Repository navigation
fix(profiles): store requested PIN atomically on creation - #2708
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The Suggested replacement: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Quick104
left a comment
There was a problem hiding this comment.
Review of 2012545 (PIN in the create transaction, v1 byte limit, docs, tests). One low-severity test finding, inline. I'm fixing it in a commit on this branch, so there's no need to change it yourself.
I found no defect in the production change. Both stores already insert pin_hash from the profile, so the hash is in the first committed row on Postgres and SQLite. A PIN profile now starts at PIN revision 0 instead of 1; token checks compare the revision for equality and the profile ID is new, so no earlier proof can match it. Dropping the follow-up UpdateProfile also drops a Postgres access_policy_revision bump, which only invalidated the household's existing theme-song grants as a side effect. The summary comment follows once the fix is pushed and checked on a sandbox.
AI disclosure: reviewed with Claude Code (claude-opus-5-5) and Claude subagents, with an independent read-only pass by Codex (gpt-6.1-sol, xhigh), which reported no findings.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summaryFit: 9/10 · Readiness: 9/10 — ready Reviewed head: 196fbdf (findings reviewed at 2012545, plus the one test fix below). A profile created with a PIN is now protected from its first committed state, and an overlong v1 PIN no longer leaves an unlocked profile behind. I found no defect in the production change. Findings
Verification
Remaining notes (not blocking)
Validated features
Other checks
Scores
AI disclosure: review by Claude Code ( |
Problem
Closes #2707
Related issue: #1179
Validation tasks: changes #1180 C1
Creating a profile with a PIN commits an unlocked row before storing its hash. A concurrent household caller can select that row without proof. Through v1, a PIN longer than bcrypt's 72-byte limit also leaves the profile unlocked after the request fails.
The requested PIN now protects the profile from its first committed state, and invalid input leaves no profile behind.
Approach
Hash the PIN before opening the existing profile/preferences transaction and include it in the initial insert. Reject overlong PINs in the shared handler. V1 returns 400
bad_request; v2 retains its existing 422validation_failedresponse. Successful contracts stay the same.Apple and Android already send the PIN in the create request. Jellyfin reads the same stored hash. No client changes are needed. The user manual already promises this protection; developer API documentation records the atomicity and byte limit.
Validation
365e3d436fc2and confirmed the fix at2012545299d5. Invalid ASCII/UTF-8 inputs leave no row; valid PINs deny missing proof, reject wrong PINs, and accept correct proof. Intentional PIN-less profiles remain unlocked.read:project. No human acceptance or board update is claimed.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-2707/
Risks
New protected profiles start with PIN revision 0. Fresh profile IDs and the existing account/session/profile/revision binding keep proofs scoped correctly; subsequent PIN changes retain revision invalidation.
PR #2704 separately guards household authority freshness. Its patch applies cleanly over this change; preserve its transaction guard when integrating either order. This PR does not include that fix.
The
show_forced_subtitles: falsewrite in the same function still runs after the create transaction commits. It predates this PR and is tracked in #2743, whose fix should follow this one.Checklist
AI Disclosure
claudeAgent) for cross-provider reviews.gpt-6.1-sol(xhigh) for implementation and independent code review;claude-opus-5-5(high) for plan and adversarial review.claude-opus-5-5reproduced the failing tests and checked the plan, including initial PIN revision safety and both stores; no blocking objections. Independentgpt-6.1-solreviews checked callers, contracts, failure boundaries, tests, and validation impact with no findings at67cc03455; final201254529only flattens test assertions. Backgroundclaude-opus-5-5review checked the complete final diff at201254529, traced transaction/revision/contract behavior through both stores, and passed focused race tests. It found no defects introduced by this change and posted nothing./siloreview with Claude Code (claude-opus-5-5) and Claude subagents, plus a read-only Codex pass (gpt-6.1-sol, xhigh). It traced both stores, token revision checks, the v1/v2 contract, and the tests. One low finding (a test assertion that only exercised bcrypt) was fixed in 196fbdf; Codex reported no findings. A pre-existing partial write was filed as [bug] Profile creation with show_forced_subtitles false can return 500 after committing the profile #2743.