gdCtxPrintf vsnprintf return value not checked - leaks stack memory #211
|
we probably should extend the IO layer to accept a va_list rather than go through a local buffer. then we can just pass it down directly w/out any stack allocation. |
fmunozs
commented
May 27, 2016
|
Hello, will this get a CVE assigned? Thanks. |
kaplanlior
commented
Jul 7, 2016
|
CVE-2016-5116 at http://seclists.org/oss-sec/2016/q2/430 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description:
See reproduction test case, length from the failed vsnprintf attempt [1] to copy more than 8000 chars on a 4096 buffer, vsnprintf [2] "a return value of size or more means that the output was truncated", however libgd returns this length as is and PHP prints more information from memory than it should.
Libgd isn't checking the vsnprintf return value and PHP 5.5 will print the length specified, leaking memory data.
This was reported to PHP
https://bugs.php.net/bug.php?id=72115
Compile PHP 5.5 with ASAN.
BP on https://github.com/php/php-src/blob/PHP-5.5/ext/gd/gd_ctx.c#L39
[1] https://github.com/libgd/libgd/blob/master/src/gd_xbm.c#L188
[2] http://linux.die.net/man/3/vsnprintf /
Test script:
Actual result: