Skip to content

Zeroize TLS 1.3 key schedule secrets at their last use - #11407

Open
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:tls13-zeroization-fixes
Open

Zeroize TLS 1.3 key schedule secrets at their last use#11407
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:tls13-zeroization-fixes

Conversation

@gasbytes

@gasbytes gasbytes commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@gasbytes gasbytes self-assigned this Sep 9, 2026
Copilot AI lite review requested due to automatic review settings September 9, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 of DeriveHandshakeSecret() when derivation succeeds.
  • Wipe the entire preMasterSecret buffer (ENCRYPT_LEN) at the last use sites (after deriving the master secret), since preMasterSz may 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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +64 B (+0.0%, 783,844 B / 1,048,576 B, total: 75% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +64 B (+0.0%, 302,152 B / 1,048,576 B, total: 29% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +64 B (+0.0%, 303,112 B / 1,048,576 B, total: 29% used)

gcc-arm-cortex-m7-tls13

@philljj philljj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge conflict in tests/

@gasbytes
gasbytes force-pushed the tls13-zeroization-fixes branch from 4f4330b to 855f23c Compare September 9, 2026 16:19
@gasbytes
gasbytes requested a review from philljj September 9, 2026 16:19
@gasbytes gasbytes assigned philljj and unassigned gasbytes Sep 9, 2026
@gasbytes gasbytes assigned gasbytes and unassigned wolfSSL-Bot and philljj Sep 10, 2026
@gasbytes
gasbytes force-pushed the tls13-zeroization-fixes branch from 855f23c to ea87829 Compare September 10, 2026 11:33
- 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
@gasbytes
gasbytes force-pushed the tls13-zeroization-fixes branch from ea87829 to 11fe5fb Compare September 10, 2026 11:35
@gasbytes gasbytes assigned wolfSSL-Bot and philljj and unassigned gasbytes Sep 10, 2026
@philljj philljj removed their assignment Sep 11, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #11407

⚠️ An internal error occurred during the automated review. This error has been logged. Please contact the Fenrir team if you need assistance.

Error: CalledProcessError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants