Curation pass: fix real-world TLS 1.2 decryption + clippy + honest status
Summary
A curation + fix-up pass on netgrep after ~4 months cold, so it holds up if someone reads or runs it. The audit turned into a real bug hunt.
The headline: netgrep could not decrypt real-world TLS 1.2 traffic at all. It read the negotiated TLS version from the ClientHello's supported_versions (the client's offer), but every modern client advertises 1.3 there even when the server negotiates down to 1.2. netgrep locked onto 1.3, looked up empty 1.3 secrets for a session whose keylog held a 1.2 master secret, and silently decrypted nothing. Since essentially all real 1.2 sessions come from clients that also offer 1.3, the "TLS 1.2 decryption — tested" claim held for hand-built vectors and broke on the wire. The synthetic 1.2 test missed it because its ClientHello carried no supported_versions extension.
Changes
- fix(tls): negotiate the session version from the ServerHello (the server's choice), not the ClientHello's offer. Adds a regression unit test for the negotiation.
- test(tls): end-to-end decryption tests against real captured TLS 1.2 and 1.3 sessions (checked-in fixtures +
tests/fixtures/generate.sh), with a negative control proving the marker is genuinely encrypted. - chore: fix clippy lints that newer stable tightened since the Feb commit — restores a clean
clippy -D warningson current stable. - docs: honest "Status & provenance" section in the README (AI-assisted portfolio demo, what's live-verified vs vector-tested, unmaintained/no-SLA).
Verification
cargo build --release,cargo fmt --check,cargo clippy --all-targets -- -D warningsall clean on rustc 1.94.1.cargo test: 378 pass (was 374; +1 regression unit test, +3 e2e).- Live proof: the original failing TLS 1.2 capture (client offered 1.3, server chose 1.2) went
0 matches→1 match; TLS 1.3 unaffected.
Test plan
cargo test --test tls_e2edecrypts both fixtures and confirms the negative control.- To regenerate the fixtures:
sudo -v && tests/fixtures/generate.sh.
Summary by Sourcery
Fix TLS session version negotiation and add real-world TLS decryption coverage while refreshing docs and lint compliance.
Bug Fixes:
- Correct TLS session version negotiation to derive the negotiated protocol from the ServerHello instead of the ClientHello offer, fixing real-world TLS 1.2 decryption failures.
Enhancements:
- Tighten handshake parsing logic so retransmitted ServerHellos do not clobber an already-determined session version.
- Refresh code to satisfy newer clippy lints and simplify a few test helpers and loops without changing behavior.
Documentation:
- Document the project’s status, provenance, and support expectations in the README, including which paths are live-verified versus vector-tested.
Tests:
- Add regression and end-to-end tests that run the built binary against captured TLS 1.2 and 1.3 sessions using SSL key logs to verify full decryption, including a negative control to ensure markers are actually encrypted.
- Introduce a fixture generation script that captures fresh TLS sessions and their key logs in a reproducible way for the TLS E2E tests.
Chores:
- Add committed TLS keylog fixtures for local test captures to support TLS E2E testing.
Summary by cubic
Fix TLS 1.2 decryption by negotiating the version from ServerHello and harden live TLS decryption with safe keylog refresh, per-direction key installs, and correct epoch/sequence handling. Keep the code clippy-clean on stable Rust 1.97.
-
Bug Fixes
- Negotiate TLS version from ServerHello to fix real 1.2 sessions misclassified as 1.3.
- Correct TLS 1.3 app-epoch detection using handshake-complete; derive keys per-direction only before that direction’s app data starts; warn once if secrets arrive too late; count TLS 1.2 Finished as sequence-consuming to keep AEAD counters aligned.
- Re-read
SSLKEYLOGFILEon growth and merge later TLS 1.3 application secrets into partial entries; tolerate a missing file at startup; only accept re-reads at least as large as the current cache; suppress future re-reads only for a persistently oversized file (transient read errors no longer lock out refreshes).
-
Chores
- Restore a clean
cargo clippy -- -D warningson stable Rust 1.97 with minor HTTP/TUI formatting fixes.
- Restore a clean
Summary by CodeRabbit
- Bug Fixes
- Corrected TLS version negotiation to follow the server’s negotiated result.
- Hardened TLS decryption when key-log secrets arrive late, reducing missed/incorrect decryption due to AEAD sequencing.
- Tests
- Added end-to-end TLS decryption coverage for TLS 1.2 and TLS 1.3 using key-log fixtures, with negative controls.
- Updated stress tests and refreshed/regenerated TLS fixture data.
- Documentation
- Added README “Status & provenance” guidance and maintenance expectations.
- Chores
- Added a script to regenerate TLS decryption fixtures and updated ignore rules to track fixture pcaps.