Skip to content

write-dup: copy the PHA transcript to the read side from FINISHED_DONE - #12027

Open
yosuke-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/write-dup
Open

yosuke-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/write-dup

Conversation

@yosuke-wolfssl

Copy link
Copy Markdown
Contributor

Problem

With wolfSSL_write_dup(), the write side answers a TLS 1.3 post-handshake CertificateRequest and then copies its transcript to the read side. The read side hashes the next CertificateRequest onto that copy.

The copy was made in wolfssl_write_dup_do_tls13_work() only when wolfSSL_connect_TLSv13() sent the whole response in one call. If the response hit WANT_WRITE or WC_PENDING_E and finished on a later wolfSSL_write(), no copy was made. The next PHA round was then hashed onto the old transcript, so the client's CertificateVerify/Finished did not match the server's, and every later PHA round on the connection failed.

Fix (src/tls13.c)

  • postHandshakeAuthPublish is set by wolfssl_write_dup_do_tls13_work() when it starts a PHA response.
  • Tls13WriteDupPublishPhaHashes() copies the transcript into dupWrite->postHandshakeSyncedHashState in wolfSSL_connect_TLSv13()'s FINISHED_DONE state while that bit is set.

Tests

  • test_write_dup and test_write_dup_want_write run a second PHA round. The want_write case covers a first response that blocked.
  • New test_write_dup_negotiate_pha calls wolfSSL_negotiate() on the write side before and after a PHA round and checks that no copy is made.

Verification

  • --enable-all --enable-writedup --enable-asynccrypt --enable-asynccrypt-sw: builds clean, and all three tests pass over TLS 1.3 and DTLS 1.3.
  • With the new tests on master's library code, test_write_dup_want_write fails on its second PHA round. The other two tests still pass there, so the second round of test_write_dup_want_write is the one that catches this bug.

- wolfSSL_connect_TLSv13() copies the write side's transcript into
  postHandshakeSyncedHashState in FINISHED_DONE when the new
  postHandshakeAuthPublish bit is set, via
  Tls13WriteDupPublishPhaHashes().
- wolfssl_write_dup_do_tls13_work() sets postHandshakeAuthPublish
  when it starts a PHA response, and no longer copies the
  transcript itself.
- test_write_dup and test_write_dup_want_write run a second PHA
  round.
- New test_write_dup_negotiate_pha calls wolfSSL_negotiate() on the
  write side before and after a PHA round.
@yosuke-wolfssl yosuke-wolfssl self-assigned this Nov 5, 2026
Copilot AI balanced review requested due to automatic review settings November 5, 2026 23:51

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

No active review issues are reported for the TLS 1.3 post-handshake authentication transcript synchronization change.

No open issues 🎉

What changed in this PR

This PR fixes transcript synchronization for TLS 1.3 post-handshake authentication with wolfSSL_write_dup() when a response completes across multiple calls, preventing later authentication rounds from using a stale transcript.

Changes:

  • Moves transcript publication to FINISHED_DONE, guarded by a flag set when a post-handshake authentication response starts.
  • Adds second-round regression coverage and verifies that unrelated wolfSSL_negotiate() calls do not publish a transcript.
File Description
wolfssl/​internal.h Adds the pending transcript-publication flag.
tests/​api.c Extends repeated-authentication tests and adds negotiation isolation coverage.
src/​tls13.c Publishes the transcript at handshake completion, including resumed responses.
src/​ssl_api_rw.c Sets the publication flag and removes the single-call publication path.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

@yosuke-wolfssl

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude 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.

Code review found no issues

No high-confidence issues detected in this change.

@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 #12027

Scan targets checked: wolfssl-src, wolfssl-bugs
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

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.

4 participants