Repository navigation
Conversation
Inside a container, code execution uses the sandbox unless ALLOW_LOCAL_CODE_EXEC is set, so a leftover local setting does not run code in the application process. Password changes and revoking sessions drop the refresh token and reject access tokens issued before that second. MCP HTTP and SSE clients pin the address on each request. The first administrator is created only from setup with FIM_SETUP_TOKEN, and only one concurrent setup can succeed. Co-authored-by: Tao An <tao-hpu@users.noreply.github.com>
Access and refresh tokens now carry the account's session generation. Password changes, session revoke, and admin force-logout increment it, so a token issued in the same second is rejected. Tokens from before this column stay valid until the next sign-out or password change. Refresh rotation only commits when the generation is still the one it read. Co-authored-by: Tao An <tao-hpu@users.noreply.github.com>
A Python-side default was written into every INSERT, including rows built against a schema from before the column existed. The column stays NOT NULL with a server default of 0, so existing and new rows still start at 0. Co-authored-by: Tao An <tao-hpu@users.noreply.github.com>
Disabling an account now increments its session generation, the same cut password changes and revoke-all already use. Turning the account back on no longer accepts an access token issued before the disable. Co-authored-by: Tao An <tao-hpu@users.noreply.github.com>
10 of 13 tasks
This branch has not been deployed
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.
What
Hardens four defaults in the application and deployment entrypoint, with regression tests.
CODE_EXEC_BACKEND=localis ignored unlessALLOW_LOCAL_CODE_EXEC=true. Outside a container, unset still meanslocal.users.session_generationand clear the stored refresh token. Access and refresh tokens carry that value asgen. A token from an earlier generation is rejected, including one issued in the same second. Turning a disabled account back on does not restore tokens issued before the disable./refreshreplaces the stored refresh token only when both the presented hash and the generation it read are still current, so a password change in flight cannot leave a rotated session behind. Tokens issued before this version have nogenand keep working while the account is still at generation 0; the next sign-out, password change, or disable rejects them. Migrationg4c0e2f7a813adds the column (not null, server default 0) and fills existing rows with 0. Inserts that do not set the value leave it to that default, so a schema from before the column still accepts those rows.POST /api/auth/setup, which requiresFIM_SETUP_TOKEN. The setup page sends that value only in the request body, in a password field, and does not store it. Registration and provider sign-in cannot create that account. Concurrent setup calls take one database lock, so only one can succeed.Why
These paths were weaker than the documented deployment: in-process code execution could still be selected inside a container, a session could still be used after a password change, a self-serve sign-out, or re-enabling a disabled account, MCP HTTP connections checked the address only before connecting, and the first account could be created more than once without a setup secret.
Type
Checklist
uv run ruff check src/ tests/passes (the tree already has findings; this change does not take that on)uv run mypyon the edited auth modules — no issues26a41b6a(run 45635335205): Python 3.11, 3.12, and 3.13, Frontend, Docs links, and Workflow editor smoke passeden/andzh/(English docs and messages only; translation runs on master via i18n sync, and this environment has no translate key)g4c0e2f7a813upgrade, downgrade, upgrade on a disposable local SQLite database and on a disposable local PostgreSQL 16 database, including an existing user row backfilled to 0Operator notes
Set
FIM_SETUP_TOKENto a long random value before creating the first administrator, and enter it on the setup page. Instances that already have users are unchanged. Do not commit the token.Inside a container, remove a leftover
CODE_EXEC_BACKEND=localunless you also setALLOW_LOCAL_CODE_EXEC=true. The entrypoint otherwise starts the sandbox backend and waits for the proxy token. Outside a container,./start.shwithCODE_EXEC_BACKENDunset still runs code in the application process.Apply migration
g4c0e2f7a813with the usual startup migration. Existing sessions keep working until the next password change, sign-out of all sessions, or disable. Disabling an account signs its sessions out. Turning it back on does not restore tokens issued before the disable; sign in again. Requests are refused while the account is disabled.Dependency updates for Next.js, soupsieve, and opentelemetry-api are left to the existing pull requests and are not included here.