Repository navigation
Reject an HTTP/2 request with a non-numeric content-length - #1211
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
…gits RFC 9110, section 8.6 defines the content-length field value as one or more digits and RFC 9113, section 8.1.1 requires a request that is malformed to be treated as a stream error of type PROTOCOL_ERROR. The value was parsed with Long.parseLong(), so a request with a value such as +3, -0 or -1 was accepted. A negative value was treated as if the field was absent. HTTP/1.1 rejects the same values with a 400 response. Check the value when the header field is received.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC 9110, section 8.6 defines the value of a content-length field as one or more digits, and RFC 9113, section 8.1.1 requires a request that is malformed to be treated as a stream error of type PROTOCOL_ERROR.
In HTTP/2 the value was parsed with
Long.parseLong(), so a request withcontent-length: +3,-0or-1was accepted, and a negative value was treated as if the field was absent. HTTP/1.1 rejects the same values with a 400 response.This checks the value in
Stream.emitHeader()and resets the stream with PROTOCOL_ERROR if it is not made of digits.Tested with a running Tomcat and a raw HTTP/2 client: without the change those requests are processed, with the change the stream is reset with PROTOCOL_ERROR. Valid values, including ones with leading zeros, are not affected.