Repository navigation
Cgo wrapper hardening: bounds, validation, missing stubs - #39
Open
JeremiahM37 wants to merge 4 commits into
Open
JeremiahM37 wants to merge 4 commits into
JeremiahM37 wants to merge 4 commits into
Conversation
JeremiahM37
force-pushed
the
fenrir
branch
2 times, most recently
from
May 11, 2026 06:14
a457752 to
5a243d5
Compare
JeremiahM37
marked this pull request as ready for review
May 11, 2026 06:20
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #39
Scan targets checked: go-wolfssl-bugs, go-wolfssl-src
No new issues found in the changed files. ✅
There was a problem hiding this comment.
🟡 Changes recommended
HMAC-disabled builds still fail to compile or link because the PBKDF2 stub is skipped when NO_HMAC is defined without NO_PWDBASED, leaving wc_PBKDF2_Unlocked calling a missing function.
1 open issue
What changed in this PR
This PR hardens the Go cgo wrappers around wolfSSL by validating sizes before C conversions, correcting appended-tag buffer handling, and adding disabled-feature stubs.
Changes:
- Add bounds checks for TLS I/O, X509/BIO buffers, Curve25519 buffers, and PBKDF2 arguments.
- Correct ChaCha20-Poly1305 ciphertext/tag placement and clarify AES-GCM buffer sizing.
- Add fallback stubs for disabled HMAC, HKDF, and password-based cryptography.
| File | Description |
|---|---|
| x509.go | Guard certificate, public-key, and BIO sizes before C integer conversions. |
| ssl.go | Reject oversized TLS read/write requests. |
| hmac.go | Add disabled-feature HMAC and HKDF stubs. |
| curve25519.go | Validate buffer sizes and pin output lengths to 32 bytes. |
| chacha_poly.go | Place the appended tag directly after ciphertext in oversized buffers. |
| aes.go | Add a PBKDF2 stub and argument checks; clarify AES-GCM buffer sizing. |
Review effort: Balanced
| // return -174; | ||
| // } | ||
| // #endif | ||
| // #ifdef NO_PWDBASED |
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.

Fixes F-3021, F-1866, F-2546, F-1872, F-1875, F-2550, F-2553, F-2551, F-3023
Summary:
len(inPlain)+tagso oversized caller buffers don't leave garbage between cipher and tag.math.MaxInt32before theC.intcast inWolfSSL_read/write, curve25519 make_pub/make_priv,BIO_new_mem_buf, and X509 buffer wrappers (BIO can wrap to -1, OpenSSL'sstrlensentinel).iter <= 0inWc_PBKDF2and require exactlyCURVE25519_KEYSIZEon curve25519 export/shared_secret outputs.