Address VerifyDelegate last-wins signature selection and uniqueness c…#748
Open
udf2457 wants to merge 1 commit into
Open
Address VerifyDelegate last-wins signature selection and uniqueness c…#748udf2457 wants to merge 1 commit into
udf2457 wants to merge 1 commit into
Conversation
…heck At present `VerifyDelegate` has no `break` and the last matching signature wins silently. Adding the `break` statement makes it clear we only want one signature per keyID. In addition, it is slightly more efficient as we stop searching after finding a match Second, adding some defense in depth by catching duplicate keyIDs both during loading and verification. Signed-off-by: udf2457 <udf2457@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR tightens delegated-metadata signature verification in Metadata.VerifyDelegate by preventing ambiguous “last match wins” behavior and adding explicit validation to reject duplicate signature keyIDs.
Changes:
- Adds an early duplicate-signature (duplicate keyID) check for delegated metadata passed into
VerifyDelegate. - Makes signature selection deterministic and slightly more efficient by breaking out of signature scans after the first matching keyID is found.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+261
to
+263
| // Early check for duplicate signatures in the delegated metadata | ||
| switch d := delegatedMetadata.(type) { | ||
| case *Metadata[RootType]: |
Comment on lines
+261
to
+279
| // Early check for duplicate signatures in the delegated metadata | ||
| switch d := delegatedMetadata.(type) { | ||
| case *Metadata[RootType]: | ||
| if err := checkUniqueSignatures(*d); err != nil { | ||
| return err | ||
| } | ||
| case *Metadata[SnapshotType]: | ||
| if err := checkUniqueSignatures(*d); err != nil { | ||
| return err | ||
| } | ||
| case *Metadata[TimestampType]: | ||
| if err := checkUniqueSignatures(*d); err != nil { | ||
| return err | ||
| } | ||
| case *Metadata[TargetsType]: | ||
| if err := checkUniqueSignatures(*d); err != nil { | ||
| return err | ||
| } | ||
| } |
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.
At present
VerifyDelegatehas nobreakand the last matching signature wins silently.Adding the
breakstatement makes it clear we only want one signature per keyID. In addition, it is slightly more efficient as we stop searching after finding a matchSecond, adding some defense in depth by catching duplicate keyIDs both during loading and verification.