Skip to content

Fix multiple reported issues. - #11009

Open
kareem-wolfssl wants to merge 8 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd22229
Open

Fix multiple reported issues.#11009
kareem-wolfssl wants to merge 8 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd22229

Conversation

@kareem-wolfssl

Copy link
Copy Markdown
Contributor

Description

Fixes zd#22229

Testing

Built in tests, provided reproducers.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@kareem-wolfssl kareem-wolfssl self-assigned this Jul 30, 2026
Copilot AI review requested due to automatic review settings July 30, 2026 00:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses multiple reported issues (zd#22229) across certificate verification and TLS handshake processing by tightening cleanup semantics and enforcing negotiated values for RPK certificate-type extensions.

Changes:

  • Prevent untrusted temporary CA issuers from persisting in the shared CertManager during/after wolfSSL_X509_verify_cert() and fix object-list cleanup when CRLs are appended.
  • Enforce “offered vs received” constraints for client_cert_type / server_cert_type (RFC 7250 / RFC 8446) to reject unsolicited or unoffered negotiated values.
  • Reset per-handshake RPK negotiation state on SSL object reuse and harden output-buffer shrinking to avoid freeing non-heap memory and to drop stale accounting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/x509_str.c Harden temp-CA lifecycle during X509 store verification; fix get0_objects() cleanup when CRLs are present.
src/tls.c Reject unsolicited/unoffered cert-type negotiation values for RPK-related TLS extensions.
src/ssl.c Reset RPK negotiation state on WOLFSSL object reuse (preserving isRPKLoaded).
src/internal.c Make ShrinkOutputBuffer() safe for static buffers and reset output accounting when discarding pending output.
Comments suppressed due to low confidence (1)

src/x509_str.c:1170

  • Exit cleanup unconditionally calls wolfSSL_CertManagerUnloadTempIntermediateCerts(), but ignores its return value. If this unload fails (e.g., BAD_MUTEX_E), the function can return success while leaving WOLFSSL_TEMP_CA entries resident in the shared CertManager, undermining the stated goal of always cleaning up temporary trust anchors. Consider propagating cleanup failure (at least when verification otherwise succeeded).
        if (ctx->store != NULL) {
            wolfSSL_CertManagerUnloadTempIntermediateCerts(ctx->store->cm);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/x509_str.c Outdated
Comment on lines 1011 to 1013
X509StoreRemoveCa(ctx->store, issuer, WOLFSSL_TEMP_CA);
X509VerifyCertSetupRetry(ctx, certs, failedCerts,
&depth, origDepth);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't solve the problem. It just acts as a retry. Erroring out directly from X509StoreRemoveCa should be fine.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m3

  • FLASH: .text +8 B (+0.0%, 122,619 B / 262,144 B, total: 47% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text -64 B (-0.0%, 771,348 B / 1,048,576 B, total: 74% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +64 B (+0.0%, 236,679 B / 262,144 B, total: 90% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +64 B (+0.0%, 280,576 B / 1,048,576 B, total: 27% used)

linuxkm-standard

@julek-wolfssl julek-wolfssl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments are way too verbose

Comment thread src/x509_str.c Outdated
Comment on lines 1011 to 1013
X509StoreRemoveCa(ctx->store, issuer, WOLFSSL_TEMP_CA);
X509VerifyCertSetupRetry(ctx, certs, failedCerts,
&depth, origDepth);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't solve the problem. It just acts as a retry. Erroring out directly from X509StoreRemoveCa should be fine.

…reset the buffer state.

Thanks to Christos Papakonstantinou (Cantina Security) for the report.
Thanks to Christos Papakonstantinou (Cantina Security) for the report.
Thanks to Christos Papakonstantinou (Cantina Security) for the report.
Thanks to Christos Papakonstantinou (Cantina Security) for the report.
… logic, add test, make comments less verbose
@kareem-wolfssl

kareem-wolfssl commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

I removed the X509StoreRemoveCa call. Adding error checking would have caused issues in the case that the cert was already added previously. AddCA would return success, but the cert would not be added as TEMP_CA type, so X509StoreRemoveCa would error out.

The TEMP_CAs will be removed either way by the unconditional wolfSSL_CertManagerUnloadTempIntermediateCerts call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants