Skip to content

tls.c: send missing_extension alert on TLS 1.3 SNI absence#10332

Open
jackctj117 wants to merge 1 commit intowolfSSL:masterfrom
jackctj117:SNI
Open

tls.c: send missing_extension alert on TLS 1.3 SNI absence#10332
jackctj117 wants to merge 1 commit intowolfSSL:masterfrom
jackctj117:SNI

Conversation

@jackctj117
Copy link
Copy Markdown
Contributor

This pull request updates the alert handling logic in the TLSX_SNI_VerifyParse function to improve compliance with TLS 1.3 requirements. Specifically, it changes the type of alert sent when the SNI (Server Name Indication) extension is absent or does not match, sending a missing_extension alert for TLS 1.3 and above, while maintaining the previous behavior for earlier versions.

Alert handling improvements for TLS 1.3:

  • Updated TLSX_SNI_VerifyParse in src/tls.c to send a missing_extension alert instead of handshake_failure when the SNI extension is missing or has no match, but only for TLS 1.3 and above. For earlier versions, the function still sends handshake_failure. [1] [2]

@jackctj117 jackctj117 self-assigned this Apr 27, 2026
Copilot AI review requested due to automatic review settings April 27, 2026 21:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adjusts TLS alert behavior in TLSX_SNI_VerifyParse to better align with TLS 1.3 expectations by sending a different fatal alert when SNI is missing or doesn’t match.

Changes:

  • For TLS 1.3+, send missing_extension instead of handshake_failure when SNI is absent.
  • For TLS 1.3+, also send missing_extension instead of handshake_failure when SNI has NO_MATCH.
  • Preserve handshake_failure behavior for pre–TLS 1.3.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tls.c
Comment on lines +2612 to +2615
SendAlert(ssl, alert_fatal,
IsAtLeastTLSv1_3(ssl->version)
? missing_extension
: handshake_failure);
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

missing_extension is intended for cases where a required extension is absent. In this branch, the SNI extension appears to be present but has WOLFSSL_SNI_NO_MATCH, so missing_extension is likely the wrong alert for TLS 1.3+. Consider using an alert that reflects 'name not recognized' (commonly unrecognized_name per RFC 6066) for the NO_MATCH case, and reserve missing_extension for the truly-absent-extension branch.

Copilot uses AI. Check for mistakes.
Comment thread src/tls.c
Comment on lines +2598 to +2601
SendAlert(ssl, alert_fatal,
IsAtLeastTLSv1_3(ssl->version)
? missing_extension
: handshake_failure);
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The TLS-version-dependent alert selection logic is duplicated across both error branches. To reduce repetition and keep future protocol tweaks consistent, consider computing the chosen alert once (e.g., a local int alert = ...) and reusing it in both places, or extracting a small helper for 'SNI required' alert selection.

Copilot uses AI. Check for mistakes.
Comment thread src/tls.c
Comment on lines +2612 to +2615
SendAlert(ssl, alert_fatal,
IsAtLeastTLSv1_3(ssl->version)
? missing_extension
: handshake_failure);
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The TLS-version-dependent alert selection logic is duplicated across both error branches. To reduce repetition and keep future protocol tweaks consistent, consider computing the chosen alert once (e.g., a local int alert = ...) and reusing it in both places, or extracting a small helper for 'SNI required' alert selection.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10332

Scan targets checked: wolfssl-bugs, wolfssl-src

No new issues found in the changed files. ✅

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.

3 participants