Repository navigation
fix(pcapng): warn on a malformed TLS key-log line instead of aborting (#1985) - #1989
Conversation
…#1985) A TLS or WireGuard key log line that did not parse raised FieldValueError from post_process, which aborted the whole extraction, wherever the line sat in the log. It now raises a ProtocolWarning ("...; line kept as captured"), is left out of the entries, and the well-formed entries around it are kept. The log text is already kept verbatim on the data model, so the block still rebuilds octet for octet. A last line the capture or the block cut is still left out silently, as #1983 does. Tests that pinned the old refusal now pin the warning. Closes #1985
|
NEEDS CHANGES at
Question for you: the warning quotes the whole malformed line, so it can include a TLS secret or a WireGuard private key. |
…1985) TLSKeyLog.post_process indexed entries[label] before bytes.fromhex ran, so a line with a known label but fields that do not decode left an empty bucket for that label. Both values are decoded first and entries is touched only once they are. WireGuardKeyLog decodes before it adds, so it needs no change. Also drops timed wording from the test docstrings and rewraps the post_process docstring. Refs #1985
|
Pushed |
|
the warning name only the label, with the values elided |
|
The code at |
) The malformed-line warning quoted the whole key-log line, which carries key material. _malformed_line_message names only the label, when the key log knows it, and elides the values. An unrecognised label is not quoted either, since it may be key material too. The WireGuard parser's internal ValueError no longer carries the line. Tests assert the new text and that no warning quotes a hex secret or base64 key from their input. Refs #1985
|
Pushed
The tests assert the exact text, and that no warning contains the secrets from their inputs. A delta review is running. |
|
GOOD TO GO at |
|
Coverage: 91.53% (unit tier, Python 3.15,
Per-file detail: the |
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— a bug fixDescription of your pull request and other information
A malformed line in a Decryption Secrets Block's key log no longer aborts
extract.TLSKeyLog.post_processandWireGuardKeyLog.post_processnow handle a line that does not parse, wherever it sits, the same way:ProtocolWarning: "invalid TLS key log format: '…'; line kept as captured".entries, and the valid entries and every frame are kept.A line cut by the capture is still dropped silently, as in #1983. A cut last line that still fits inside the pad now gets this warning instead of raising.
Three existing tests that asserted the old
FieldValueErrornow assert the warning. The newtest_pcapng_tls_keylog_malformed_1985_unit.pyfails onmain(19 failed) and passes here.Not covered: a WireGuard secret with invalid base64 still parses silently, because
b64decodedrops the bad characters.Closes #1985