Skip to content

feat: require a setup token to create the first user on a tunnel (#32324) - #32513

Merged
BobbyHo merged 1 commit into
release/2.39from
backport/32324-to-2.39
Nov 20, 2026
Merged

BobbyHo merged 1 commit into
release/2.39from
backport/32324-to-2.39

Conversation

@coder-backporter-app

@coder-backporter-app coder-backporter-app Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Backport of #32324

Original PR: #32324 — feat: require a setup token to create the first user on a tunnel
Merge commit: 88d3494
Requested by: @BobbyHo

The automatic cherry-pick had conflicts. They are resolved by hand; the server and CLI changes are the same as in #32324.

Differences from #32324
  • scripts/develop: keeps this branch's password handling and adds only the setup token. password_test.go is left out because it comes from fix: generate per-instance dev passwords and remove the shared default #32283, which is not on this branch.
  • Docs: the setup token sentences for docs/install/index.md and docs/install/server/rpm.md are left out. Those pages do not mention the tunnel on this branch.

@coder-backporter-app coder-backporter-app Bot added the backport/v2.39 Backport PR targeting release/2.39 label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @coder-backporter-app[bot]!

This PR is targeting the release/2.39 release branch, but its title does not start with fix: or fix(scope):.

Only bug fixes should be cherry-picked to release branches. If this is a bug fix, please update the PR title to match the conventional commit format:

fix: description of the bug fix
fix(scope): description of the bug fix

If this is not a bug fix, it likely should not target a release branch.

)

fix(security): require setup token for first user on tunnels

Prevent unauthorized users from claiming Owner access on public `try.coder.app` tunnels before initial setup.

- Generate a setup token at startup when using a tunnel with no existing users.
- Require the token for first-user creation via the API, web UI, and CLI.
- Block GitHub/OIDC first-user signup until setup is complete.
- Support custom tokens via `--setup-token` / `CODER_SETUP_TOKEN` and non-interactive CLI setup.
- Update development scripts, documentation, and tests.
- Preserve existing behavior for deployments with an access URL or existing users.

Validated with automated tests and 23/23 manual scenarios using a real tunnel.

Refs CORE-784

(cherry picked from commit 88d3494)
@BobbyHo
BobbyHo force-pushed the backport/32324-to-2.39 branch from d08c343 to 00317ca Compare November 20, 2026 15:42
@BobbyHo BobbyHo changed the title feat: require a setup token to create the first user on a tunnel (#32324) (conflicts) feat: require a setup token to create the first user on a tunnel (#32324) Nov 20, 2026
@BobbyHo

BobbyHo commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

/coder-agents-review Please limit the review to P0, P1, and P2 issues only.

@coder-agents-review

coder-agents-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-11-20 18:28 UTC by @BobbyHo
Spend: $11.60 / $100.00

Review history
  • R1 (2026-11-20): 15 reviewers, COMMENT. Review

deep-review v0.13.0 | Round 1 | 8208ee1..00317ca

Last posted: Round 1, no findings, COMMENT. Review

Finding inventory

Finding inventory, PR #32513

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Dropped by orchestrator (operator requested P0-P2 only) -scripts/develop/password_test.go Backport drops the SendsSetupToken test; the test does not depend on #32283 R1 Netero No
CRF-2 P3 Dropped by orchestrator (site/AGENTS.md FE1 forbids assertions in play functions) site/src/pages/SetupPage/SetupPageView.stories.tsx:49 SetupTokenRefused play function has no expect R1 Netero No
CRF-3 P3 Dropped by orchestrator (operator requested P0-P2 only) coderd/userauth.go:1784 Tunnel plus DisablePasswordAuth: OAuth first sign-up refused, setup page creates an owner that cannot sign in R1 Pen Botter No
CRF-4 P3 Dropped by orchestrator (operator requested P0-P2 only) cli/login.go:261 Non-interactive coder login without --first-user-setup-token fails with bare EOF R1 Pen Botter No
CRF-5 P3 Dropped by orchestrator (operator requested P0-P2 only) site/src/pages/SetupPage/SetupPageView.tsx:79 Failed authmethods request hides the setup token field on a tunnel R1 Nami No
CRF-6 P3 Dropped by orchestrator (operator requested P0-P2 only) coderd/setuptoken.go:30 Messages say the server prints the token, but a supplied token is not printed R1 Gon No
CRF-7 P3 Dropped by orchestrator (operator requested P0-P2 only) cli/server.go:1044 No test covers the resolveSetupToken call with tunnel != nil in coder server R1 Bisky No
CRF-8 P3 Dropped by orchestrator (operator requested P0-P2 only) cli/setuptoken.go:17 142-bit claim holds only for random tokens, not operator-supplied ones R1 Gon No
CRF-9 P3 Dropped by orchestrator (operator requested P0-P2 only) cli/setuptoken.go:64 Generated token length 32 is a bare literal repeated in three files R1 Gon No
CRF-10 P4 Dropped by orchestrator (downgraded from P2: purpose clause states the real ordering; below operator threshold) cli/login.go:253 Comment says token is asked first; username and name are asked before it R1 Gon No
CRF-11 Nit Dropped by orchestrator (downgraded from P2: comment bloat, no behavior; below operator threshold) cli/setuptoken.go:53 First comment sentence restates the code R1 Gon No
CRF-12 Nit Dropped by orchestrator (downgraded from P2: comment bloat, no behavior; below operator threshold) scripts/develop/main.go:812 serverCmd comment restates the function name R1 Gon No
CRF-13 Nit Dropped by orchestrator (downgraded from P2: test field naming; below operator threshold) cli/setuptoken_internal_test.go:26 Test field users should be userCount R1 Gon No
CRF-14 P4 Dropped by orchestrator (operator requested P0-P2 only) codersdk/deployment.go:4001 Help text hard-codes the 24-character minimum R1 Gon No
CRF-15 Nit Dropped by orchestrator (operator requested P0-P2 only) coderd/setuptoken.go:39 errSetupNotComplete name reads as a sentinel error R1 Gon No
CRF-16 Nit Dropped by orchestrator (operator requested P0-P2 only) site/src/pages/SetupPage/SetupPageView.tsx:44 validationSchema is now a function with a noun name R1 Gon No
CRF-17 P4 Dropped by orchestrator (operator requested P0-P2 only) coderd/setuptoken.go:22 Web client trims the token, CLI and server do not R1 Melody No
CRF-18 P4 Dropped by orchestrator (operator requested P0-P2 only) coderd/setuptoken.go:18 Comment says hashing time does not depend on len(got) R1 Razor No
CRF-19 P4 Dropped by orchestrator (operator requested P0-P2 only) cli/setuptoken_internal_test.go:149 ptrInt64 helper replaceable by new(expr) R1 Ging-Go No
CRF-20 P4 Dropped by orchestrator (operator requested P0-P2 only) docs/install/cli.md:44 Tunnel docs pages do not mention the setup token (also docs/admin/setup/index.md:20) R1 Pen Botter, Pariston No
CRF-21 Note Dropped by orchestrator (operator requested P0-P2 only) coderd/userauth.go:825 setup_token_required stays true after the first user exists until restart R1 Luffy, Melody, Ryosuke, Pariston No
CRF-22 Note Dropped by orchestrator (operator requested P0-P2 only) docs/install/server/cloud/compute-engine.md:50 journalctl lines do not start with "Setup token:" R1 Pen Botter No
CRF-23 OOS Out of scope (body) site/src/pages/SetupPage/SetupPage.tsx:37 SetupPage has no error state for a failed authmethods query on any deployment R1 Nami No

Contested and acknowledged

None.

Round log

Round 1

Round type: round 1, full panel. Netero first pass: 2 P3, no P0, panel proceeded. Law not run (effective additions 764).
Panel (15): ging-go, ging-ts, ging-react, kurapika, luffy, melody, nami, pen-botter, ryosuke (domain specialists), pariston, mafuuu (core), gon, leorio (round 1 floor), bisky (tests changed), razor (wildcard). Size above the 9-12 target because nine domain specialists were triggered: ging-go, ging-ts, ging-react, kurapika, luffy, melody, nami, pen-botter, ryosuke.
Operator instruction on the PR (BobbyHo): limit the review to P0, P1, and P2. Result after cross-check: no P0, P1, or P2 findings; 9 P3, 6 P4, 5 Nit, 2 Note held back; 1 out of scope.
Backport parity verified by orchestrator: per-file sorted +/- line comparison of 88d3494^..88d3494 against 8208ee1..00317ca differs only in docs/install/index.md, docs/install/server/rpm.md, scripts/develop/password_test.go (all declared in the PR body) and scripts/develop/main.go (password vs cfg.password, release-branch password handling).
Downgrade gate for Gon P2s: CRF-10 keep-argument: "first" is literally false since username and name prompts precede it; drop reason: the purpose clause in the same sentence states the real contract (token before email and password), no behavior is wrong, and the text matches main verbatim. CRF-11, CRF-12, CRF-13 keep-argument: bloat and naming cost readers time; drop reason: no behavior consequence, convention-level only.
CRF-2 drop gate: keep-argument: the story passes if the field error stops rendering; drop reason: site/AGENTS.md FE1 says play functions must not assert behavior, and the Pixel screenshot captures the error state (Bisky).
CRF-3 severity test: upward case: the PR removes the only working first-owner path for tunnel plus DisablePasswordAuth and the setup page silently creates an owner that cannot sign in; downward case: only fresh tunnel deployments with password auth disabled, recoverable by restarting with password auth enabled. Kept at P3.
Reviewed against 8208ee1..00317ca.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR backports #32324, which requires a setup token to create the first user when coder server opens a try.coder.app tunnel. No P0, P1, or P2 findings. As requested, findings below P2 are not posted.

The added and removed lines match #32324 file by file, except for the four files named in the description (docs/install/index.md, docs/install/server/rpm.md, scripts/develop/password_test.go, and cfg.password in scripts/develop/main.go).

Out of scope (needs a ticket or explicit acceptance by a human):

  • site/src/pages/SetupPage/SetupPage.tsx:37: SetupPage renders the form when the authmethods query fails, so the page silently drops the auth options that the response would have enabled.

🤖 This review was automatically generated with Coder Agents.

@BobbyHo
BobbyHo merged commit dbab9ed into release/2.39 Nov 20, 2026
59 of 61 checks passed
@BobbyHo
BobbyHo deleted the backport/32324-to-2.39 branch November 20, 2026 21:24

This branch had an error being deployed

1 failed deployment
docs-preview — 00317cac Deployed Nov 20, 2026 by BobbyHo via cleanup #314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.39 Backport PR targeting release/2.39

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants