Skip to content

fix(ipv6): a truncated IPv6 extension header rebuilds padded to its declared length #1451

Closed

Description

@JarryShaw

Bug. An IPv6 extension header cut short inside itself does not rebuild byte-exact from its own info. The rebuild pads the header out to its declared length.

Repro on main (78991b7d5): a Routing header declares 24 octets (Hdr Ext Len 2), but only 23 are captured.

rt = bytes([17, 2, 0, 1]) + b'\x00'*4 + b'\x11'*16
body = rt[:23]
raw = bytes([0x60,0,0,0]) + struct.pack('!HBB', len(body), 43, 64) + b'\x00'*32 + body
p = IPv6(raw, len(raw))
p.data == raw                                    # True  (parent is exact)
ex = next(iter(p._exthdr.values()))
len(type(ex).from_data(ex.info).data), len(ex.data)   # 24, 23

The #1449 cross-review reports the same for AH. It also cut every extension header class at 8 points and found other truncated cases fail the same way.

Found during the #1449 review. #1449 itself does not change this behaviour, because its trim only shortens.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  2. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    Blocked until #1449 merges. #1449 changes how extension-mode headers trim their data, in internet.py, and this fix lives in the same files. A worker will start from main once #1449 is in.

  3. added
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  4. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1449 merged as 2f7aadd08. Back to pending; a worker can now start from main.

  5. added
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 9, 2026
  6. moved this from Blocked to Pending in PyPCAPKiton Oct 9, 2026
  7. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    A worker is on it now, on branch fix/1451-truncated-ext-header.

  8. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  9. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    Related: #1458 is the general form of this bug. Any header cut inside a fixed-width field is zero-filled on parse (pcapkit/corekit/fields/field.py:586), across every protocol family. The worker on this issue is checking whether the corekit root cause is what drives the IPv6 extension-header case, so the two may close together.

  10. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    A fix is ready on fix/1451-truncated-ext-header (96488354b). It rejects a truncated extension header and keeps the octets as captured. Before I open the PR, I've asked on #1458 whether to take that approach or fix the zero-fill in corekit instead; the corekit fix would cover this issue too.

  11. added
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Oct 9, 2026
  12. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    Decided on #1458: the fix goes into corekit (option 2), and that PR will close this issue too. The reject-based branch is dropped.

  13. removed
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Oct 9, 2026
  14. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 9, 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

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

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions