Repository navigation
Conversation
|
142c6f6 to
8e11d4f
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12062
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfcrypt-port-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): doc/dox_comments/header_files/asn_public.h
Coverage: 10 of 12 in-scope changed file(s) opened by the reviewer; not opened: wolfssl/internal.h, wolfssl/wolfcrypt/asn.h
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12062
Scan targets checked: wolfssl-src, wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs, wolfcrypt-port-bugs
Not reviewed (no scan target covers them): doc/dox_comments/header_files/asn_public.h
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
|
@ageprocpp I believe this overlaps some with the older #12021 PR. Can you verify and pull out portions that do not or close this one please. |
bb2d1e5 to
2a32313
Compare
2a32313 to
192bb21
Compare
|
@JacobBarthelmeh #12021 uses reference-counted sharing when This PR extends the lifetime guarantee to those configurations. It reuses #12021’s reference counting where available and falls back to copying when reference counting is unavailable. It also handles alternative keys and preserves CTX-derived credentials across automatic handshake cleanup so that an SSL can be reused. |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12062
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Coverage: 6 of 10 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c, tests/api/test_tls.c, wolfssl/internal.h, wolfssl/wolfcrypt/settings.h
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
| { | ||
| #if !defined(WOLFSSL_COPY_CERT) | ||
| const DerBuffer* cert = ssl->buffers.certificate; | ||
| const DerBuffer* ctxCert = ssl->ctx != NULL ? ssl->ctx->certificate : NULL; |
There was a problem hiding this comment.
OCSP cache eligibility check reads ctx-certificate without synchronization during handshakes · Race conditions
SslCanUseCtxOcspCache reads ssl->ctx->certificate mid-handshake with no lock. A concurrent CTX reload (ProcessBufferCertHandleDer FreeDer(&ctx->certificate)) causes a use-after-free in XMEMCMP in copy builds, or stapling a cached OCSP request for the new CTX cert. Related known finding F-8917 (similar but distinct): that finding covers SSLs borrowing CTX buffers; this new code dereferences the CTX buffer itself.
Suggested fix: Fixing this needs a design decision: tie the CTX OCSP cache entry to a specific CTX certificate (for example under ctx->ocspLock) rather than reading ctx->certificate unlocked.
Related known findings (similar but distinct; listed for context, not part of this finding)
- F-15606 (open): File/function: the candidate is SslCanUseCtxOcspCache, while F-15606 is DefTicketEncCb. Both are in src/internal.c but they are different functions, so this does not match. Faulting operation: the candidate reads ssl->ctx->certificate and dereferences it (XMEMCMP) while a CTX reload frees it, a use-after-free or stale-cert race. F-15606 reads the expirary[0] sentinel before taking the mutex and then consumes ticket key material, an initialization-publication race. Root cause: both read shared stat
Description
Fixes Fenrir #16791.
When
WOLFSSL_COPY_CERTorWOLFSSL_COPY_KEYis disabled, an SSL object borrows the certificate, chain, or key buffer from its CTX. Replacing one of those buffers on the CTX afterwolfSSL_new()can leave the existing SSL with a dangling pointer.#12021 introduced reference-counted DER sharing for configurations where copying was enabled. This PR extends the lifetime guarantee to configurations where copying is disabled:
ShareDer(). Where DER reference counting is unavailable,ShareDer()falls back to copying.wolfSSL_clear()can reuse the SSL. Explicit unloading still releases them.Applications must synchronize credential updates on a CTX with SSL creation from that CTX. If the certificate and key are updated separately, applications must also prevent SSL creation between those updates.
Background
This PR builds on #12021 and retains the part that was not covered there: buffer lifetime when certificate or key copying is disabled.
The reference-counting approach was previously proposed in #11109. The callback restrictions in #11191 address a different case; the lifetime issue can also occur when a CTX is updated after
wolfSSL_new()and before the SSL uses its credentials.