Verify TAPSIGNER factory certificates - #870
Conversation
Wrap TapSigner in a VerifiedTapSigner newtype that runs certificate verification during connection. Development factory certificates are rejected with an IncorrectSignature error, blocking any authenticated commands from reaching counterfeit cards. Adds a test with a simulated counterfeit transport that confirms rejection after exactly 3 APDU exchanges.
📝 WalkthroughWalkthroughTapSigner reader initialization now verifies card certificates and rejects counterfeit or development factory certificates before use. New tests confirm rejection occurs before authenticated commands, with added development dependencies for certificate test data. ChangesTapSigner verification
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TapSignerReader
participant VerifiedTapSigner
participant TapSignerCard
participant CertificateVerifier
TapSignerReader->>VerifiedTapSigner: connect
VerifiedTapSigner->>TapSignerCard: request status and certificate
VerifiedTapSigner->>CertificateVerifier: verify certificate
CertificateVerifier-->>VerifiedTapSigner: authentication result
VerifiedTapSigner-->>TapSignerReader: verified signer or error
Suggested reviewers: 🚥 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rust/src/tap_card/tap_signer_reader.rs (1)
86-99: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSeparate result bindings from control flow.
Insert blank lines after lines 87 and 98. This separates each result binding from the following
matchorif.As per coding guidelines, “Add blank lines between logical steps in function bodies, including after setup or result bindings before control flow.”
🤖 Prompt for 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. In `@rust/src/tap_card/tap_signer_reader.rs` around lines 86 - 99, In TapSignerReader::connect, add blank lines after the transport-to-card result binding and after the certificate root result binding, separating each setup step from its following match or if control flow.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@rust/src/tap_card/tap_signer_reader.rs`:
- Around line 86-99: In TapSignerReader::connect, add blank lines after the
transport-to-card result binding and after the certificate root result binding,
separating each setup step from its following match or if control flow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1cef044d-dd8b-4eac-8c3a-63960e2b9855
⛔ Files ignored due to path filters (1)
rust/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
rust/Cargo.tomlrust/src/tap_card/tap_signer_reader.rs
Greptile SummaryThe PR authenticates TAPSIGNER cards against Coinkite factory roots during reader construction and rejects development certificates before retaining the card or issuing PIN-bearing commands.
Confidence Score: 5/5The PR appears safe to merge and strengthens the TAPSIGNER authentication boundary before sensitive commands are dispatched. Reader construction now validates the card’s factory certificate, rejects development roots, and stores only the verified wrapper; no concrete changed-code failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Mobile UI
participant Reader as TapSignerReader
participant Card as NFC TAPSIGNER
participant Root as Coinkite Factory Roots
UI->>Reader: create reader(command)
Reader->>Card: status
Card-->>Reader: card type and public key
Reader->>Card: certificate chain and check challenge
Card-->>Reader: certificate chain and signature
Reader->>Root: validate factory certificate
alt Production certificate is valid
Root-->>Reader: verified production root
Reader-->>UI: verified reader
UI->>Reader: run PIN-bearing command
Reader->>Card: authenticated command
else Invalid, missing, or development certificate
Root-->>Reader: reject
Reader-->>UI: connection error
end
Reviews (1): Last reviewed commit: "Verify factory certificate on TapSigner ..." | Re-trigger Greptile |
Summary
Root cause
Cove converted the unauthenticated card status response into a usable TAPSIGNER and did not call the certificate verification operation provided by
rust-cktap. A counterfeit card could therefore reach setup, import, or signing operations.Impact
Cove now checks card authenticity before it accepts a TAPSIGNER. A card with an invalid, missing, or development certificate cannot receive authenticated commands.
Verification
just fmtjust clippygit diff --checkSummary by CodeRabbit
Security
Bug Fixes