[LOW] Normalize malformed signature verification errors - #21
Open
OskarEichler wants to merge 2 commits into
Open
[LOW] Normalize malformed signature verification errors#21OskarEichler wants to merge 2 commits into
OskarEichler wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Normalize malformed signature and verification-data inputs across ECDSA, RSA-PKCS1, RSA-PSS, and EdDSA to
SignatureVerificationError. This keeps attacker-controlled invalid signature material inside the gem's documented verification-failure boundary instead of leaking Ruby, OpenSSL, or Ed25519 backend exceptions.The original commit normalized malformed ECDSA byte strings that raise
OpenSSL::PKey::PKeyError. The follow-up validates input types before backend calls and normalizes invalid Ed25519 signature lengths.Reproduction
Release/current behavior can raise
NoMethodError,TypeError,ArgumentError, orOpenSSL::PKey::PKeyErrorfor malformed signature shapes and lengths. Downstream callers such as COSE commonly catchOpenSSL::SignatureAlgorithm::Error; the leaked exceptions can therefore turn an invalid credential into an unhandled request or worker failure.The focused model exercises eight malformed signatures and five malformed verification-data values across all four algorithms: 52 rejection paths in total.
Verification
SignatureVerificationError; all four algorithms still verify valid signaturesCompatibility and breaking changes
Valid signatures, key assignment/deserialization, and signing behavior are unchanged. Invalid non-string inputs and malformed Ed25519 lengths now raise the gem's existing
SignatureVerificationErrorinstead of backend-specific exceptions; callers relying on those backend exception classes will observe this intentional error-normalization change.