You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ext/phar: out-of-bounds read/write in Phar::webPhar() 301 redirect (full path length used instead of basename) #25093
webPhar() 301 redirect: full-path length used instead of basename length
Category: heap-buffer-overflow READ + 1-byte WRITE of '\0'; CWE-125/CWE-787.
Context: non-CGI SAPI (e.g. php -S), request URI ending exactly at the phar
basename (no PATH_INFO), phar located in a nested directory; default stub
calls Phar::webPhar().
Observed: ASan reports heap-buffer-overflow READ of size 1 in
zim_Phar_webPhar (ext/phar/phar_object.c:770) under the cli-server SAPI;
the read address lands (fname_len - basename_len) bytes past the end of the
SAPI request_uri buffer (PoC: 15 bytes past, path /work/site/dir/app.phar).
Relevant source: ext/phar/phar_object.c:769-771
(tmp = strstr(path_info, basename) + fname_len; sa = *tmp; *tmp = '\0';),
restore at :783.
Source assessment: the offset should advance by the basename length but uses
the full server-side path length (fname_len); the mismatch equals the phar's
directory prefix length. The same function uses the correct
(fname_len - (basename - fname)) computation when building pt at :691.
Expected: advance by basename length.
Activity
Fix phpGH-25093: Phar::webPhar() redirect reads past the request URI (p…
Merge branch 'PHP-8.4' into PHP-8.5
[ci skip] Merge branch 'PHP-8.6' into fix-zend-long-uint-ovfl-32bit-8.6