inet6: parse only complete Routing Header addresses - #5142
Open
KernelClint wants to merge 2 commits into
Open
Conversation
AI-Assisted: yes (GPT-5.6-Cyber)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5142 +/- ##
=======================================
Coverage 80.63% 80.64%
=======================================
Files 390 390
Lines 96936 96936
=======================================
+ Hits 78168 78176 +8
+ Misses 18768 18760 -8
🚀 New features to boost your workflow:
|
AI-Assisted: yes (GPT-5.6-Cyber)
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.
An IPv6 Routing Header carries a list of addresses, and its
lenfield counts the header's size ineight-byte units. The generic form parses that list at
scapy/layers/inet6.py:997-1007:Addresses are sixteen bytes, so an odd
lendescribes a whole number of eight-byte units but onlyhalf an address. The field at
scapy/layers/inet6.py:252-271converts each chunk it is given intoan address, including a final incomplete one, and parsing raises partway through. The packet ends
as
IPv6followed by unparsed data, and anything reading the layer chain — abridge_and_sniff()transform, for instance — does not see the transport header that a conforming receiver does.
The change parses only the complete entries and keeps an odd trailing eight bytes as generic
routing data:
The extra field is conditional on an odd length, so even-length Routing Headers keep exactly the
representation and build output they have today. The length adjustment is updated to match so a
header built with trailing data round-trips.
The added regression parses an odd-length header and asserts it yields an empty address list, the
trailing data, and the transport header beneath it. With only the test, the IPv6 suite reports 522
passed and 1 failed; with the source change, 523 passed and 0 failed.
Performance was measured on one computer, before and after the fix: parsing a valid even-length
header took 6,777.1 ns before and 6,574.2 ns after. Repeat runs of this test moved by about 8%,
which is wide enough that only a large change would show — this is not one.