Repository navigation
toolkit(scapy): scale IPv4 fragment offset to octets before reassembly #484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking suggestion: this test proves the payload-corruption half of #483's defect (the wrong bytes at the wrong offset), but it doesn't check the other symptom that the same corruption would have produced through #482's new
conflictmachinery.I traced
IP.reassembly()/IP._detect_conflicts()inpcapkit/foundation/reassembly/ip.py(unchanged by this PR) against this exact fixture under the pre-fix, unscaledfo:fo=0, 40-octet payload) setsRCVBTbits for blocks 0-4 (FO // 8throughFO // 8 + (TL - IHL + 7) // 8= 0..5) and writesdatagram[0:40] = b'A' * 40.fo=5instead of the correct40, writes atdatagram[5:13]._detect_conflictsruns before that write, over[5, 13): every one of those positions falls in an already-RCVBT-set block (0 and 1, both fully claimed by fragment 1), andtdlis still-1at that point (fragment 2's ownMF=0update happens after), so thetdl < 0branch of the guard is satisfied everywhere.datagram[pos]is'A'andpayload[index]is'B'for the whole span, so this reports a single conflicting run, i.e.conflict == ((5, 12),)-- a spurious conflict manufactured entirely by the unscaled offset, on data that never actually overlapped on the wire.So a fix that scaled
focorrectly but left some other consumer of the raw value unscaled would still be caught by the existing payload-bytes assertion, but a regression that reintroduced the offset bug would show up two ways: corrupted payload bytes and a non-emptyconflicttuple on otherwise non-overlapping fragments. Since this is precisely the interaction #482 and #483 have with each other, assertingself.assertEqual(datagram.conflict, ())alongside the existing payload assertion would pin that down directly rather than leaving it to be inferred from the payload check.Not asking for a change before merge -- the existing assertions already conclusively demonstrate the fix works -- just flagging the gap since it's exactly the interaction worth covering here.