Skip to content

Fix path_info pointer underflow in CGI fix_pathinfo handling - #250

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/cgi-pathinfo-underflow
Closed

Fix path_info pointer underflow in CGI fix_pathinfo handling#250
iliaal wants to merge 1 commit into
PHP-8.4from
fix/cgi-pathinfo-underflow

Conversation

@iliaal

@iliaal iliaal commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Fix a path_info pointer underflow in the CGI fix_pathinfo strip loop: when PATH_INFO is shorter than the suffix stripped from SCRIPT_FILENAME, env_path_info + pilen - slen underflows and the subsequent path_info[0] write goes out of bounds.

When the PATH_INFO supplied by the webserver is shorter than the
suffix stripped from SCRIPT_FILENAME, computing env_path_info +
pilen - slen underflows and the subsequent path_info[0] = 0 writes
out of bounds before the start of the string.

The FPM side of this same loop was hardened by commit ab061f9
(CVE-2019-11043) but sapi/cgi was never given the equivalent guard.
Mirror it: only derive path_info when pilen exceeds slen, and skip
the ORIG_*/SCRIPT_NAME juggling when there is no extracted path.
@iliaal
iliaal force-pushed the fix/cgi-pathinfo-underflow branch from 6f3c8a6 to e90c6b5 Compare August 22, 2026 14:52
@iliaal

iliaal commented Aug 22, 2026

Copy link
Copy Markdown
Owner Author

Upstream: php#23411

@iliaal iliaal closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant