Add negative-count and NULL checks to group-setting and shared-cipher APIs#10249
Merged
Conversation
|
ColtonWilley
force-pushed
the
pr15-tls-config-bounds
branch
from
May 5, 2026 18:57
d789341 to
9a47ef3
Compare
ColtonWilley
force-pushed
the
pr15-tls-config-bounds
branch
from
May 27, 2026 18:43
b59b177 to
de79d60
Compare
ColtonWilley
marked this pull request as ready for review
May 27, 2026 21:56
|
retest this please |
…d cipher APIs Add count < 0 validation to wolfSSL_CTX_set_groups and wolfSSL_set_groups (src/tls.c) to prevent negative count from bypassing the upper-bound check and corrupting numGroups via byte truncation. Widen count == 0 to count <= 0 and add NULL groups check in wolfSSL_CTX_set1_groups and wolfSSL_set1_groups (src/ssl.c). Add NULL buf and NULL cipher checks in wolfSSL_get_shared_ciphers to prevent NULL pointer dereference.
Extend test_tls13_apis with negative-count assertions for wolfSSL_CTX_set_groups and wolfSSL_set_groups, and NULL-groups assertions for wolfSSL_CTX_set1_groups and wolfSSL_set1_groups (tests/api/test_tls13.c). Add test_wolfSSL_get_shared_ciphers covering NULL ssl, NULL buf, and zero-length inputs (tests/api/test_tls.c).
ColtonWilley
force-pushed
the
pr15-tls-config-bounds
branch
from
June 8, 2026 20:06
de79d60 to
6211210
Compare
dgarske
requested changes
Jun 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens several public-facing TLS APIs against invalid inputs (negative group counts and NULL pointers) to prevent misbehavior such as out-of-bounds reads, and adds regression tests to lock in the corrected behavior.
Changes:
- Add input validation for negative counts / NULL pointers in group-setting and shared-cipher APIs.
- Add TLS 1.3 API tests for negative group counts and NULL group lists.
- Add an API test covering
wolfSSL_get_shared_ciphers()NULL/zero-length handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/api/test_tls13.c | Adds TLS 1.3 regression coverage for negative group counts and NULL group pointer cases. |
| tests/api/test_tls.h | Registers the new shared-ciphers API test in the TLS test list. |
| tests/api/test_tls.c | Implements test_wolfSSL_get_shared_ciphers() to validate NULL/zero-length handling and behavior with/without error strings. |
| src/ssl.c | Adds NULL checks for wolfSSL_get_shared_ciphers() and strengthens argument validation for *_set1_groups() APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dgarske
approved these changes
Jun 8, 2026
dgarske
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wolfSSL_CTX_set_groups/wolfSSL_set_groups: addcount < 0toentry guard — negative count passes the upper-bound check and truncates
to a garbage
numGroupsbyte, causing OOB read during SSL initwolfSSL_CTX_set1_groups/wolfSSL_set1_groups: widencount == 0to
count <= 0and add NULLgroupscheckwolfSSL_get_shared_ciphers: add NULL checks forbufandwolfSSL_get_cipher_name_ianareturn value