Skip to content

[LOW] Normalize malformed signature verification errors - #21

Open
OskarEichler wants to merge 2 commits into
cedarcode:masterfrom
OskarEichler:codex/normalize-malformed-verification-errors
Open

[LOW] Normalize malformed signature verification errors#21
OskarEichler wants to merge 2 commits into
cedarcode:masterfrom
OskarEichler:codex/normalize-malformed-verification-errors

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 29, 2026

Copy link
Copy Markdown

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, or OpenSSL::PKey::PKeyError for malformed signature shapes and lengths. Downstream callers such as COSE commonly catch OpenSSL::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

  • Candidate: 52/52 malformed inputs raise SignatureVerificationError; all four algorithms still verify valid signatures
  • Existing suite: 31 examples, 0 failures on Ruby 4.0.6 through rbenv
  • RuboCop: 20 files, 0 offenses
  • Ruby 3.2.11 syntax checks pass for all three changed paths
  • Version 1.3.0 gem builds and unpacks successfully
  • No repository tests or dependency files changed

Compatibility 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 SignatureVerificationError instead of backend-specific exceptions; callers relying on those backend exception classes will observe this intentional error-normalization change.

@OskarEichler OskarEichler changed the title Normalize malformed signature verification errors [LOW] Normalize malformed signature verification errors Sep 3, 2026
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