Skip to content

Add negative-count and NULL checks to group-setting and shared-cipher APIs#10249

Merged
dgarske merged 4 commits into
wolfSSL:masterfrom
ColtonWilley:pr15-tls-config-bounds
Jun 9, 2026
Merged

Add negative-count and NULL checks to group-setting and shared-cipher APIs#10249
dgarske merged 4 commits into
wolfSSL:masterfrom
ColtonWilley:pr15-tls-config-bounds

Conversation

@ColtonWilley

Copy link
Copy Markdown
Contributor
  • wolfSSL_CTX_set_groups / wolfSSL_set_groups: add count < 0 to
    entry guard — negative count passes the upper-bound check and truncates
    to a garbage numGroups byte, causing OOB read during SSL init
  • wolfSSL_CTX_set1_groups / wolfSSL_set1_groups: widen count == 0
    to count <= 0 and add NULL groups check
  • wolfSSL_get_shared_ciphers: add NULL checks for buf and
    wolfSSL_get_cipher_name_iana return value

@github-actions

github-actions Bot commented Apr 18, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m0plus

  • FLASH: .text +236 B (+0.4%, 63,467 B / 262,144 B, total: 24% used)

gcc-arm-cortex-m3

  • FLASH: .text +328 B (+0.3%, 121,233 B / 262,144 B, total: 46% used)

gcc-arm-cortex-m4

  • FLASH: .text +512 B (+0.3%, 198,702 B / 262,144 B, total: 76% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +256 B (+0.4%, 66,059 B / 262,144 B, total: 25% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .text +256 B (+0.1%, 173,550 B / 262,144 B, total: 66% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +256 B (+0.1%, 179,544 B / 1,048,576 B, total: 17% used)

gcc-arm-cortex-m4-min-ecc

  • FLASH: .text +256 B (+0.4%, 61,037 B / 262,144 B, total: 23% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +512 B (+0.1%, 766,188 B / 1,048,576 B, total: 73% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +256 B (+0.1%, 210,929 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +256 B (+0.1%, 277,144 B / 1,048,576 B, total: 26% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +512 B (+0.2%, 322,616 B / 1,048,576 B, total: 31% used)

gcc-arm-cortex-m4-sp-math

  • FLASH: .text +256 B (+0.4%, 61,037 B / 262,144 B, total: 23% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +320 B (+0.3%, 121,997 B / 262,144 B, total: 47% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +256 B (+0.1%, 234,400 B / 262,144 B, total: 89% used)

gcc-arm-cortex-m7

  • FLASH: .text +512 B (+0.3%, 198,702 B / 262,144 B, total: 76% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +256 B (+0.1%, 277,720 B / 1,048,576 B, total: 26% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +256 B (+0.1%, 234,464 B / 262,144 B, total: 89% used)

linuxkm-pie

  • Data: __patchable_function_entries +32 B (+0.1%, 24,208 B)

linuxkm-standard

  • Data: __patchable_function_entries +48 B (+0.1%, 45,920 B)
    No memory changes detected for:
  • stm32-sim-stm32h753

@ColtonWilley
ColtonWilley force-pushed the pr15-tls-config-bounds branch from d789341 to 9a47ef3 Compare May 5, 2026 18:57
@ColtonWilley
ColtonWilley force-pushed the pr15-tls-config-bounds branch from b59b177 to de79d60 Compare May 27, 2026 18:43
@ColtonWilley
ColtonWilley marked this pull request as ready for review May 27, 2026 21:56
@github-actions

Copy link
Copy Markdown

retest this please

@ColtonWilley
ColtonWilley requested a review from wolfSSL-Bot June 5, 2026 16:52
…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
ColtonWilley force-pushed the pr15-tls-config-bounds branch from de79d60 to 6211210 Compare June 8, 2026 20:06
@dgarske
dgarske removed the request for review from wolfSSL-Bot June 8, 2026 20:45
Comment thread src/ssl.c

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.

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.

Comment thread tests/api/test_tls.h
Comment thread src/ssl.c Outdated
@dgarske
dgarske merged commit 358ae9a into wolfSSL:master Jun 9, 2026
479 of 480 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