Repository navigation
fix(wallet): grant no biometric allowance without a stored spending limit - #1356
Conversation
A PIN entry now restores the biometric allowance only from a stored limit; with no stored limit there is no allowance and a spend asks for the PIN. A limit of 0 now resets the allowance to 0 on PIN entry instead of leaving the previous value. The allowance rules are pure functions with unit tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pre-merge checks:
|
|
✅ Final review complete — no blockers (commit e2bbd84) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification of head e2bbd84 found no actionable in-scope code defects: the allowance check rejects an unset spending limit, and PIN verification resets absent or zero limits to zero allowance. Current CI reports passing simulator tests, target-membership validation, workflow lint, and accessibility checks; no local builds or tests were run. The only failed check is PR-title validation because auth is not an allowed scope; renaming the title to fix(wallet): … addresses that metadata-only failure.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff makes a small, contained change to biometric allowance checks and PIN-entry resets with focused tests, rather than a large or intricate change to a critical surface. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 87% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); agentphase2-reviewer
romchornyi
left a comment
There was a problem hiding this comment.
✅ no major · 1 untracked gap · 4 non-blocking recommendations · no blockers — reviewed at e2bbd84691
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | Real hole: with no stored limit a PIN entry wrote UInt64.max as the allowance, so biometrics covered any amount. Failing closed is the right call. |
| 2 · Architecture | ✅ right layer | The decision stays in AuthenticationService. |
| 3 · Completeness | 🟡 untracked gap | Spend gates that pass no amount never consult the allowance (below). |
| 4 · Code | ✅ clean | The hole is closed on both sides (refill writes 0; an existing -1 allowance with no limit is refused). No sentinel collision: only 0 / 0.1 / 0.5 / 1 / 5 DASH are ever stored. didAuthenticate is set before the reset. No lockout: the user leaves the state via the biometrics toggle, the Advanced Security slider or Reset to Default. |
Untracked gap — please file an issue: several spend gates call AuthenticationGate.authenticate without spendAmount, so the biometric limit (including this PR's "no limit ⇒ PIN" rule and a limit of 0, which the UI describes as "PIN is always required") does not apply there; biometrics authorize any amount:
- andvia
authenticateSpend( ) - (gift-card purchases)
- (identity funding)
4 non-blocking recommendations
- The spend check now runs the legacy limit migration — —
canUseBiometricAuthenticationreadsbiometricSpendingLimit, which migratesSPEND_LIMIT_AMOUNTon read and rewrites.biometricAmountLeftto the full limit ( ). With a legacy UserDefaults limit and a Face-ID-only session, the allowance is read first (stale) and then refilled, so the next spend passes without a PIN. One-time and capped at the user's own limit; reading the limit without the migration side effect here would avoid it. - Advanced Security misdescribes the "no stored limit" state —
DWAdvancedSecurityModeltreatsUINT64_MAXas no confirmation needed, while spends now always ask for the PIN (the slider index is alsoNSNotFound, as on base). (partly verified) - The root cause sits in the enable paths —
DWBiometricAuthModelandSecurityMenuViewModelignore the result ofsetBiometricSpendingLimitIfAuthenticated, which is how "biometrics on, no limit" arises; those users now silently lose biometric spending. Restoring the 0.5 DASH default on PIN entry when biometrics are enabled and no limit is stored would be the sturdier fix. (not verified) - Tests cover only the two static helpers —
— restoring the old
if limit > 0body inresetSpendingLimitsIfAuthenticatedkeeps all 7 green; a test throughinit(secureTime:userDefaults:)covering the instance wiring would pin it.
Review details
Layered review: idea → architecture → completeness → code. Level 4 ran the general correctness lane and a security/funds lane covering every reader and writer of .spendingLimit / .biometricAmountLeft, the legacy migration and upgrade states. The gap list and recommendations 1 and 4 were verified against the code.
🤖 Reviewed with Claude Code
|
Filed #1381 for the spend confirmations that skip the limit. |
Summary
allowanceAfterPinEntry,biometricAllowanceCovers) are pure functions, covered byBiometricAllowanceTests.Regular limits are unchanged: with a 0.5 DASH limit, a PIN entry restores 0.5 DASH, and the legacy UserDefaults limit migration works as before.
Test plan
BiometricAllowanceTests(7) andAuthenticationGateTestspasscheck_test_target_membership.pypasses🤖 Generated with Claude Code