Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug4: heap oob read (info leak) of swfmill swf2xml #49

Open
ghost opened this issue Jul 1, 2018 · 0 comments
Open

bug4: heap oob read (info leak) of swfmill swf2xml #49

ghost opened this issue Jul 1, 2018 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 1, 2018

poc:
https://drive.google.com/open?id=1NT-eAqw-yxV8IlwKG-Y2FoaOxIe43kjK
asan:
https://drive.google.com/open?id=14LD3HjGsdQZOyw2FLocu6TzTyRP55yBS

bool MetadataInfo::parse( Reader *r, int end, Context *ctx ) {
file_offset = r->getPosition();
if( ctx->debugTrace ) {
fprintf( stderr, "PARSE %s @%i-%i :%i\n",
"MetadataInfo",
r->getPosition(),
r->getBits(),
end );
}

nameIndex = r->getU30();
if( ctx->debugTrace ) {
fprintf( stderr, "PARSE %s: %" PRIi32 "\n",
"nameIndex",
nameIndex );
}
valuesCount = r->getU30();
if( ctx->debugTrace ) {
fprintf( stderr, "PARSE %s: %" PRIi32 "\n",
"valuesCount",
valuesCount );
}


{
if( ctx->debugTrace ) {
fprintf( stderr, "PARSE list<%s> %s: %i items, @%i-%i :%i\n",
"U30",
"keys",
valuesCount,
r->getPosition(),
r->getBits(),
end );
}
U30 *item;
for( int i=0; i<valuesCount; i++ ) {
item = U30::get(r,end,ctx);
keys.append( item );
}
}

Due to that the val valuesCount is set based on the value from file (r->getU30()), this value can be faked!
In the loop below, for( int i=0; i<valuesCount; i++ ), it will execute U30::get(r,end,ctx) many times without checking.

bool U30::parse( Reader *r, int end, Context *ctx ) {
file_offset = r->getPosition();
if( ctx->debugTrace ) {
fprintf( stderr, "PARSE %s @%i-%i :%i\n",
"U30",
r->getPosition(),
r->getBits(),
end );
}

value = r->getU30();
if( ctx->debugTrace ) {
fprintf( stderr, "PARSE %s: %" PRIi32 "\n",
"value",
value );
}


return r->getError() == Reader::ok;
}

the val end is useless!
So Heap Out-of-bound Read will happen, which may cause memory leaking!

@djcsdy djcsdy added the bug label Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant