Repository navigation
feat(stack): run native PostgreSQL as a non-root user when started as root - #6823
Merged
Merged
Conversation
… root Native PostgreSQL refuses uid 0, so agent sandboxes that run as root could not start the native stack. When the stack runs as root inside a detected Claude Code sandbox, or SUPABASE_NATIVE_POSTGRES_USER names a non-root user, only the PostgreSQL process now runs as that user. The stack verifies the instance path is root-controlled, hands the data directory, key, socket, and the bundle's getkey script to the user, and adds traverse-only access on their parent directories, logging each change. Root elsewhere still fails fast, and `stack prepare` no longer refuses root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…root-fallback-938526 # Conflicts: # packages/stack/src/runtime/NativeProcess.ts # packages/stack/src/runtime/native-launcher.ts # packages/stack/src/services/Database.ts
Contributor
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@42ef8e6fac4686aa20ef4c0117eeb3bacb2be16bPreview package for commit |
jgoux
requested changes
Sep 25, 2026
jgoux
left a comment
Contributor
There was a problem hiding this comment.
The native root startup path loses PostgreSQL bundle access when another service or database tool prepares an artifact. The inline finding includes the verified call path and reproduction.
… shared roots Artifact preparation and state loading reset the artifact cache root, each artifact directory, and the stack state root to 0700. Once another service was prepared after PostgreSQL launched as a non-root user, the server could no longer reach its own bundle, so new sessions failed to load session_preload_libraries with `could not access file "supautils"`, and a config reload could not read postgresql.conf. Those roots now stay restricted to their owner while keeping an existing traverse-only grant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01REDom2C1Z1DUi2df7xGMMv
jgoux
self-requested a review
September 25, 2026 10:29
jgoux
approved these changes
Sep 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 25, 2026
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.
Summary
TL;DR:
supabase start --runtime nativeno longer fails immediately when it runs as root inside an agent sandbox. Only the PostgreSQL process steps down to a non-root user, so agents can start the native stack on the first try. Root outside a detected sandbox still fails fast unlessSUPABASE_NATIVE_POSTGRES_USERnames a user.Before
After
flowchart TD A[native start as uid 0] --> O{SUPABASE_NATIVE_POSTGRES_USER?} O -->|valid user| S[PostgreSQL runs as that user] O -->|unset| B{Claude Code sandbox?} B -->|no| E[fail fast, suggest the override] B -->|yes| P[ubuntu, else postgres,<br/>else lowest uid >= 1000] P --> SWhy
Agent sandboxes such as Claude Code's cloud environment run as root by default and provide ordinary non-root accounts. The native runtime refused to start there with
PostgreSQL cannot be run as root, so agents had to set up a separate user by hand before the stack could run.What changed
SUPABASE_NATIVE_POSTGRES_USERoverride first, then a per-sandbox preferred user list (ubuntufor Claude Code, detected viaCLAUDECODEandIS_SANDBOX=yes), thenpostgres, then the lowest uid at or above 1000. Accounts with uid 0, gid 0, ornobodyare never used. Other agent sandboxes can be added as one table entry.uid/gid, cwd/, and the user'sHOME. Every other service keeps the stack's identity.pgsodium_getkey.shto the user withchown -R -P;o+xto their parent directories, including root's home, logging each change.0700. Without this, preparing another service after PostgreSQL launched cut the stepped-down server off from its own bundle and data directory: new sessions failed withcould not access file "supautils"and config reloads could not readpostgresql.conf.startprints one line naming the user PostgreSQL runs as and why.Database.prepareno longer refuses root, sosupabase stack prepareworks in root Dockerfiles.startside-effects doc describe the new behavior and the environment variable.Linked issue
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01REDom2C1Z1DUi2df7xGMMv