Skip to content

x509name: check for error of X509_NAME_cmp()#1030

Open
ndossche wants to merge 1 commit intoruby:masterfrom
ndossche:clesss-5
Open

x509name: check for error of X509_NAME_cmp()#1030
ndossche wants to merge 1 commit intoruby:masterfrom
ndossche:clesss-5

Conversation

@ndossche
Copy link
Copy Markdown
Contributor

These functions may return -2 to indicate an error according to the manual [1]. This can also be confirmed when looking at the code as it may call into i2d_X509_NAME() which can fail [2].
In such cases, the failure is reinterpreted as a "less than" comparison and the error is not reported, potentially leading to wrong results in userland code.

[1] https://manpages.opensuse.org/Tumbleweed/openssl-3-doc/X509_NAME_cmp.33ssl.en.html
[2] https://github.com/openssl/openssl/blob/f023662d1bde1fcb7fecf976b25a45afd55734b8/crypto/x509/x509_cmp.c#L269-L271

This was found by a hybrid static-dynamic analyser that looks for inconsistent handling of error checks in bindings.

These functions may return -2 to indicate an error according to the
manual [1]. This can also be confirmed when looking at the code as it
may call into i2d_X509_NAME() which can fail [2].
In such cases, the failure is reinterpreted as a "less than" comparison
and the error is not reported, potentially leading to wrong results in
userland code.

[1] https://manpages.opensuse.org/Tumbleweed/openssl-3-doc/X509_NAME_cmp.33ssl.en.html
[2] https://github.com/openssl/openssl/blob/f023662d1bde1fcb7fecf976b25a45afd55734b8/crypto/x509/x509_cmp.c#L269-L271
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.

1 participant