Skip to content

Fixes for OpenSSL compatibility layer#10674

Merged
dgarske merged 3 commits into
wolfSSL:masterfrom
Frauschi:cert_chain_fix
Jun 12, 2026
Merged

Fixes for OpenSSL compatibility layer#10674
dgarske merged 3 commits into
wolfSSL:masterfrom
Frauschi:cert_chain_fix

Conversation

@Frauschi

Copy link
Copy Markdown
Contributor

Various fixes and hardening for the OpenSSL compatibility layer. Adds regression tests as well.

Fixes zd21920.

Frauschi added 3 commits June 12, 2026 17:29
Ensure caller-supplied intermediate certificates cannot terminate the
chain during compatibility-layer verification; a path must reach a
configured trust anchor. Add a regression test and supporting certs.
Fail compatibility-layer verification when the path-building loop runs
out of its depth budget before reaching a configured trust anchor,
instead of accepting the last verified link. Add a regression test.
…ck pollution

Robustness fixes in the OpenSSL-compatibility certificate verifier, independent
of the depth-exhaustion fix:

- Fail closed on allocation failure. When the failedCerts working stack could
  not be allocated, the function fell through to exit with ret still set to
  WOLFSSL_SUCCESS and reported the chain as verified without checking anything
  (a fail-open regression from the leak fix that turned the early return into a
  goto exit). Also check the ctx->chain allocation. Both now set an error.

- Remove caller-supplied intermediates from the correct stack. The intermediates
  appended to the working cert list during chain building were popped from
  ctx->store->certs by count, but they are appended to whichever stack is in use
  - which may be the caller's setTrustedSk (X509_STORE_CTX_set0_trusted_stack).
  Remove them by pointer identity from that same stack, recomputed from
  ctxIntermediates. Identity removal also survives the chain-building retries
  that reorder the stack, where a positional pop could drop a legitimate trusted
  entry and leave an injected intermediate behind - which a later verification
  reusing the store/ctx would then snapshot as a trust anchor. The removal helper
  walks the list once (O(n)) rather than indexing per position.

- NULL-guard ctx->store->param before dereferencing its flags in the
  partial-chain check.

Add regression tests covering: the trusted stack being restored after
verification, and the retry path (tampered plus genuine same-subject
intermediates, both orderings) leaving the store clean for later use.
@Frauschi Frauschi added the For This Release Release version 5.9.2 label Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

@dgarske dgarske merged commit e4b7b67 into wolfSSL:master Jun 12, 2026
304 of 305 checks passed
@Frauschi Frauschi deleted the cert_chain_fix branch June 12, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants