utils: restore TLS settings when a pcapng reader closes - #5137
Open
KernelClint wants to merge 1 commit into
Open
utils: restore TLS settings when a pcapng reader closes#5137KernelClint wants to merge 1 commit into
KernelClint wants to merge 1 commit into
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 #5137 +/- ##
=======================================
Coverage 80.63% 80.64%
=======================================
Files 390 390
Lines 96936 96944 +8
=======================================
+ Hits 78168 78180 +12
+ Misses 18768 18764 -4
🚀 New features to boost your workflow:
|
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.
When a pcapng capture carries a Decryption Secrets Block, Scapy loads the keys and switches on TLS
session processing so the encrypted traffic in that file can be read
(
scapy/utils.py:1994-2016).Both are process-global settings on
conf.Closing the reader restores neither.
rdpcap()closes it (scapy/utils.py:1303-1314), but theinherited close only closes the file. The keys and the enable flag outlive the capture that supplied
them, so a later unrelated capture is read with the first file's keys still installed. A
key-carrying capture with no packets in it, read first, was enough to make a second encrypted
capture decrypt.
The change remembers the previous values the first time a reader installs keys, and puts them back
when it closes:
Settings the operator configured themselves are preserved: only what this reader changed is undone.
Decryption within the capture that carries the keys is unaffected.
The added regression reads a key-carrying capture, closes it, and asserts
conf.tls_nss_keysandconf.tls_session_enableare back to what they were. Without the source change it fails.Performance was measured on one computer, before and after the fix: reading a capture took
1,668.8 ns before and 1,808.2 ns after. Repeat runs of this test moved by about 7%, which is wide
enough that only a large change would show — this is not one.