Skip to content

Fix user buffer overrun from wolfSSL_get_finished/wolfSSL_get_peer_finished#10576

Open
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:zd21906
Open

Fix user buffer overrun from wolfSSL_get_finished/wolfSSL_get_peer_finished#10576
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:zd21906

Conversation

@holtrop-wolfssl
Copy link
Copy Markdown
Contributor

Description

Fix user buffer overrun from wolfSSL_get_finished/wolfSSL_get_peer_finished

Fixes ZD#21906

Testing

Added unit tests to reproduce buffer overrun.

Checklist

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

@holtrop-wolfssl holtrop-wolfssl self-assigned this Jun 2, 2026
Copilot AI review requested due to automatic review settings June 2, 2026 22:24
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

Fixes a buffer overrun in the TLS Finished-message accessor APIs (wolfSSL_get_finished / wolfSSL_get_peer_finished) by preventing copies when the caller-provided buffer is smaller than the stored Finished message (notably TLS 1.3 where Finished can exceed TLS_FINISHED_SZ).

Changes:

  • Add size checks in wolfSSL_get_finished and wolfSSL_get_peer_finished to avoid writing past the caller’s buffer.
  • Add new unit tests that reproduce the prior overrun condition during a TLS 1.3 handshake and validate that no out-of-bounds writes occur.

Reviewed changes

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

File Description
tests/api.c Adds TLS 1.3 memio unit tests to detect and prevent Finished-message buffer overruns.
src/ssl.c Adds bounds checking before copying Finished-message bytes to user buffers.

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

Comment thread src/ssl.c
Comment on lines +12999 to +13005
if (count < len) {
WOLFSSL_MSG("Buffer too small");
return WOLFSSL_FAILURE;
}

XMEMCPY(buf, src, len);

Comment thread src/ssl.c
Comment on lines +13030 to +13036
if (count < len) {
WOLFSSL_MSG("Buffer too small");
return WOLFSSL_FAILURE;
}

XMEMCPY(buf, src, len);

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

MemBrowse Memory Report

No memory changes detected for:

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.

2 participants