-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Filter integer header names during SAPI discovery #157
Filter integer header names during SAPI discovery #157
Conversation
Integer strings have the nasty habit of being cast to actual integers by PHP, making them problematic for usage in an associative array, despite being valid per the RFC 7230 ABNF. Additionally, having them pass through `marshal_headers_from_sapi()` means that once `ServerRequest` gets them and tries to use them, `HeaderSecurity::assertValidName()` will raise an exception for integers, which could lead to unexpected server errors. This patch chooses to filter such header names out entirely. Doing so prevents those server errors. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Creates a "security features" document that brings in the former v2 "forward migration" document around filtering x-forwarded-* headers, and also adds narrative around filtering integer headers. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
…hange Signed-off-by: Matthew Weier O'Phinney <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServerRequestFactory::fromGlobals()
needs test to ensure it filters out integer-like headers since marshalHeadersFromSapi()
is an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A typo, otherwise good.
Co-authored-by: Aleksei Khudiakov <[email protected]> Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Adds integer and string-integer keys from the `marshalHeadersFromSapi()` test case to the ServerRequestFactory test cases to demonstrate they get filtered out. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Links to PHP bug 80309 in discussion of the string integer value to integer conversion. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
When a header field is added with `withHeader()` or `withHeaderLine()`, these will accept strings that have digits only, which can also lead to the issues presented elsewhere. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Co-authored-by: Aleksei Khudiakov <[email protected]> Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Description
Integer strings have the nasty habit of being cast to actual integers by PHP, making them problematic for usage in an associative array, despite being valid per the RFC 7230 ABNF.
Additionally, having them pass through
marshal_headers_from_sapi()
means that onceServerRequest
gets them and tries to use them,HeaderSecurity::assertValidName()
will raise an exception for integers, which could lead to unexpected server errors.This patch chooses to filter such header names out entirely.
It also documents the change, and ways to address it if you previously depended on integer header field names.
Fixes #11