Block cert modification in callbacks - #11191
Conversation
|
retest this please |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11191
Scan targets checked: wolfcrypt-rs-bugs, wolfssl-bugs, wolfssl-src
Findings: 10
10 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
| { | ||
| int ret = 0; | ||
|
|
||
| if (SslDerIsStale(ssl->buffers.certificate, ssl->buffers.weOwnCert, |
There was a problem hiding this comment.
🔵 [Low] Cert-swap block is post-hoc and per-session; other sessions on the CTX keep dangling DER pointers · Use-after-free / double-free
The check runs only after the callback has already freed ctx->certificate/ctx->privateKey. In the default non-WOLFSSL_COPY_CERT build every other live WOLFSSL from that CTX still aliases the freed DerBuffer (assigned at src/internal.c:7627) and dereferences it when building its Certificate message, so the use-after-free remains reachable for concurrent sessions.
Fix: Prevent CTX cert/key replacement while sessions reference it (refcount the DerBuffers or reject the load) rather than detecting it after the free.
There was a problem hiding this comment.
Refcount solution was attempted and sprawling, but would allow us to support modification in the callbacks. But too invasive of a change for an invalid use case.
There was a problem hiding this comment.
The ability to reach a UAF is a legit problem with this approach. Closing the PR
|
070e66a to
e90aefe
Compare
|
Superseded by #11203 |
Description
Prevent the user from modifying certificates when those buffers are aliased across
WOLFSSLandWOLFSSL_CTXobjects. Specifically, thewolfSSL_CTX_use_certificate*andwolfSSL_CTX_user_PrivateKey*API families (and a few other one-offs) are blocked.This is yet another approach to solving zd 22107
Testing
New unit tests.
Checklist