-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
crypto: Fix potential null pointer dereference when BIO_meth_new() fails #61788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
| @@ -226,13 +226,15 @@ const BIO_METHOD* NodeBIO::GetMethod() { | |||
| // Static initialization ensures that this is safe to use concurrently. | |||
| static const BIO_METHOD* method = [&]() { | |||
| BIO_METHOD* method = BIO_meth_new(BIO_TYPE_MEM, "node.js SSL buffer"); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to just CHECK_NOT_NULL(method); here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, some places seem to try to gracefully handle nulls, others don't, so I wasn't too sure. I'll change it.
This function can return null, which will make the calls to BIO_meth_set_* trigger a null deref. Even after fixing this, there is an issue with the `BIOPointer::New(GetMethod())` call in `NodeBIO::New` because the `New` method cannot handle a null pointer despite other code already guarding for this (e.g. the `NodeBIO::New` function already checks `bio`). This patch solves the issues by adding more null checks.
This function calls BIO_new() which mustn't receive a null pointer argument. Yet it is able to handle null BIOs gracefully. To solve this, add a null check. Ref: nodejs/node#61788
This function calls BIO_new() which mustn't receive a null pointer argument. Yet it is able to handle null BIOs gracefully. To solve this, add a null check. Ref: nodejs/node#61788
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61788 +/- ##
==========================================
- Coverage 89.76% 89.73% -0.03%
==========================================
Files 675 675
Lines 204674 204675 +1
Branches 39330 39340 +10
==========================================
- Hits 183716 183656 -60
- Misses 13235 13293 +58
- Partials 7723 7726 +3
🚀 New features to boost your workflow:
|
This function can return null, which will make the calls to BIO_meth_set_* trigger a null deref.
Even after fixing this, there is an issue with the
BIOPointer::New(GetMethod())call inNodeBIO::Newbecause theNewmethod cannot handle a null pointer despite other code already guarding for this(e.g. the
NodeBIO::Newfunction already checksbio). This patch solves the issues by adding more null checks.Note: this was found by a static-dynamic analyser I'm developing.