-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #73630: Built-in Weberver - overwrite $_SERVER['request_uri'] #7207
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
Conversation
The built-in Webserver's `on_path`, `on_query_string` and `on_url` callbacks may be called multiple times from the parser; we must not simply replace the old values, but need to concatenate the new values instead. This appears to be tricky for `on_path` due to the path normalization, so we fail if the function is called again.
Codecov Report
@@ Coverage Diff @@
## PHP-7.4 #7207 +/- ##
===========================================
+ Coverage 72.99% 73.02% +0.02%
===========================================
Files 803 803
Lines 283801 283937 +136
===========================================
+ Hits 207155 207338 +183
+ Misses 76646 76599 -47
Continue to review full report at Codecov.
|
The total length of the HTTP headers is already restricted to at most `PHP_HTTP_MAX_HEADER_SIZE` bytes, so no integer overflow can occur in our calculations.
The built-in Webserver logs errors during request parsing to stderr, but this is ignored by the php_cli_server framework, and apparently the Webserver does not send a resonse at all in such cases (instead of an 4xx). Thus we can only check that a request with an overly long path fails.
The built-in Webserver's
on_path
,on_query_string
andon_url
callbacks may be called multiple times from the parser; we must not
simply replace the old values, but need to concatenate the new values
instead.
This appears to be tricky for
on_path
due to the path normalization,so we fail if the function is called again.