sessions: bound missing ranges in TCP reassembly - #5112
Merged
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 #5112 +/- ##
==========================================
- Coverage 80.59% 80.09% -0.51%
==========================================
Files 390 390
Lines 96892 96905 +13
==========================================
- Hits 78094 77612 -482
- Misses 18798 19293 +495
🚀 New features to boost your workflow:
|
gpotter2
reviewed
Aug 26, 2026
Adds max_gap=MTU to the constructor and warns when data is dropped. AI-Assisted: yes (GPT-5.6-Cyber)
Contributor
Author
|
Both done in
Added two tests: one that a custom |
Member
|
Thanks for the PR |
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.
TCPSessionstores stream data at offsets derived from TCP sequence numbers. One far-ahead bytecauses
StringBuffer.append()to allocate a zero-filled gap atscapy/sessions.py:105-124,then every retransmission materializes and checks the attacker-sized buffer at
scapy/sessions.py:354-364.From 128 to 1,024 updates, median capture processing grew from 14.69 ms to 551.49 ms, with a 1.91
exponent and a 4.0% noise floor. Patched times were 7.10 ms to 56.05 ms, with a 1.00 exponent and a
4.8% noise floor. Valid contiguous append changed by -1.3%, within a 3.0% noise floor.
This change ignores missing ranges larger than Scapy's 65,535-byte receive limit. The focused
boundary regression failed on the unmodified revision and passed with the patch.