Skip to content

fix(protocol): credential public key match limited to ECDSA - #732

Merged
james-d-elliott merged 1 commit into
masterfrom
fix-androidkey-ec2
Aug 8, 2026
Merged

fix(protocol): credential public key match limited to ECDSA#732
james-d-elliott merged 1 commit into
masterfrom
fix-androidkey-ec2

Conversation

@james-d-elliott

Copy link
Copy Markdown
Member

§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.

@james-d-elliott
james-d-elliott requested a review from a team as a code owner August 8, 2026 05:16
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 79230d5b-6ab3-409c-90b5-e6853305fded

📥 Commits

Reviewing files that changed from the base of the PR and between ae8fff8 and bc43f08.

📒 Files selected for processing (2)
  • protocol/attestation_androidkey.go
  • protocol/attestation_spec_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • protocol/attestation_androidkey.go

Walkthrough

Android 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.

Changes

Attestation key verification

Layer / File(s) Summary
Generic COSE key matching
protocol/utils.go
The shared matcher converts EC2, RSA, and OKP/Ed25519 keys to standard-library public keys, compares them with certificate keys, and returns the parsed credential key.
Attestation validator integration
protocol/attestation_androidkey.go, protocol/attestation_apple.go, protocol/attestation_spec_test.go
Android Key and Apple validation use the generic matcher. Android Key validation uses webauthncose.VerifySignature and checks algorithm agreement. U2F test comments reflect the permitted non-zero AAGUID.
Multi-algorithm validation coverage
protocol/utils_test.go
Tests cover ECDSA, RSA, and Ed25519 matches, mismatches, malformed keys, key-type differences, and generic certificate generation.

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
Loading

Poem

A rabbit checks each key with care,
EC, RSA, and Ed25519 share.
Certificates match, signatures fly,
Bad coordinates hop by.
Generic paths now pass the gate—
Thump, thump, verified state!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the protocol fix for ECDSA-only credential public key matching, which is the main change.
Description check ✅ Passed The description directly explains support for RSA keys and the updated Android Key signature verification.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-androidkey-ec2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.37500% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.08%. Comparing base (025d897) to head (bc43f08).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
protocol/utils.go 68.00% 5 Missing and 3 partials ⚠️
protocol/attestation_androidkey.go 33.33% 2 Missing and 2 partials ⚠️
protocol/attestation_apple.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
protocol/attestation_apple.go 54.83% <0.00%> (ø)
protocol/attestation_androidkey.go 78.78% <33.33%> (-1.22%) ⬇️
protocol/utils.go 87.23% <68.00%> (-3.75%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 025d897 and ae8fff8.

📒 Files selected for processing (4)
  • protocol/attestation_androidkey.go
  • protocol/attestation_apple.go
  • protocol/utils.go
  • protocol/utils_test.go

Comment thread protocol/attestation_androidkey.go
Comment thread protocol/attestation_androidkey.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.
@james-d-elliott
james-d-elliott merged commit b4df26e into master Aug 8, 2026
8 of 11 checks passed
@james-d-elliott
james-d-elliott deleted the fix-androidkey-ec2 branch August 8, 2026 05:34
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