Skip to content

fix(ipv6): a cut upper layer after an extension header falls back to Raw that duplicates the header #1471

Closed

Description

@JarryShaw

Bug. An IPv6 packet whose extension header is followed by a truncated upper layer duplicates the extension header when rebuilt.

Repro on main (94ae9664c), with Destination Options → TCP and the packet cut at 57 octets:

dst = bytes([6,0,1,4,0,0,0,0])                               # next header = TCP
tcp = struct.pack('!HHIIBBHHH',1,2,0,0,0x50,2,0,0,0) + b'x'
body = dst + tcp
full = bytes([0x60,0,0,0]) + struct.pack('!HBB', len(body), 60, 64) + b'\x00'*32 + body
p = IPv6(full[:57], 57)
p.data == full[:57]                       # True
len(IPv6.from_data(p.info).data)          # 65, not 57

The upper layer falls back to Raw, and that Raw includes the extension header, so the rebuild writes the header twice.

The #1465 cross-review reports 51 of 69 cuts failing this way for each of DST→TCP, HBH→TCP, HBH→DST and DST→AH. #1465's own sweep missed it because its chains end in No Next Header (59).

The review also found that the dict-form rebuild raises AttributeError: 'HIP' object has no attribute 'type' for Ethernet/IPv6/HIP cut at 56. That happens on main too, but I have not reproduced it.

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 #1466 merges. #1466 changes pcapkit/protocols/internet/ipv6.py (_lookup_exthdr), which is where this fix goes. A worker starts from main once #1466 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: #1466 merged (8328fd3bb). #1471 and #1473 both touch pcapkit/protocols/internet/ipv6.py, so one worker is taking both, rebased on current main.

  5. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 9, 2026
  6. 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