fix(protocol): credential public key match limited to ECDSA - #732
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAndroid Key and Apple attestation validation now use generic credential public-key matching. The matcher supports EC2, RSA, and Ed25519 COSE keys. Tests cover matches, mismatches, malformed keys, and key-type differences. ChangesAttestation key verification
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant AndroidKeyAttestation
participant verifyAttestationPublicKeyMatch
participant webauthncose.VerifySignature
AndroidKeyAttestation->>verifyAttestationPublicKeyMatch: verify credential key against certificate key
verifyAttestationPublicKeyMatch-->>AndroidKeyAttestation: return parsed credential key
AndroidKeyAttestation->>webauthncose.VerifySignature: verify attestation signature
webauthncose.VerifySignature-->>AndroidKeyAttestation: return verification result
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #732 +/- ##
==========================================
- Coverage 86.23% 86.08% -0.16%
==========================================
Files 49 49
Lines 4286 4296 +10
==========================================
+ Hits 3696 3698 +2
- Misses 379 384 +5
- Partials 211 214 +3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@protocol/attestation_androidkey.go`:
- Around line 100-103: Update the verification handling around
webauthncose.VerifySignature in the Android key attestation flow by checking and
reporting a non-nil verification error separately from a false valid result.
Preserve the existing error cause only for actual verification errors, and
return a distinct invalid-signature detail without formatting or attaching a nil
error when valid is false.
- Around line 97-103: Update the second signature verification in the Android
key attestation flow to use the attestation statement’s alg value by passing
webauthncose.COSEAlgorithmIdentifier(alg) to VerifySignature, or remove this
redundant check. Preserve the existing invalid-attestation error handling while
ensuring RSA/PSS and ECDSA attestations are verified with the statement
algorithm rather than the credential key’s algorithm.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 16ec60ee-5fcd-4032-a295-8c722eeb1d70
📒 Files selected for processing (4)
protocol/attestation_androidkey.goprotocol/attestation_apple.goprotocol/utils.goprotocol/utils_test.go
§8.4 and §8.8 only require the attestation certificate public key to match the credentialPublicKey, but the check refused anything but ECDSA on either side, rejecting the RSA keys Android Keystore attests. It now converts the parsed COSE key to its standard library equivalent and compares with Equal, so a differing key type is a mismatch rather than a refusal. The android-key handler's second signature verification now goes through webauthncose.VerifySignature. It isn't redundant with the certificate check above it, as each takes its digest from the algorithm it carries, so passing both requires the two to agree.
ae8fff8 to
bc43f08
Compare
§8.4 and §8.8 only require the attestation certificate public key to match the credentialPublicKey, but the check refused anything but ECDSA on either side, rejecting the RSA keys Android Keystore attests. It now converts the parsed COSE key to its standard library equivalent and compares with Equal, so a differing key type is a mismatch rather than a refusal.
The android-key handler's second signature verification now goes through webauthncose.VerifySignature. It isn't redundant with the certificate check above it, as each takes its digest from the algorithm it carries, so passing both requires the two to agree.