25.3.8-fips: openssl-cmake: shim fixes for MongoDB#1451
25.3.8-fips: openssl-cmake: shim fixes for MongoDB#1451Enmk merged 2 commits intoreleases/25.3.8-fipsfrom
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7223ea8e64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ccd7df1c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| SSL *ssl = (SSL *)BIO_get_data(b); | ||
| if (!ssl) |
There was a problem hiding this comment.
Validate BIO type before casting BIO_get_data to SSL
BIO_do_handshake now assumes b is always an SSL BIO and immediately casts BIO_get_data(b) to SSL *, but BIO_get_data for non-SSL BIOs returns other internal structs. If a caller invokes handshake on a wrapped chain head (e.g., a filter/connect BIO above SSL), SSL_get_rbio/SSL_do_handshake will run on an invalid pointer and can crash. The previous BIO_ctrl(...BIO_C_DO_STATE_MACHINE...) path delegated through BIO ctrl handlers instead of dereferencing arbitrary BIO payloads.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The only call site for this function in the entire codebase is mongoc-stream-tls-openssl.c:569, and openssl->bio is assigned at line 793 from bio_ssl, which is the SSL BIO created by BIO_new_ssl.
| #define BIO_get_ssl(b, sslp) \ | ||
| BIO_ctrl(b, BIO_C_GET_SSL, 0, (char *)(sslp)) | ||
| #define BIO_do_handshake(b) \ | ||
| BIO_ctrl(b, BIO_C_DO_STATE_MACHINE, 0, NULL) | ||
| (*(SSL **)(sslp) = (SSL *)BIO_get_data(b)) |
There was a problem hiding this comment.
Preserve BIO_ctrl chain semantics in BIO_get_ssl shim
Replacing BIO_get_ssl with direct BIO_get_data(b) extraction drops BIO_ctrl forwarding semantics and only works when b is the SSL BIO itself. On chained BIOs, this macro will store the top BIO's private data pointer into sslp rather than the SSL object, which can later cause invalid SSL operations. OpenSSL's macro (BIO_ctrl(...BIO_C_GET_SSL...)) supports wrappers by routing through ctrl handlers.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
In our use case (MongoDB contrib), every call for BIO_get_ssl is proven to be on the SSL BIO directly and called right after BIO_new_ssl
|
AI audit returned 1 defect (potential memory leak). I think this one needs review. |
This seems to be a real issue. Thanks! I'll fix it asap. Reference: https://github.com/aws/aws-lc/blob/AWS-LC-FIPS-2.0.0/ssl/ssl_lib.cc#L748 |
|
Fixed by #1616 . LGTM |
This commit fixes three issues that led to MongoDB integration tests failing. I tried to explain each of the fixes with a proper documentation to the function/macro.
Changelog category (leave one):
CI/CD Options
Exclude tests:
Regression jobs to run: