Fix user buffer overrun from wolfSSL_get_finished/wolfSSL_get_peer_finished#10576
Open
holtrop-wolfssl wants to merge 1 commit into
Open
Fix user buffer overrun from wolfSSL_get_finished/wolfSSL_get_peer_finished#10576holtrop-wolfssl wants to merge 1 commit into
holtrop-wolfssl wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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_finishedandwolfSSL_get_peer_finishedto 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 on lines
+12999
to
+13005
| if (count < len) { | ||
| WOLFSSL_MSG("Buffer too small"); | ||
| return WOLFSSL_FAILURE; | ||
| } | ||
|
|
||
| XMEMCPY(buf, src, len); | ||
|
|
Comment on lines
+13030
to
+13036
| if (count < len) { | ||
| WOLFSSL_MSG("Buffer too small"); | ||
| return WOLFSSL_FAILURE; | ||
| } | ||
|
|
||
| XMEMCPY(buf, src, len); | ||
|
|
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.
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