Repository navigation
fix(toolkit): the scapy adapters stop at the IP datagram's declared length (#1584) - #1589
Merged
Merged
Conversation
Owner
Author
|
Verdict: NEEDS CHANGES at Needed:
Confirmed:
|
Contributor
|
Coverage: 89.56% (unit tier, Python 3.14,
Per-file detail: the |
…ength (#1584) Scapy files the octets past an IP layer's Total Length or Payload Length as a Padding layer, and bytes() of every layer above it ends with them. - ipv6_reassembly took the fragment's data, and so its tl, with the frame's trailer on the end: an 80-octet datagram reassembled to 84 octets. - tcp_reassembly and tcp_traceflow did the same to the TCP payload, len and last. A segment now ends at the shortest end any enclosing IP layer declares, and is dropped, as the default engine drops it, when that holds under 20 octets or the Data Offset counts under 5. - Jumbograms use pcapkit's own Jumbo Payload Length, since Scapy misreads it and splits nothing off. - ipv4_reassembly is unchanged: it hands the trailer on as the default engine's adapter does, and the reassembler cuts at tl - ihl. Tests: the adapters match the default engine on every frame tested, and each new test fails without its fix.
JarryShaw
force-pushed
the
fix/1584-scapy-ipv6-trailer
branch
from
October 10, 2026 07:18
051defa to
4ce6ee3
Compare
4 of 13 tasks
Owner
Author
|
Verdict: GOOD TO GO at
Unchanged from |
3 of 13 tasks
3 of 13 tasks
JarryShaw
added a commit
that referenced
this pull request
Oct 14, 2026
Third-party engines are best effort (#1687), so the scapy code that exists only to match the default engine comes out: - revert #1683, #1663, #1652 and #1631, and the scapy hunks of #1614: the link-type and loopback-family walk, the frame and extension-header bounds, the IPv6 chain walk over the octets, the stops at GRE, VXLAN, PPPoE and the other layers the default engine leaves raw and at ICMP quotes, and the IPv4 header checks - keep #1624's walk (TCP behind AH or an IPv6 extension header in IPv4, and the later-fragment stop), #1605's keying by the carrying IP header and #1589's trailer cut; the walk calls _walk_extension_headers, which the pypcapfile revert keeps - re-land as guards: a zero-length frame is no IPv4 input and has no packet2dict octets (#1676); IPv4 in IPv6 ends at the Payload Length (#1623); a packet built by hand is read off its octets (#1676); ipv6_reassembly takes only its own IPv6 layer's Fragment header, and none in a later IPv4 fragment - delete the four scapy agreement modules and test_scapy_unit's default-engine checks; the guards' tests assert constants - docs: scapy applies the extension-header bound only behind IPv4 and the frame-layer bound nowhere, and its silent gaps are listed where gaps are said to be announced The scapy toolkit and engine modules, the shared modules that run scapy, and the project and tier guards pass on 3.14 (scapy 2.7.0) and 3.11 (scapy 2.8.0).
JarryShaw
added a commit
that referenced
this pull request
Oct 14, 2026
Third-party engines are best effort (#1687), so the scapy code that exists only to match the default engine comes out: - revert #1683, #1663, #1652 and #1631, and the scapy hunks of #1614: the link-type and loopback-family walk, the frame and extension-header bounds, the IPv6 chain walk over the octets, the stops at GRE, VXLAN, PPPoE and the other layers the default engine leaves raw and at ICMP quotes, and the IPv4 header checks - keep #1624's walk (TCP behind AH or an IPv6 extension header in IPv4, and the later-fragment stop), #1605's keying by the carrying IP header and #1589's trailer cut; the walk calls _walk_extension_headers, which the pypcapfile revert keeps - re-land as guards: a zero-length frame is no IPv4 input and has no packet2dict octets (#1676); IPv4 in IPv6 ends at the Payload Length (#1623); a packet built by hand is read off its octets (#1676); ipv6_reassembly takes only its own IPv6 layer's Fragment header, and none in a later IPv4 fragment - delete the four scapy agreement modules and test_scapy_unit's default-engine checks; the guards' tests assert constants - docs: scapy applies the extension-header bound only behind IPv4 and the frame-layer bound nowhere, and its silent gaps are listed where gaps are said to be announced The scapy toolkit and engine modules, the shared modules that run scapy, and the project and tier guards pass on 3.14 (scapy 2.7.0) and 3.11 (scapy 2.8.0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
Closes #1584.
Scapy files the octets past an IP layer's declared length as a
Paddinglayer, andbytes()of every layer above it ends with them.pcapkit/toolkit/scapy.pytook payloads withbytes(layer.payload), so:ipv6_reassembly): fragment data andtlincluded the trailer. The 80-octet datagram from the issue came back 84 octets.tcp_reassembly,tcp_traceflow): the payload,lenandlastincluded Ethernet padding and trailers. A padded 60-octet frame holding a 1-octet segment gave 6 octets._within_datagrams()cuts at the default engine's boundaries:jumbo_payload_length, because Scapy misreads that field.A TCP segment gives no record when its datagrams hold fewer than 20 octets of it, or its Data Offset is under 5, as on the default engine.
IPv4 reassembly is unchanged. Its adapter hands the trailer on just as the default engine's adapter does, and
foundation/reassembly/ip.pycuts attl - ihl.Tests (
tests/toolkit/test_scapy_unit.py::ScapyTrailerTests): the adapters match the default engine field for field, with the expected values pinned. Each new test fails without its fix.test_data_with_no_length_to_stop_at_is_taken_wholefails onmainonly because the helper it calls does not exist there. Coverage oftoolkit/scapy.pywent from 98% to 99%. I ran narrow selections only, notmake test.