GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — HTTP/2.0 non US-ASCII header names should be rejected · Issue #11975 · netty/netty Closed DescriptionExpected behaviorAccording to the HTTP/2.0 RFC :
Since it is referring to HTTP/1.x RFC, here is the interesting part :
US-ASCII is only using 7 bits. So during the header name parsing, any bytes in the form As reminder, here is the header name validator used in Netty for HTTP/1.1 : private static void validateHeaderNameElement(byte value) { switch (value) { case 0x1c: case 0x1d: case 0x1e: case 0x1f: case 0x00: case '\t': case '\n': case 0x0b: case '\f': case '\r': case ' ': case ',': case ':': case ';': case '=': throw new IllegalArgumentException( "a header name cannot contain the following prohibited characters: =,;: \\t\\r\\n\\v\\f: " + value); default: // Check to see if the character is not an ASCII character, or invalid if (value < 0) { throw new IllegalArgumentException("a header name cannot contain non-ASCII character: " + value); } } Actual behaviorThe only validation made on header names is : private static final ByteProcessor HTTP2_NAME_VALIDATOR_PROCESSOR = new ByteProcessor() { @Override public boolean process(byte value) { return !isUpperCase(value); // isUpperCase : return value >= 'A' && value <= 'Z'; } }; Thus non-ASCII characters are accepted and corrupted when transformed into string (ie : 2 byte coding UTF-16BE chars). As an example, this non-ASCII byte : Minimal yet complete reproducer code (or URL to code)import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import io.netty.handler.codec.http2.DefaultHttp2Headers; import io.netty.handler.codec.http2.Http2Error; import io.netty.handler.codec.http2.Http2Exception; import io.netty.util.AsciiString; public class Test { @Test void shouldRejectNonUsAsciiValues() { // U+1F631 : 😱 : F0 9F 98 B1 byte[] buf = new byte[] {(byte) 0xF0, (byte) 0x9F, (byte) 0x98, (byte) 0xB1}; DefaultHttp2Headers headers = new DefaultHttp2Headers(); Assertions.assertThatThrownBy(() -> headers.add(new AsciiString(buf), "test")) .isInstanceOf(Http2Exception.class) .hasMessageStartingWith("invalid header name") .hasFieldOrPropertyWithValue("error", Http2Error.PROTOCOL_ERROR); } } Netty version4.1.72 JVM version (e.g.
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |