Skip to content

fix(internet): a cut behind an IPv4 Total Length of 0 reads checksums INVALID #2689

Closed

Description

@JarryShaw

Found by the short-read audit, and confirmed by an independent re-probe. Neither case is a regression; the first is the #2653 symptom on the TSO path, which #2668 left out.

  • IPv4 with Total Length 0 (TSO), cut by snaplen. IPv4.read reads a Total Length of 0 as "the rest of the frame", so the frame's lengths are the only record of the cut. Internet._decode_next_layer clears frame_length regardless, so GRE, ICMP and IGMP behind such a packet read their checksum INVALID and raise a false ChecksumWarning. The NOTE in _decode_next_layer admits the cut is lost.
  • GRE(cut) constructed directly, with the header cut inside the checksum or an earlier field. It verifies the zero-filled checksum and reads INVALID. It never consults the header's __short_read__, which it already has.

Fix:

  • _decode_next_layer keeps the cut when the layer declared no length. The re-probe validated a declared=False path that the shared verifier carries to ICMP and IGMP, and that AH passes on.
  • GRE.read reports TRUNCATED whenever its header carries a short-read record.
  • Tests cover each protocol behind a TSO IPv4 at every cut, and a GRE header cut directly.

Activity

  1. added this to the PyPCAPKit v1.6 milestone on Nov 2, 2026
  2. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    on Nov 2, 2026
  3. moved this to Pending in PyPCAPKiton Nov 2, 2026
  4. JarryShaw commented on Nov 2, 2026

    @JarryShaw
    OwnerAuthor

    Filed from the short-read audit, and confirmed by an independent re-probe. A worker is on it now. Moved to wip.

  5. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Nov 2, 2026
  6. moved this from Pending to WIP in PyPCAPKiton Nov 2, 2026
  7. JarryShaw commented on Nov 2, 2026

    @JarryShaw
    OwnerAuthor

    The PR is #2699. A Sonnet review is running.

  8. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions