Skip to content

pkey: use RSTRING_LENINT() instead of casting to int - #460

Merged
rhenium merged 1 commit into
ruby:maint-2.1from
rhenium:ky/pkey-ec-verify-overflow
Sep 28, 2021
Merged

rhenium merged 1 commit into
ruby:maint-2.1from
rhenium:ky/pkey-ec-verify-overflow

Conversation

@rhenium

@rhenium rhenium commented Sep 28, 2021

Copy link
Copy Markdown
Member

RSTRING_LENINT() checks the range of int and raises an exception as
necessary. OpenSSL::PKey::EC#dsa_verify_asn1 currently does not do this,
and giving a too big string to it can trigger a surprising behavior:

ec.dsa_verify_asn1(digest, signature)               #=> true
ec.dsa_verify_asn1(digest, signature + "x" * 2**32) #=> true

Reference: https://hackerone.com/reports/1246050

RSTRING_LENINT() checks the range of int and raises an exception as
necessary. OpenSSL::PKey::EC#dsa_verify_asn1 currently does not do this,
and giving a too big string to it can trigger a surprising behavior:

    ec.dsa_verify_asn1(digest, signature)               #=> true
    ec.dsa_verify_asn1(digest, signature + "x" * 2**32) #=> true

Reference: https://hackerone.com/reports/1246050
@rhenium
rhenium merged commit 6880dba into ruby:maint-2.1 Sep 28, 2021
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