[LOW] Protect Ed25519 key objects from external mutation - #53
Open
OskarEichler wants to merge 1 commit into
Open
[LOW] Protect Ed25519 key objects from external mutation#53OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit 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
Security impact
Severity: LOW.
VerifyKeycurrently retains the caller's mutable string and returns the same object fromto_bytes. Code that keeps or receives that string can replace the trusted verification key after construction; a signature from the replacement key is then accepted.SigningKeyexposes similar mutable internal state, which can corrupt its serialized identity or future signatures.Exploitation requires access to a mutable string already shared with the key object. This does not reveal secret key material beyond the gem's existing serialization API and does not permit forging signatures for an unchanged key.
Reproduction
On 1.4.0/current
main, construct a verifier from trusted key bytes, retain that input string, replace its contents with an attacker public key, then verify an attacker signature. Verification succeeds because the verifier's internal key changed through the retained reference.Verification
git diff --checkpassedCompatibility and limitations
Breaking-change note: callers can still serialize and mutate the returned strings, but those mutations no longer modify the existing key object. Code that intentionally relied on this undocumented aliasing behavior must construct a new key object after changing bytes.
This patch does not alter Ed25519 verification semantics, ref10/ZIP-215 compatibility, signature canonicality, provider selection, or cryptographic arithmetic.