HTTP/2: HPACK string length addition can overflow into out-of-bounds reads

Open Beginner friendly
#1,071 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Start at h2_decode_string_counted() in the HPACK decoder and trace how pos and str_len are derived before the bounds check. Rewrite the guard as str_len > len - *pos and reject oversized lengths before any allocation or Huffman/memcpy path runs. Then add a regression vector with a wrapped position-plus-length to the existing HPACK test suite and run it to confirm the reject path fires.

Written by the indexing model from the issue text.

Description

bug critical

h2_decode_string_counted() checks *pos + str_len > len with size_t arithmetic. A large decoded length can wrap the sum and pass the check, after which Huffman decoding or memcpy reads beyond the header buffer. Use str_len > len - *pos and reject oversized values before advancing or allocating. Add a regression vector with a wrapped position-plus-length.

Dominant language
C
Stars
16
Forks
7
Avg merge
4h 17m
Merged PRs (30d)
198

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from c4punks/CWIST

All issues in c4punks/CWIST

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.