Описание
Absent Input Validation in BinaryHttpParser
Summary
BinaryHttpParser does not properly validate input values thus giving attackers almost complete control over the HTTP requests constructed from the parsed output. Attackers can abuse several issues individually to perform various injection attacks including HTTP request smuggling, desync attacks, HTTP header injections, request queue poisoning, caching attacks and Server Side Request Forgery (SSRF). Attacker could also combine several issues to create well-formed messages for other text-based protocols which may result in attacks beyond the HTTP protocol.
Details
Path, Authority, Scheme The BinaryHttpParser class implements the readRequestHead method which performs most of the relevant parsing of the received request. The data structure prefixes values with a variable length integer value. The algorithm to create a variable length integer value is below:
The parsing code below first gets the lengths of the values from the prefixed variable length integer. After it has all of the lengths and calculates all of the indices, the parser casts the applicable slices of the ByteBuf to String. Finally, it passes these values into a new DefaultBinaryHttpRequest object where no further parsing or validation occurs.
Request Method
On line 422 above, the parsed method value is passed into HttpMethod.valueOf method. The return value from this is passed to the DefaultBinaryHttpRequest constructor.
Below is the code for HttpMethod.valueOf:
If the result of methodMap.get is not null, then a new arbitrary HttpMethod instance will be returned using the provided name value.
methodMap is an instance of type EnumNameMap which is also defined within the HttpMethod class:
Note that EnumNameMap.get() returns a boolean value, which is not null. Therefore, any arbitrary http verb used within a BinaryHttpRequest will yield a valid HttpMethod object. When the HttpMethod object is constructed, the name is checked for whitespace and similar characters. Therefore, we cannot perform complete injection attacks using the HTTP verb alone. However, when combined with the other input validation issues, such as that in the path field, we can construct somewhat arbitrary data blobs that satisfy text-based protocol message formats.
Impact
Method is partially validated while other values are not validated at all. Software that relies on netty to apply input validation for binary HTTP data may be vulnerable to various injection and protocol based attacks.
Пакеты
io.netty.incubator:netty-incubator-codec-bhttp
< 0.0.13.Final
0.0.13.Final
Связанные уязвимости
The netty incubator codec.bhttp is a java language binary http parser. In affected versions the `BinaryHttpParser` class does not properly validate input values thus giving attackers almost complete control over the HTTP requests constructed from the parsed output. Attackers can abuse several issues individually to perform various injection attacks including HTTP request smuggling, desync attacks, HTTP header injections, request queue poisoning, caching attacks and Server Side Request Forgery (SSRF). Attacker could also combine several issues to create well-formed messages for other text-based protocols which may result in attacks beyond the HTTP protocol. The BinaryHttpParser class implements the readRequestHead method which performs most of the relevant parsing of the received request. The data structure prefixes values with a variable length integer value. The parsing code below first gets the lengths of the values from the prefixed variable length integer. After it has all of the l