-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
crypto: fix to check ext method for shared lib #800
Conversation
LGTM but perhaps it can be further simplified? diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 5432eae..c9d1cf1 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -1099,15 +1099,8 @@ void SSLWrap<Base>::OnClientHello(void* arg,
static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
- // Only alt_name is escaped at the moment
- if (OBJ_obj2nid(ext->object) != NID_subject_alt_name)
- return false;
-
const X509V3_EXT_METHOD* method = X509V3_EXT_get(ext);
- if (method == NULL || method->it == NULL)
- return false;
-
- if (method->i2v != reinterpret_cast<X509V3_EXT_I2V>(i2v_GENERAL_NAMES))
+ if (method != X509V3_EXT_get_nid(NID_subject_alt_name))
return false;
const unsigned char* p = ext->value->data; |
Good tip, Ben! |
@bnoordhuis It seems to me that Edit: |
In the case of using openssl with shared library, reinterpret_cast<X509V3_EXT_I2V>(i2v_GENERAL_NAMES)) refers plt pointer so that SafeX509ExtPrint returns false. Fix it to check it with method of NID_subject_alt_name This patch originally was created by Fedor Indutny and Ben Noordhuis Fixes: nodejs#617
Functionally? I don't think so. I used X509V3_EXT_get_nid because I'm not 100% sure if ext_nid is intended for public consumption. Your approach is probably fine, though. |
I see you updated the PR. LGTM. :-) |
Guys, I have a question for you. Do we care about NULL char in NID_issuer_alt_name and NID_certificate_issuer ? |
I think so. Better too strict than too loose. |
Yes, ideally we should care all the fields. It will be better to another fixes. |
Ok, please update it |
In the case of using openssl with shared library, reinterpret_cast<X509V3_EXT_I2V>(i2v_GENERAL_NAMES)) refers plt pointer so that SafeX509ExtPrint returns false. Fix it to check it with method of NID_subject_alt_name This patch originally was created by Fedor Indutny and Ben Noordhuis Fixes: #617 PR-URL: #800 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor@indutny.com>
Okay, landed in e63b517 . I will submit an another issue. Thanks for reviewing and discussion. |
Should we do the responsible thing here and ask for a CVE? Or at least get in touch with packagers and tell them they need to apply this patch when building with --shared-openssl? Also, /cc @tjfontaine and/or @misterdjules - this most likely affects joyent/node too. |
@bnoordhuis I don't think that we should. Again this issue is very unlikely to be exploitable, because all CA issued certs are validated now. Though, it won't harm to ask people to update :) |
I agree with @indutny |
Good job @shigeki ! |
Okay, I'll let joyent/node deal with, that's what's still shipped in Fedora and Debian. |
In the case of using openssl with shared library, reinterpret_cast<X509V3_EXT_I2V>(i2v_GENERAL_NAMES)) refers plt pointer so that SafeX509ExtPrint returns false.
Fix it to check it with nid of ext method.
This patch originally was created by Fedor Indutny.
Fixes: #617
Reviewer: @indutny @bnoordhuis