Skip to content

[Bug #14087] x509cert, x509crl, x509req, ns_spki: check sanity of public key#168

Merged
rhenium merged 2 commits intoruby:maintfrom
rhenium:ky/pkey-check-sanity
Nov 14, 2017
Merged

[Bug #14087] x509cert, x509crl, x509req, ns_spki: check sanity of public key#168
rhenium merged 2 commits intoruby:maintfrom
rhenium:ky/pkey-check-sanity

Conversation

@rhenium
Copy link
Member

@rhenium rhenium commented Nov 13, 2017

The pub_encode routine of an EVP_PKEY_ASN1_METHOD seems to assume the
parameters and public key component(s) to be set properly. Calling that,
for example, through X509_set_pubkey(), with an incomplete object may
cause segfault.

Use ossl_pkey_check_public_key() to check that. It doesn't look pretty,
but unfortunately there isn't a generic way to do that with the EVP API.

Something similar applies to the verify routine of an EVP_PKEY_METHOD.
Do the same check before calling *_verify().

Reference: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/83688
Reference: https://bugs.ruby-lang.org/issues/14087

Also make it take const pointer as it never modifies the pkey.
The pub_encode routine of an EVP_PKEY_ASN1_METHOD seems to assume the
parameters and public key component(s) to be set properly. Calling that,
for example, through X509_set_pubkey(), with an incomplete object may
cause segfault.

Use ossl_pkey_check_public_key() to check that. It doesn't look pretty,
but unfortunately there isn't a generic way to do that with the EVP API.

Something similar applies to the verify routine of an EVP_PKEY_METHOD.
Do the same check before calling *_verify().

Reference: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/83688
Reference: https://bugs.ruby-lang.org/issues/14087
@rhenium rhenium merged commit eb2a571 into ruby:maint Nov 14, 2017
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