Skip to content

[LOW] Reject incompatible verification key algorithms - #23

Open
OskarEichler wants to merge 1 commit into
cedarcode:masterfrom
OskarEichler:codex/reject-incompatible-verify-keys
Open

[LOW] Reject incompatible verification key algorithms#23
OskarEichler wants to merge 1 commit into
cedarcode:masterfrom
OskarEichler:codex/reject-incompatible-verify-keys

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Reject verification keys from a different algorithm family during assignment. This keeps attacker-controlled key/algorithm mismatches inside the gem’s VerifyKeyError boundary instead of allowing later backend method failures.

RSA keys are validated by their public components, and EdDSA keys by their Ed25519 verification-key type. ECDSA already validates its algorithm family and curve.

Reproduction

The shared capability-only check accepts an ECDSA key for RSA because it responds to verify; RSA-PSS later raises NoMethodError for verify_pss. EdDSA similarly accepts RSA keys and fails later on its two-argument verification call. Credential formats that carry both algorithm identifiers and public keys can expose these mismatches to untrusted input.

Verification

  • Focused model: three RSA-PSS/RSA-PKCS1/EdDSA mismatches fail on master and raise VerifyKeyError on this branch
  • Existing suite: 31 examples, 0 failures on Ruby 4.0.6 through rbenv
  • Normal wrapper and raw OpenSSL RSA verification keys remain accepted
  • RuboCop, package build, and downstream loading passed in the cumulative ordinary review
  • No repository tests or dependency files changed

Compatibility and breaking changes

Valid keys are unchanged. Incompatible keys now fail at assignment with VerifyKeyError; callers relying on a later backend-specific exception will observe this intentional error-timing change.

@OskarEichler OskarEichler changed the title Reject incompatible verification key algorithms [LOW] Reject incompatible verification key algorithms 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