Repository navigation
fix(admin-pin): changing or removing the PIN takes the current one - #350
Merged
Merged
Conversation
Until now POST /api/admin-pin/set and DELETE /api/admin-pin asked for
nothing, so anyone on the home network could remove or replace the PIN,
and with it the guard on backups, restores and Home Assistant unlocks.
- set takes { currentPin } when a PIN exists; DELETE takes { pin }.
Both share the wrong-guess limit (403, then 429).
- The Admin Panel asks for the current PIN before Update or Remove,
even on a display that remembers it.
- A forgotten PIN is reset on the server itself: reset-admin-pin.js
(npm run reset-pin), shipped in the backend image. The PIN prompt
and Admin -> Security point to the deployment guide's new section.
- utils/dbPath.js: the server and the script open the same file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
POST /api/admin-pin/setandDELETE /api/admin-pindidn't check anything. Anyone on the home network could remove or replace the admin PIN, for example:The PIN guards backup export (which includes the encryption key), restores and rollbacks, and Home Assistant unlock, disarm and garage-door actions. All of that went with it.
What changes
{ pin, currentPin }.{ pin }.server/reset-admin-pin.js(npm run reset-pin). It is in the backend image;server/scripts/is excluded from Docker builds, so it lives next toindex.js.docs/guides/deployment.md.server/utils/dbPath.jsis shared by the server and the script, so both open the same database file.Testing
npm test: 667/667.adminPinRoutes.test.jsnow covers:vitest832/832;check:i18nandbuildare clean..dockerignore, and/appis the image's working directory.🤖 Generated with Claude Code