Zeroize TLS 1.3 key schedule secrets at their last use - #11407
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The zeroization changes are consistent with buffer sizing/allocation in the codebase and are covered by targeted regression tests that validate the intended memory-clearing behavior.
Pull request overview
This PR hardens wolfSSL’s TLS 1.3 key schedule handling by ensuring sensitive key-schedule material is zeroized at its last use, preventing handshake/early secrets from lingering in buffers after in-place HKDF operations.
Changes:
- Zeroize the TLS 1.3 early secret (
arrays->secret) and the PSK buffer (arrays->psk_key) at the end ofDeriveHandshakeSecret()when derivation succeeds. - Wipe the entire
preMasterSecretbuffer (ENCRYPT_LEN) at the last use sites (after deriving the master secret), sincepreMasterSzmay no longer reflect what’s stored after in-place extract. - Add and register regression tests that confirm these buffers are fully cleared after a successful handshake in the relevant scenarios.
File summaries
| File | Description |
|---|---|
tests/api/test_tls13.h |
Registers new TLS 1.3 regression tests in the API test declaration list. |
tests/api/test_tls13.c |
Adds regression tests asserting preMasterSecret, secret, and psk_key buffers are zeroized after handshakes. |
src/tls13.c |
Implements zeroization of early secret/PSK after handshake secret derivation and wipes full preMasterSecret buffer at last use. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
philljj
left a comment
There was a problem hiding this comment.
merge conflict in tests/
4f4330b to
855f23c
Compare
855f23c to
ea87829
Compare
- wipe the whole preMasterSEcret buffer at the tls 1.3 handshake secret's last use as preMasterSz no longer describes its contents - zeroize the tls 1.3 early secret and teh psk it was extracted from at their last use in DeriveHandshakeSecret
ea87829 to
11fe5fb
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11407
Error: CalledProcessError
Description
Wipe the whole preMasterSecret buffer at the handshake secret's last use, since preMasterSz no longer describes its contents once the extract happens in place.
Zeroize the early secret and the PSK it was extracted from at the end of the DeriveHandshakeSecret.
Testing
Added regression tests for both fixes (test_tls13_hs_secret_zeroized_psk_ke, test_tls13_hs_secret_zeroized_sha384, test_tls13_early_secret_zeroized, test_tls13_psk_key_zeroized).
Checklist