Skip to content

fix(toolkit): dpkt reads TCP and IPv6 fragments past the end of an IPv6 packet whose Payload Length is zero #1651

Closed

Description

@JarryShaw

Describe the bug
With engine='dpkt', an IPv6 packet whose Payload Length is 0 does not get the default engine's TCP reassembly, trace or IPv6 reassembly inputs:

  • No Jumbo Payload option. The default engine dissects no payload, so it finds no TCP and no Fragment header. dpkt hands one over anyway, with its payload running to the end of the record, link-layer trailer included.
  • With a Jumbo Payload option (RFC 2675). The default engine's payload ends at the Jumbo Payload Length (pcapkit/protocols/internet/ipv6.py:224). dpkt's keeps going: into a trailer, or, with no trailer, past a Jumbo Payload Length shorter than the packet.

6in4 behaves the same way, except that the IPv4 Total Length already cuts off a trailer.

dpkt 1.9.8 cuts an IPv6 payload only when the Payload Length is non-zero (dpkt/ip6.py:76). tcp_reassembly (pcapkit/toolkit/dpkt.py:975) and tcp_traceflow (:1039) take tcp.data as it is (:1029, :1095). ipv6_reassembly (:866) also cuts at the Payload Length only when it is non-zero (:909).

Reproduction on main (b375656e1), Python 3.14.8 and 3.11.15, dpkt 1.9.8.

Each case is an Ethernet frame, carrying 6in4 where the row says so. The IPv6 packet has the Payload Length shown and carries either a TCP segment with 4 octets of data, or one IPv6 Fragment header (offset 0, M=1, 16 octets of data). The trailer is 6 octets of 0xee. Extracted with reassembly=True, tcp=True, ipv6=True, trace=True.

TCP cells give the reassembly payload octets / whether it was traced (- means none). Fragment cells give the payload octets of the IPv6 reassembly input.

frame default dpkt scapy
IPv6, TCP (control) 4 / yes 4 / yes 4 / yes
Payload Length 0, TCP - / no 4 / yes - / no
the same, with trailer - / no 10 / yes - / no
6in4, Payload Length 0, TCP - / no 4 / yes - / no
Payload Length 0, Fragment header - 16 -
the same, with trailer - 22 -
jumbogram (Hop-by-Hop Jumbo option, Payload Length 0), TCP (control) 4 / yes 4 / yes 4 / yes
the same, with trailer 4 / yes 10 / yes 4 / yes
Jumbo Payload Length 2 short, no trailer 2 / yes 4 / yes 2 / yes
6in4 jumbogram, Jumbo Payload Length 2 short 2 / yes 4 / yes 2 / yes

pypcapfile declines TCP over IPv6 by design (pcapkit/toolkit/pypcapfile.py:23), and pyshark does no reassembly, so neither is shown.

Expected behavior
dpkt hands over the same inputs as the default engine. For a Payload Length of 0 with no Jumbo Payload option, that means no input. Otherwise, the payload ends at the Jumbo Payload Length.

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 13, 2026
  2. moved this to Pending in PyPCAPKiton Oct 13, 2026
  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 13, 2026
  4. JarryShaw commented on Oct 13, 2026

    @JarryShaw
    OwnerAuthor

    Blocked until the #1637/#1638 dpkt PR merges, because both edit pcapkit/toolkit/dpkt.py's ipv6_reassembly.

  5. moved this from Pending to Blocked in PyPCAPKiton Oct 13, 2026
  6. 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 13, 2026
  7. JarryShaw commented on Oct 13, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1655 has merged. A worker has this, in a single dpkt PR that also covers #1654 and the dpkt parts of #1609 and #1626.

  8. moved this from Blocked to WIP in PyPCAPKiton Oct 13, 2026
  9. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 13, 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