CWE-134
ypKChz

CWE-134

Weakness ID:134(Weakness Base)

Status: Draft

̖

v

{Ǝ㐫݂\tgEFÁAprintf n̊֐ɊO琧”\ȏgpĂ܂B̊֐́Aobt@I[o[t[f[^\̖”\܂B

Ǝ㐫̔

YvbgtH[


C++
Perl ipxj
T|[g錾

Ǝ㐫̔

܂ɁA[U̓͂ƂĈvO݂܂B{Ǝ㐫́A񂪎w肳ĂȂObZ[W\zR[hɕpɂɔ܂B

n扻⍑ۉ̏ꍇɂ́AŗL̃bZ[W̃|WgUiƂĎgp”\܂B |Wg̐ɂAU҂̓bZ[WAARec̉”\ł邽߁A̖͑̐Ǝ㐫̌ʂƂĔ܂B

ʓIȉe

 

e󂯂͈ e
@ ̖́AvOւ̍UPlȏ̊J”\܂B
ANZX ̖ɂACӂ̃R[hs”\܂B

 

U󂯂”\

ɍ

oi

ÓI
{Ǝ㐫͎ÓI͂ɂČo”\łBŋ߂̃c[̑́AtH[X|WeBuŏ邽߂ɁAf[^t[͂␧x[X̋ZpgpĂ܂B

ubN{bNX:
̖́Aɂ߂Ē (G[bZ[W̃O擾) Ŕꍇ߁AubN{bNXɂ錟m͍łBݓIȖ̑́A\[XR[h⓯̃\[XɊ֘AȂAst@Cɑ݂Xɂ܂B

LFI

ƎȃR[h

 1:

 

ȉ̗́AprintWrapper() ֐̒ŁAprintf() Ăяo߂ɍU”\܂BiUP邽߁AX^bNobt@[lj܂Bj

TvF C ij
#include <stdio.h>

void printWrapper(char *string) {

printf(string);
}

int main(int argc, char **argv) {

char buf[5012];
memcpy(buf, argv[1], 5012);
printWrapper(argv[1]);
return (0);
}

 

 2:

 

ȉ̗́Asnprintf()𗘗păR}hC̈obt@ɃRs[܂B

TvF C ij
int main(int argc, char **argv){
char buf[128];
...
snprintf(buf,128,argv[1]);
}

̃R[hł́AU҂X^bN̓e{Awq܂ރR}hC̈gpăX^bNɏނƂ”\łBu%xv Ȃǂ̏wqA֐vȏɓ͂邱ƂŁAX^bN̓eǂݎ邱Ƃ”\łB(̗ł́A֐͏󂯎Ă܂B)

U҂́u%nvgpAsnprintf() ɂ肱܂ł̏o̓oCgw肳ꂽɏ݂ȂAX^bNɏމ”\܂B́AlǂݍނƂAz肳ꂽƂ͈قȂ̂łB IȎł́AX^bÑ|C^lSɐ䂷邽߂ɁA4 oCg炵ď݂܂B

 

 3:

 

ɂẮÄʒu𐧌䂷鏑wqɂAǂݏU”\܂܂Bwq̗Ƃ glibc ŋLqꂽȉ̃R[h܂B

TvF C ij
printf("%d %d %1$d %1$d¥n", 5, 9);


̃R[h́A u5 9 5 5v Əo͂܂B܂Ahalf-writes (%hn) gpĂA̔Cӂ DWORDS 𐳊mɐ䂷邱Ƃ”\łB̂ƂɂA1̗lȁA4 oCg炵ďޕKv̂UP邱Ƃ”\łB

 

 

Q ڍ
CVE-2002-1825 format string in Perl program
CVE-2001-0717 format string in bad call to syslog function
CVE-2002-0573 format string in bad call to syslog function
CVE-2002-1788 format strings in NNTP server responses
CVE-2007-2027 Chain: untrusted search path enabling resultant format string by loading malicious internationalization messages

 

Q̊ɘa

tF[Y:v`

{Ǝ㐫̉e󂯂ȂgpĉB

tF[Y:

SĂ̏֐A[UłȂÓIȕłȀÅ֐ɓK؂Ȑ̈nĂ邱ƂmFĉB”\Ȃ΁Aɂ u%nv T|[gȂ֐gpĉB

rhFsK؂ȎgpxÔ\邽߁ARpCуJ[̌xɒӂĉB

̑̕⑫

̐Ǝ㐫́AʓIɃobt@I[o[t[̃JeSɕނ܂Aɂ̓obt@̓I[o[t[Ă܂B
̖ɂƎ㐫́ArIVł (1999) A•ψ󂯎֐A󂯎̐mF錻IȎi݂ȂƂɋN܂BC̃^C֐܂߁A•ψ󂯎֐̒ōłʓIȂ̂́A printf() nłB
̖͗lXȌ`Ō܂B
wq̂Ȃ *printf() R[͊댯łAU”\܂BႦ΁AReLXgɂāAprintf(y,input); ͍U邱Ƃ܂񂪁Aprintf(input); ɂ͍U”\܂B printf(input); R[sɗpꂽʁA͕͏wqƂĎgp邽߁AU҂ɃX^bN`”\܂Bcp[^̓X^bNo邽߁AU҂͏wqƋɓ͕lߍ݁AX^bN̒lǂݎn߂܂Bň̏ꍇɂ́A̕spɂACӂ̒l (܂͍UvȌƂȂl) ғ̃vÕɏސ^Ă܂”\܂B

ʓIɁAUΏۂƂȂ̂̓t@CAvZXAʎqłB

̖́AC/C++ɂm̐Ǝ㐫łAeՂɌmł邱ƂČ݂͂قƂǑ݂܂B̖肪U󂯂Ȍ̈‚ u%nv ̏wqɂ܂Bu%nv́AɂĎw肳ꂽɑ΂A܂łɏɂĕ\ꂽ݂܂BIɐ邱ƂŁAӂ郆[U̓X^bN̒l𗘗p write-what-where condition (CWE-123) N”\܂B
܂ȀwqlɍUɎgp”\܂BႦ΁Au%9999sv̏wq́Aobt@I[o[t[̗UAfprintf ̗lȃt@CtH[}bg֐ŎgpꂽꍇA\傫ȏo͂𐶐”\܂B

ɂ鑼̐Ǝ㐫Ƃ̈ˑ֌W

 

ˑ֌W ڍ
ƗI ̐Ǝ㐫̗LɊ֌WAƗĔ

 

֌W

 

Nature Type ID Name View(s) this relationship pertains to
ChildOf Weakness Class 20 Improper Input Validation Seven Pernicious Kingdoms (primary)700
ChildOf Weakness Class 74 Failure to Sanitize Data into a Different Plane (aka 'Injection') Development Concepts (primary)699
Research Concepts (primary)1000
ChildOf Category 133 String Errors Development Concepts699
ChildOf Category 633 Weaknesses that Affect Memory Resource-specific Weaknesses (primary)631
ChildOf Category 726 OWASP Top Ten 2004 Category A5 - Buffer Overflows Weaknesses in OWASP Top Ten (2004) (primary)711
ChildOf Category 743 CERT C Secure Coding Section 09 - Input Output (FIO) Weaknesses Addressed by the CERT C Secure Coding Standard (primary)734
ChildOf Category 808 2010 Top 25 - Weaknesses On the Cusp Weaknesses in the 2010 CWE/SANS Top 25 Most Dangerous Programming Errors(primary)800
PeerOf Weakness Base 123 Write-what-where Condition Research Concepts1000
MemberOf View 630 Weaknesses Examined by SAMATE Weaknesses Examined by SAMATE (primary)630
MemberOf View 635 Weaknesses Used by NVD Weaknesses Used by NVD (primary)635

 

v iCWE ̌j

CȊǑɂ鏑̖͒łB܂̓fBXNARg[Af[^j́APerlA PHPAPython Ȃǂ C ȊǑŏꂽAvP[Vɂ鏑̍U̗vƂȂ܂B

e󂯂VXe\[X

@\

O̎擾
G[
ʓIȃAEgvbg

̐

smiJ҂̍šʂɂȂƎ㐫j   

gDł̕

 

gD܂͑gDł̕ m[h ID CWE̕ނƂ̓Kx ޖ
PLOVER Format string vulnerability
7 Pernicious Kingdoms Format String
CLASP Format string problem
CERT C Secure Coding FIO30-C Exact Exclude user input from format strings
OWASP Top Ten 2004 A1 CWE More Specific Unvalidated Input
CERT C Secure Coding FIO30-C Exclude user input from format strings
WASC 6 Format String

 

֘AUp^[

 

CAPEC-ID Up^[ (CAPEC Version 1.5)
67 String Format Overflow in syslog()

 

zCg{bNX̒`

R[hpXȉ̏𖞂Ǝ㐫
1. JnXe[ggœ͂tꍇ
2. ȉ̏𖞂IXe[ggŕ񏈗֐ɏnꍇ
    E̓f[^͕̈ꕔłAA]܂Ȃłꍇ
Ĺu]܂ȂvƂ́Aȉ̏Ԃw܂B
1. ؂ĂȂ
2. @Ō؂Ă

Q

Steve Christey. "Format String Vulnerabilities in Perl Programs". <http://www.securityfocus.com/archive/1/418460/30/0/threaded>.
Hal Burch and Robert C. Seacord. "Programming Language Format String Vulnerabilities". <http://www.ddj.com/dept/security/197002914>.
Tim Newsham. "Format String Attacks". Guardent. September 2000. <http://www.lava.net/~newsham/format-string-attacks.pdf>.
[REF-11] M. Howard and D. LeBlanc. "Writing Secure Code". Chapter 5, "Format String Bugs" Page 147. 2nd Edition. Microsoft. 2002. 

XV

[2011N0421]
  2010N1012_̃f[^ɍXV
[2009N0629]
  2009N0202_̉L URL ɍ쐬
    http://cwe.mitre.org/data/definitions/134.html


o^ 2011/04/21

ŏIXV 2023/04/04