Skip to content

Fix issues in TLS Extension size calculations#9824

Merged
JacobBarthelmeh merged 4 commits intowolfSSL:masterfrom
embhorn:zd21239
Feb 26, 2026
Merged

Fix issues in TLS Extension size calculations#9824
JacobBarthelmeh merged 4 commits intowolfSSL:masterfrom
embhorn:zd21239

Conversation

@embhorn
Copy link
Member

@embhorn embhorn commented Feb 24, 2026

Description

Three GetSize functions in src/tls.c use word16 (16-bit) variables to accumulate extension sizes in loops. With enough extensions, the value wraps past 65535 back to a small number, causing under-allocation of buffers.

Fix applied to all three functions:

  • TLSX_SNI_GetSize()
  • TLSX_CSR_GetSize_ex()
  • TLSX_CSR2_GetSize()

Fixes zd21239

Testing

Added test case test_TLSX_SNI_GetSize_overflow

Checklist

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

Credit for finding issue to:

Muhammad Arya Arjuna (pelioro)

@embhorn embhorn self-assigned this Feb 24, 2026
Copilot AI review requested due to automatic review settings February 24, 2026 14:39
Copy link
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

This PR fixes integer overflow vulnerabilities in TLS extension size calculations that could lead to buffer under-allocation. Three functions were using 16-bit variables to accumulate extension sizes, which could wrap past 65,535 and return incorrectly small values.

Changes:

  • Changed size accumulation variables from word16 to word32 in three GetSize functions
  • Added overflow detection that returns 0 when sizes exceed WOLFSSL_MAX_16BIT
  • Added test case test_TLSX_SNI_GetSize_overflow to verify the fix

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/tls.c Fixed integer overflow in TLSX_SNI_GetSize(), TLSX_CSR_GetSize_ex(), and TLSX_CSR2_GetSize() by changing accumulator types to word32 and adding overflow checks
tests/api/test_tls_ext.c Added comprehensive test that creates overflow conditions and verifies both the fix and that the old implementation was vulnerable
tests/api/test_tls_ext.h Added declaration for new overflow test function
tests/api.c Registered new test case in test suite

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

Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


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

Copilot AI review requested due to automatic review settings February 24, 2026 17:19
Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


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

@embhorn
Copy link
Member Author

embhorn commented Feb 25, 2026

Jenkins retest this please

@embhorn embhorn assigned wolfSSL-Bot and unassigned embhorn Feb 25, 2026
Copilot AI review requested due to automatic review settings February 25, 2026 22:43
Copy link
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


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

Copilot AI review requested due to automatic review settings February 26, 2026 14:40
Copy link
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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


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

Copilot AI review requested due to automatic review settings February 26, 2026 16:46
Copy link
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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


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

@JacobBarthelmeh JacobBarthelmeh merged commit 85228f0 into wolfSSL:master Feb 26, 2026
444 checks passed
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