Skip to content

Check HPACK Huffman code strictly#2172

Merged
maskit merged 2 commits intoapache:masterfrom
maskit:h2_improve_hpack
Jun 26, 2017
Merged

Check HPACK Huffman code strictly#2172
maskit merged 2 commits intoapache:masterfrom
maskit:h2_improve_hpack

Conversation

@maskit
Copy link
Copy Markdown
Member

@maskit maskit commented Jun 21, 2017

This fixes issues checked with these h2spec tests below.

5.2. String Literal Representation
1: Sends a Huffman-encoded string literal representation with padding longer than 7 bits
2: Sends a Huffman-encoded string literal representation padded by zero

HPACK Huffman decoder was trying to decode whole Huffman code block that includes extra padding.
This is prohibited by the spec (Sec 5.2), and it must be treated as a decoding error.
@maskit maskit added the HTTP/2 label Jun 21, 2017
@maskit maskit added this to the 7.1.0 milestone Jun 21, 2017
@maskit maskit self-assigned this Jun 21, 2017
@maskit maskit requested review from bryancall and masaori335 June 21, 2017 05:39
@maskit
Copy link
Copy Markdown
Member Author

maskit commented Jun 21, 2017

@zwoop This is nice to have because it's not a bug fix. Marked as a 7.1 candidate but there's no necessity.

++byte_boundary_crossed;
}
if (byte_boundary_crossed > 3) {
return -1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use HPACK_ERROR_COMPRESSION_ERROR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that's in HPACK.h, so we shouldn't use it here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, here is HuffmanCodec. Got it.

HPACK Huffman code didn't care whether all padding bits are one.
This is prohibited by the spec(Sec 5.2), and it must be treated as a decode error.
@maskit maskit force-pushed the h2_improve_hpack branch from dc2ee72 to b228c13 Compare June 21, 2017 06:18
--src_len;
++byte_boundary_crossed;
}
if (byte_boundary_crossed > 3) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checking length of encoded data, right? It looks like some Huffman code has 3 byte boundaries. Is this should be 4? ( e.g. |11111111|11111111|11111110|0010 fffffe2 [28])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I thought >= 3 :p

@zwoop
Copy link
Copy Markdown
Contributor

zwoop commented Jun 21, 2017

I've put this on Docs / CI for testing.

@zwoop
Copy link
Copy Markdown
Contributor

zwoop commented Jun 26, 2017

Should we land this?

@maskit maskit merged commit c530a3f into apache:master Jun 26, 2017
@zwoop
Copy link
Copy Markdown
Contributor

zwoop commented Jun 26, 2017

@maskit This does not cherry-pick cleanly to 7.1.x branch, can either of you make a PR against 7.1.x please?

@maskit
Copy link
Copy Markdown
Member Author

maskit commented Jun 26, 2017

@zwoop Made it (#2200). Actually it was able to cherry-pick cleanly. It just has two commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants