Skip to content

fix(application): rebuild a cut HTTP/2 frame after the connection preface (#2665) - #2675

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2665-httpv2-preface-replay
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2665-httpv2-preface-replay

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — fixes a bug

Description of your pull request and other information

A cut HTTP/2 frame that follows the connection preface rebuilds as captured. Before this, HTTPv2.from_data returned the first octets of the preface.

  • Cause: replay_short_read cut from the first octet of the rebuilt data, but HTTP.pack writes the 24-octet preface ahead of the frame header.
  • Fix: the replay starts where the header begins, at the rebuilt length minus the header's buffered width. That assumes pack writes nothing after the header schema, which holds for every protocol that reaches the replay, and the docstring states the assumption.

A Sonnet cross-review returned GOOD TO GO on the code. Instrumenting 196,184 replay calls across all 703 unit-tier modules found a non-zero start only for HTTPv2 after a preface. Of 34,962 trials, the 209 that changed are all preface-plus-cut HTTP/2 rebuilds going from wrong to right. Its docs request, a dead cross-reference, is fixed in this head. #2673 tracks an older SCTP defect the review found.

Closes #2665

…face (#2665)

A frame the capture cuts short after the connection preface rebuilds from
HTTPv2.from_data as the preface's first octets. replay_short_read measured its
cut from the first octet of the rebuilt data, which the frame header opens only
when nothing is ahead of it, and HTTP.pack writes the preface there.

- replay_short_read starts the cut where the header starts, past what is
  written ahead of it: a header cut short has no payload past it, so it ends
  the rebuilt data. Every other replay still starts at the first octet.
- Tests: SETTINGS, DATA, HEADERS and PING frames after the preface, cut at
  every offset through TCP and through HTTPv2, rebuilt from info, its dict and
  the HTTP base; each whole frame as the control; and a short-read sweep case.

HTTP, HTTP/2, schema, sweep, option, doc-claim, member-order and RFC-constants
modules pass; captures parse and rebuild identically to main.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at f459f6189. A Sonnet cross-review checked the change to replay_short_read, which is shared, at every caller. The only non-zero start came from HTTPv2 after a preface. It was clean alongside #2672, and every changed rebuild went from wrong to right. The dead cross-reference and the NOTE on the lead-in-only assumption are fixed in this head.

@JarryShaw
JarryShaw merged commit 0631e6b into main Nov 2, 2026
61 checks passed
@github-project-automation github-project-automation Bot moved this to Done in PyPCAPKit Nov 2, 2026
@JarryShaw
JarryShaw deleted the fix/2665-httpv2-preface-replay branch November 2, 2026 18:53
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…TTP/2 and SCTP rebuilds into 1.6.0 (#2449)

- Breaking: the IPv4, HOPOPT, IPv6-Opts, IPv6-Route, MH and HIP makers
  (#2677) raise on a value a field cannot hold, where 1.5.x wrote it
  masked; a PDM scale past one octet raises where it warned, and
  MH._decode_signed is removed. The entry gives the old and new values.
- Fixed: an SCTP packet cut short of its declared length rebuilds as
  captured (#2679).
- Folded into unreleased entries: a cut HTTP/2 frame after the connection
  preface rebuilds, into the cut-SETTINGS entry (#2675); IPv4's Quick-Start
  function and not-used octet refusals, into the Quick-Start entry (#2677).
- No entry for the test-only 42a6133.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(application): a cut HTTP/2 frame after the connection preface rebuilds as the preface's octets

1 participant