Skip to content

Ensure that a resumed session properly handles client auth. Clear session ticket resumption state in wolfSSL_clear. - #11600

Merged
philljj merged 11 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd22516
Oct 29, 2026
Merged

philljj merged 11 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd22516

Conversation

@kareem-wolfssl

@kareem-wolfssl kareem-wolfssl commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes F-14714, partially fixes zd#22516

Testing

Built in tests, provided reproducers, added tests

Checklist

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m3

  • FLASH: .text +140 B (+0.1%, 130,909 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4

  • FLASH: .text +384 B (+0.2%, 210,332 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +256 B (+0.1%, 194,584 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +576 B (+0.1%, 796,780 B / 1,048,576 B, total: 76% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +512 B (+0.2%, 312,228 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +448 B (+0.1%, 343,576 B / 1,048,576 B, total: 33% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +128 B (+0.1%, 131,665 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +512 B (+0.2%, 249,742 B / 262,144 B, total: 95% used)

gcc-arm-cortex-m7

  • FLASH: .text +384 B (+0.2%, 210,332 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +448 B (+0.1%, 313,124 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +512 B (+0.2%, 249,806 B / 262,144 B, total: 95% used)

zephyr-frdm_rw612

  • FLASH: log_const_area -8 B, rodata -8 B, text +48 B (+0.0%, 282,496 B / 67,108,864 B, total: 0% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

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.

Copilot review overview

🟡 Changes recommended

The changes introduce an optional-build compilation failure, a callback-backed authentication bypass, and an unversioned persisted-cache layout change.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Adds client-authentication awareness to resumed sessions and clears stale ticket state during wolfSSL_clear().

Changes:

  • Persists client-auth status in sessions and tickets.
  • Rejects resumptions that cannot satisfy mandatory client authentication.
  • Adds TLS 1.2 resumption and reset tests.
File Description
wolfssl/​internal.h Adds ticket flags and session authentication state.
src/​internal.c Enforces client authentication during TLS 1.2 resumption.
src/​tls13.c Enforces authentication for TLS 1.3 ticket PSKs.
src/​ssl.c Clears stale ticket and alternate-session state.
src/​ssl_sess.c Serializes and populates authentication state.
tests/​api/​test_tls.c Adds TLS 1.2 resumption and reuse tests.
tests/​api/​test_tls.h Registers new TLS tests.
tests/​api.c Tests session serialization compatibility.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/internal.c Resolved
Comment thread src/internal.c Resolved
Comment thread wolfssl/internal.h Resolved
Comment thread src/tls13.c Resolved

@julek-wolfssl julek-wolfssl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks correct but the comments are getting too verbose. Cut them down.

@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, and a nit.

also, see Fenrir item

Comment thread src/ssl_sess.c Resolved
Comment thread wolfssl/ssl_sess.h Resolved

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

Scan targets checked: wolfssl-src, wolfssl-bugs
Coverage: 5 of 8 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c, tests/api/test_tls.c, wolfssl/ssl_sess.h

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/internal.c Resolved
@kareem-wolfssl

Copy link
Copy Markdown
Contributor Author

Retest this please

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

Scan targets checked: wolfssl-src, wolfssl-bugs
Coverage: 5 of 7 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c, tests/api/test_tls.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/ssl_sess.c Resolved
@philljj
philljj requested a review from julek-wolfssl October 9, 2026 18:29

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

Scan targets checked: wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_tls.h
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_tls.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/tls13.c Resolved
Comment thread wolfssl/internal.h Resolved
Comment thread wolfssl/internal.h Resolved
Comment thread wolfssl/internal.h Resolved
Comment thread wolfssl/internal.h Resolved
Comment thread src/ssl_sess.c Resolved
Comment thread src/tls13.c Resolved
Comment thread src/tls13.c Resolved
Comment thread src/internal.c Resolved
Comment thread src/tls13.c Resolved
Comment thread wolfssl/internal.h Resolved
Reset useTicket and createTicket, the server's alternate session id, and
the per-connection alert count, empty record count, fragment offset and
message building state, so a reused object starts the next handshake
clean. DoClientHello resets the ticket flags itself, except during secure
renegotiation, where the hello inherits the connection's.

Thanks to ByteRay Ltd for the report.
Record in the session and in the ticket whether the client presented a
certificate and proved possession of its key, and do a full handshake
instead of resuming (session id, ticket, session secret callback and
TLS 1.3 PSK) when the policy requires a client certificate the session
never had. Every site deciding that policy uses ClientAuthRequired(),
which covers mutual auth without verifyPeer and the PSK exception of
WOLFSSL_VERIFY_FAIL_EXCEPT_PSK. The TLS 1.3 post-handshake exemption
stays with the callers that defer. wolfSSL_mutual_auth() sets the verify
mode so the certificate is asked for, and FAIL_IF_NO_PEER_CERT and
FAIL_EXCEPT_PSK imply VERIFY_PEER. The i2d/d2i session encoding carries
the new flag and d2i requires the full length.

Thanks to ByteRay Ltd for the report.
Fix peerAuthOK logic around resumption and PHA.
Fix PSK determination logic.
Ensure PSK/anon suite options are fully reset between connections and in wolfSSL_clear.
Don't set failNoCert in _mutual_auth functions as it is redundant and wouldn't get reset on clear.
Add tests.
…east one reference, otherwise clear the session.

Use isPsk to determine PSK status rather than verifyPeer.
Add tests.
…ntAuthRequired should only check if the ticket was authenticated for this case.
Add isPsk to the session for TLS 1.3, as it has no other way of knowing if a session ticket is PSK.
Refactor to always build ClientAuthRequired function.
Search for CERT_WITH_EXTERN_PSK extension from the peer rather than relying on certWithExternPsk option.
Add tests.
Gate WOLFSSL_SESSION members on !NO_WOLFSSL_SERVER.
@philljj

philljj commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

tests good with multi-test with gcc-c89, c89-clang-tidy, wolfssl-all, openssl-extra-coexist, tls13, dtls13, quic, etc scenarios.

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.

7 participants