Repository navigation
fix(dashpay): refuse a contract-group-bound key registration - #1139
Conversation
`ManagedPlatformWallet.ContractBounds` grew a third case in the Swift SDK (dashpay/platform#4800), and the DPP-layer `ContractBounds` that `PlatformDashConnectDataSource.parse()` maps it into still has two, so the file stopped compiling against current `v4.2-dev`: PlatformDashConnectDataSource.swift:246:33: error: switch must be exhaustive note: add missing case: '.contractGroup(id: let id)' There is no correct arm to add. Dropping the bound would be wrong twice over: the value decides which approved app a scanned key registration belongs to, so a key whose bound is erased names no single app; and the same value is rebuilt into the `IdentityPubkey` handed back to `updateIdentity(...)`, so a silently weakened bound would mean signing a transition the dApp never asked for. A key bound to a contract group is never one of the login keys this flow derives, so refuse the transition instead — the same conclusion the SDK's own persistence seam reaches, and the reason dashpay/platform#4853 asks for the DPP-layer enum to model the bound end to end. The identity-key fixtures gain the protocol-14 limit fields (dashpay/platform#4798) so the test target builds against the same SDK. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe key-registration parser now rejects contract-group bounds instead of omitting them. The test helper now supplies the added ChangesKey registration validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
|
✅ Final review complete — no blockers (commit 61c3208) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified the supplied findings against head 61c3208 and the complete base-to-head diff. The throwing conversion rejects the entire registration before connection selection, key derivation, authorization, or identity-update submission; no blocking defect was identified. Both reviewers identified the same valid, non-blocking regression-test gap, consolidated below; this verification was static and did not independently establish build or runtime success.
🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: ffi-engineer); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
lowbygpt-6-astra(effort low) — The diff adds a straightforward rejection of an unsupported contract-bound enum case in PlatformWalletDashConnectStateTransitionParser.parse() and updates test fixture arguments, making it small and contained despite touching key-registration handling. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort high); agentphase1-reviewer,muse-spark-1.3-contributor— ffi-engineer (completed, effort high); agentphase1-reviewer,muse-spark-1.3-contributor— security-auditor (completed, effort high); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(zai below 15% reserve: 5h 100% left, weekly 13% left) - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort medium); agentphase2-reviewer,gpt-6-astra— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `DashWallet/Sources/Models/DashConnect/PlatformDashConnectDataSource.swift`:
- [SUGGESTION] DashWallet/Sources/Models/DashConnect/PlatformDashConnectDataSource.swift:254-266: Add a regression test for whole-transition contract-group refusal
The new `.contractGroup` refusal branch has no regression coverage: the existing parser tests cover supported identity updates and token purchases, while this PR's fixture changes only supply the new optional key-limit fields. Use the existing injected `parseTransition` closure to return an identity update containing a supported key followed by a contract-group-bound key, then assert that `parse` throws `DashConnectPlatformError.keyRegistrationUnexpectedMutation`. This directly protects the security-relevant guarantee that the entire registration is rejected rather than returning a partial key list or silently weakening a bound, without requiring a live dApp.
| case .contractGroup: | ||
| // The wallet layer reports a contract-group bound since the | ||
| // SDK's #4800, and the DPP-layer `ContractBounds` this maps | ||
| // into has no case for it (dashpay/platform#4853). Dropping | ||
| // the bound is not an option here: the value decides which | ||
| // approved app a key registration belongs to, and it is also | ||
| // rebuilt into the `IdentityPubkey` handed back to | ||
| // `updateIdentity(...)`, so a silently weakened bound would | ||
| // mean signing a transition the dApp did not ask for. A key | ||
| // bound to a contract group is never one of the login keys | ||
| // this flow derives, so refuse the transition instead. | ||
| throw DashConnectPlatformError.keyRegistrationUnexpectedMutation | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: Add a regression test for whole-transition contract-group refusal
The new .contractGroup refusal branch has no regression coverage: the existing parser tests cover supported identity updates and token purchases, while this PR's fixture changes only supply the new optional key-limit fields. Use the existing injected parseTransition closure to return an identity update containing a supported key followed by a contract-group-bound key, then assert that parse throws DashConnectPlatformError.keyRegistrationUnexpectedMutation. This directly protects the security-relevant guarantee that the entire registration is rejected rather than returning a partial key list or silently weakening a bound, without requiring a live dApp.
source: muse-spark-1.3-contributor (phase1-reviewer: general, ffi-engineer, security-auditor); gpt-6-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
llbartekll
left a comment
There was a problem hiding this comment.
Approving. Verified against packages/swift-sdk at 72b58f6073: the switch in parse() was the only app-side match over ManagedPlatformWallet.ContractBounds (the other two sites switch the DPP enum, which #4853 leaves at two cases), refusing rather than dropping the bound is correct since it both selects the pending connection and is rebuilt into the IdentityPubkey for updateIdentity, and the IdentityPublicKeyInfo fixture change matches the no-default memberwise init from #4798 in the right order. Note for anyone building develop after this merges: ../platform must be ≥ 5568dfa443 with a rebuilt xcframework.
Issue being fixed or feature implemented
dashpay/dashwallet-iosdevelopno longer compiles against currentpackages/swift-sdkonv4.2-dev.ManagedPlatformWallet.ContractBoundsgained a third case in dashpay/platform#4800 (5568dfa443) —contractGroup(id:), FFI kind 3 — while the DPP-layerContractBoundsthatPlatformDashConnectDataSource.parse()maps it into still has two:The SDK-side gap is filed as dashpay/platform#4853. This PR is only the app-side refusal, split out of #1138 so a build can take it without the Bluetooth login feature.
What was done?
parse()refuses a key registration that carries a contract-group bound, rather than mapping it to something it is not.There is no correct arm to add, and dropping the bound would be wrong twice over:
IdentityPubkeyhanded back toupdateIdentity(...), so a silently weakened bound would mean signing a transition the dApp never asked for.A key bound to a contract group is never one of the login keys this flow derives, so refusing is also the honest behaviour — the same conclusion the SDK's own
PersistentPublicKeyseam documents when it declines to project kind 3 as.singleContract.The identity-key fixtures in
PlatformDashConnectDataSourceTestsgain the protocol-14 limit fields (totalBudget,expiresAt, bothnil— dashpay/platform#4798) so the unit-test target builds against the same SDK.How Has This Been Tested?
Against
packages/swift-sdkonv4.2-devat72b58f6073,DashSDKFFI.xcframeworkrebuilt with./build_ios.sh --target sim:xcodebuild -workspace DashWallet.xcworkspace -scheme dashpay -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' ARCHS=arm64 build— BUILD SUCCEEDED (fails ondevelopwithout this change).build-for-testingon the unit-test target — TEST BUILD SUCCEEDED (fails without the fixture change).Not exercised at runtime: no dApp registers a contract-group-bound key today, so the refusal path has no live counterpart to try it against. The behaviour it replaces did not compile.
Breaking Changes
None for users. A key registration carrying a contract-group bound is now refused instead of failing to build; nothing in the shipped flows produces one.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit