Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-552

HTTP2: HpackDecoder might not throw HPackException although it should

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 1.3.0.CR3
    • 1.3.0.CR2
    • None
    • None
    • Hide

      E.g.: add following three tests into HpackSpecExamplesUnitTestCase.java:

          @Test
          public void testExample_D_2_110() throws HpackException {
              // my, wrong header field without indexing data test
              byte[] data = { 0x00 };
              HpackDecoder decoder = new HpackDecoder(Hpack.DEFAULT_TABLE_SIZE);
              HeaderMapEmitter emitter = new HeaderMapEmitter();
              decoder.setHeaderEmitter(emitter);
              try {
                  decoder.decode(ByteBuffer.wrap(data));
              } catch (HpackException e) {
                  // This exception is expected
                  return;
              }
              Assert.fail("Didn't get expected HPackException!");
          }
      
          @Test
          public void testExample_D_2_111() throws HpackException {
              // my, wrong header field with incremental indexing data test (last byte is not passed)
              byte[] data = { 0x60, 0x01, 0x78, 0x01 }; // , 0x79};
              HpackDecoder decoder = new HpackDecoder(Hpack.DEFAULT_TABLE_SIZE);
              HeaderMapEmitter emitter = new HeaderMapEmitter();
              decoder.setHeaderEmitter(emitter);
              try {
                  decoder.decode(ByteBuffer.wrap(data));
              } catch (HpackException e) {
                  // This exception is expected
                  return;
              }
              Assert.fail("Didn't get expected HPackException!");
          }
      
          @Test
          public void testExample_D_2_112() throws HpackException {
              // my, wrong header field with incremental indexing data test (last byte is not passed)
              byte[] data = { 0x60, 0x02, 0x78 }; //, 0x79};
              HpackDecoder decoder = new HpackDecoder(Hpack.DEFAULT_TABLE_SIZE);
              HeaderMapEmitter emitter = new HeaderMapEmitter();
              decoder.setHeaderEmitter(emitter);
              try {
                  decoder.decode(ByteBuffer.wrap(data));
              } catch (HpackException e) {
                  // This exception is expected
                  return;
              }
              Assert.fail("Didn't get expected HPackException!");
          }
      

      and run

      mvn clean install -DfailIfNoTests=false -Dtest="io.undertow.protocols.http2.HpackSpecExamplesUnitTestCase#testExample_D_2_11*"
      

      to see them failed.

      Show
      E.g.: add following three tests into HpackSpecExamplesUnitTestCase.java : @Test public void testExample_D_2_110() throws HpackException { // my, wrong header field without indexing data test byte [] data = { 0x00 }; HpackDecoder decoder = new HpackDecoder(Hpack.DEFAULT_TABLE_SIZE); HeaderMapEmitter emitter = new HeaderMapEmitter(); decoder.setHeaderEmitter(emitter); try { decoder.decode(ByteBuffer.wrap(data)); } catch (HpackException e) { // This exception is expected return ; } Assert.fail( "Didn't get expected HPackException!" ); } @Test public void testExample_D_2_111() throws HpackException { // my, wrong header field with incremental indexing data test (last byte is not passed) byte [] data = { 0x60, 0x01, 0x78, 0x01 }; // , 0x79}; HpackDecoder decoder = new HpackDecoder(Hpack.DEFAULT_TABLE_SIZE); HeaderMapEmitter emitter = new HeaderMapEmitter(); decoder.setHeaderEmitter(emitter); try { decoder.decode(ByteBuffer.wrap(data)); } catch (HpackException e) { // This exception is expected return ; } Assert.fail( "Didn't get expected HPackException!" ); } @Test public void testExample_D_2_112() throws HpackException { // my, wrong header field with incremental indexing data test (last byte is not passed) byte [] data = { 0x60, 0x02, 0x78 }; //, 0x79}; HpackDecoder decoder = new HpackDecoder(Hpack.DEFAULT_TABLE_SIZE); HeaderMapEmitter emitter = new HeaderMapEmitter(); decoder.setHeaderEmitter(emitter); try { decoder.decode(ByteBuffer.wrap(data)); } catch (HpackException e) { // This exception is expected return ; } Assert.fail( "Didn't get expected HPackException!" ); } and run mvn clean install -DfailIfNoTests= false -Dtest= "io.undertow.protocols.http2.HpackSpecExamplesUnitTestCase#testExample_D_2_11*" to see them failed.

    Description

      Generally according to the specification: In case when client sends corrupted header data to server - like incomplete header data - causing that server cannot decompress them properly, server should close connection with "COMPRESSION_ERROR" connection-error type.

      Current implementation of HpackDecoder.java is although quite benevolent in such cases causing that connection is terminated later on with "PROTOCOL_ERROR" connection-error type.

      This is probably no big problem and actually is not big issue as connection is actually terminated although with wrong error type, but it is violation against specification.

      Attachments

        Issue Links

          Activity

            People

              sdouglas1@redhat.com Stuart Douglas
              jstourac@redhat.com Jan Stourac
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: