Repository navigation
fix(engines): read each record whole through the scapy engine (#1717) - #1733
Merged
Merged
Conversation
- sniff() reads with recv(), whose size defaults to Scapy's MTU of 65,535
octets, and every Scapy reader cuts a record to size: the engine's
readers default recv() to 0xFFFFFFFF, the most a 32-bit captured length
counts, for PCAP and PCAP-NG alike; an explicit size is still passed on
- Scapy 2.6 reads each PCAP-NG block at MTU whatever the size: the
_read_block() override defaults to the same 0xFFFFFFFF
- Scapy 2.8's PCAP reader reads at most MTU * 4 (262,140) octets of a
record and skips the rest: the PCAP reader reads the record itself, in
256 KiB chunks so a forged captured length still costs only the octets
the file holds, from a RawPcapReader base after PcapReader, where
PcapReader.read_packet's super(PcapReader, self) looks
Tests: test_scapy_record_length_1717_{unit,runtime}.py, 5 passed on scapy
2.6.0, 2.7.0 and 2.8.0; 9 of the 11 fail on each against origin/main.
Closes #1717
Owner
Author
|
Verdict: GOOD TO GO at
|
Contributor
|
Coverage: 89.61% (unit tier, Python 3.15,
Per-file detail: the |
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 change. Narrow runs only, listed below.Added 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 #1717. The scapy engine cut any record longer than 65,535 octets. Behind that cap sit two more, which each scapy version hits in a different mix:
sniff()reads withrecv(), whosesizedefaults toMTU(0xffff), and every reader slices to itrecv()defaults to0xFFFFFFFF, the most a 32-bit captured length can countMTU_read_block()override defaults to the sameMTU * 4(262,140) octets of a recordReading in chunks means a forged captured length costs only the octets the file actually holds.
Tests:
options-ipv6.pcap(65,590 octets). They pass on scapy 2.6.0, 2.7.0 and 2.8.0, and 9 of the 11 checks fail onmainon each.