Repository navigation
Conversation
`scripts/develop.sh` waits a fixed 60 seconds for the API server's `/healthz` after it starts the server, then fails with `server did not become ready in 1m0s`. A cold first start (a new `.coderv2`, embedded Postgres setup and migrations) can take about 61 to 64 seconds on a shared host, so the first launch fails even though the server comes up a moment later. This adds `--health-timeout` (`CODER_DEV_HEALTH_TIMEOUT`), a duration that sets that wait. The default stays 60 seconds. A value that is zero or negative is refused before anything starts. The timeout error names the configured value. `.claude/docs/DEV_ISOLATION.md` lists the flag.
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (2)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d0ae28e58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if c.healthTimeout <= 0 { | ||
| return xerrors.Errorf("--health-timeout must be greater than zero, got %s", c.healthTimeout) |
There was a problem hiding this comment.
Reject health timeouts shorter than the polling interval
When --health-timeout is any positive value below 500ms, this validation accepts it, but poll does not invoke the /healthz predicate until its 500ms ticker fires (scripts/develop/main.go:647-655). The timeout therefore expires without making a single request, even if the server is already healthy. Either enforce a minimum timeout of 500ms or perform the first health check immediately.
AGENTS.md reference: AGENTS.md:L20-L20
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f7620e2. waitForHealthy now sends its first /healthz request at once, before it waits for the 500 ms poll tick, so a timeout below 500 ms still reaches a server that is already healthy. poll and its other caller are unchanged. TestWaitForHealthyImmediate covers a healthy test server with a 100 ms timeout. It fails when I restore the poll-only behavior.
| By default, the script waits 60 seconds for the API server's `/healthz` after it | ||
| starts the server, then exits with an error. A cold first start (a new | ||
| `.coderv2`, embedded Postgres setup and migrations) can take longer. Pass | ||
| `--health-timeout 3m` to wait longer. The value must be greater than zero. |
There was a problem hiding this comment.
Update the readiness section for configured timeouts
Adding the configurable timeout here leaves the same guide's readiness section at lines 112-114 claiming that the script waits for /healthz for at most 60 seconds. When an agent follows this example and passes --health-timeout 3m, that statement is false and can lead it to diagnose or interrupt a still-valid startup at the old deadline; describe 60 seconds as the default there and mention the configured override.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f7620e2. The "Readiness without new probes" section of .claude/docs/DEV_ISOLATION.md now says the wait is up to 60 seconds by default and names --health-timeout to change it.
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
`waitForHealthy` waited for the first 500 ms poll tick before its first `/healthz` request. A `--health-timeout` below 500 ms therefore ended without a single request, even when the server was already healthy. The first request now runs at once, and `poll` keeps its behavior for its other callers. The "Readiness without new probes" section of `.claude/docs/DEV_ISOLATION.md` now says that 60 seconds is the default and names `--health-timeout`.
`waitForHealthy` took the timeout as a parameter, so `develop()` could pass a value other than `cfg.healthTimeout` and no test would notice. It now takes the `*devConfig` and reads `cfg.healthTimeout` itself. The two `waitForHealthy` tests build a config. The flag table intro in `.claude/docs/DEV_ISOLATION.md` no longer calls the flags "existing", because the table now lists `--health-timeout`.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7620e2229
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cfg := &devConfig{healthTimeout: 100 * time.Millisecond} | ||
| err := waitForHealthy(ctx, logger, cfg, srv.URL) |
There was a problem hiding this comment.
Replace the real-time health deadline with a mock clock
When a parallel CI worker is delayed for more than 100 ms, the real localhost request can miss this deadline even though the test server is healthy, making TestWaitForHealthyImmediate flaky under load; the adjacent timeout test similarly waits on an actual 10 ms deadline. Inject a Quartz mock clock and advance it explicitly so these tests verify polling and deadline behavior without depending on scheduler timing.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1ba69ca. waitForHealthy now takes a quartz.Clock for its deadline and its poll ticks, and develop() passes the real clock, so the production behavior is the same. TestWaitForHealthyImmediate never advances the mock clock. TestWaitForHealthyTimeout traps the deadline timer and the ticker, advances one poll tick at a time, and then advances to the deadline. Neither test has a real-time deadline left.
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
The `waitForHealthy` tests ran on real 100 ms and 10 ms deadlines, so a delayed CI worker could end a wait before its probe ran. `waitForHealthy` now takes a `quartz.Clock` for the deadline and the poll ticks, and `develop()` passes the real clock. The deadline is a clock timer that cancels the wait with `context.DeadlineExceeded`, so the error text and the wrapped error are the same as with a context deadline. `poll` keeps its signature and its real ticker, and a new `pollWithClock` takes the clock. `TestWaitForHealthyImmediate` never advances the mock clock. `TestWaitForHealthyTimeout` traps the deadline timer and the ticker, advances one poll tick at a time, and then advances to the deadline.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 1ba69ca7e1
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| // once, so a server that is already healthy is found even when the | ||
| // timeout is shorter than the poll interval. | ||
| var err error | ||
| if !healthy(ctx) { |
There was a problem hiding this comment.
🛡️ Codex Security Review
Security: Verify child ownership before accepting health
On a shared host, if a lower-privileged user occupies the selected API port and setup reaches them before the new child reports its bind failure, they can spoof /api/v2/buildinfo and /healthz. This new synchronous call accepts that listener before the launched Coder process proves port ownership; normal setup can then send the persisted Coder-Session-Token or a configured first-user password to it. Treat every pre-existing listener as a conflict and require an authenticated child-instance signal before credential-bearing setup. Credential theft is an explicit security concern.
SECURITY.md reference: SECURITY.md:L13-L15
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0ed6a92. Before setup sends the saved session token or the admin password, it now reads /proc/net/tcp and /proc/net/tcp6 for the sockets that listen on the API port and refuses with an error that names the port and the uid when one of them belongs to another OS user. The check runs on Linux only.
There was a problem hiding this comment.
Documentation re-review after the new commits. Both prior Codex findings this PR addressed also closed the two docs gaps a previous doc-check pass would have raised: the "Readiness without new probes" section no longer contradicts the new --health-timeout paragraph. One suggestion survives verification; see the summary comment for the full trace.
| agents connect through `host.docker.internal`. | ||
|
|
||
| By default, the script waits 60 seconds for the API server's `/healthz` after it | ||
| starts the server, then exits with an error. A cold first start (a new |
There was a problem hiding this comment.
The paragraph says the script "exits with an error" on timeout but doesn't say the error names the configured duration, so a reader can't predict what the failure looks like when deciding whether to raise --health-timeout (Newcomer).
Evidence: scripts/develop/main.go:973 formats the error as "server did not become ready in %s: %w" with cfg.healthTimeout interpolated, e.g. server did not become ready in 1m0s for the default.
| starts the server, then exits with an error. A cold first start (a new | |
| By default, the script waits 60 seconds for the API server's `/healthz` after it | |
| starts the server, then exits with an error naming the configured timeout (for | |
| example, `server did not become ready in 1m0s`). A cold first start (a new | |
| `.coderv2`, embedded Postgres setup and migrations) can take longer. Pass | |
| `--health-timeout 3m` to wait longer. The value must be greater than zero. |
There was a problem hiding this comment.
Fixed in 09c4a91. The paragraph now says that the error names the configured timeout, with the example server did not become ready in 1m0s.
Documentation CheckRe-review of PR #31968 after new commits (head Previously raised, now resolved
Suggestions
Related open PRsNone found that would change a claim in this PR. Findings for agents- id: learner-2
persona: learner
class: suggestion
file: .claude/docs/DEV_ISOLATION.md
line: 58
quote: "then exits with an error."
evidence:
- scripts/develop/main.go:973
rule: null
problem: An agent debugging a timeout doesn't learn from the page that the error message names the configured timeout value, so it can't predict what the failure text looks like.
fix: "then exits with an error naming the configured timeout (for example, \"server did not become ready in 1m0s\")."
verified: trueAutomated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong. |
Setup sends the saved session token and the admin password to the API port. On a shared host, another OS user can bind that port before the server that develop started, and then read those credentials. Before the first request, setup now reads `/proc/net/tcp` and `/proc/net/tcp6` for the sockets that listen on the API port and accept connections to 127.0.0.1. It refuses, with an error that names the port and the uid, when one of them belongs to another uid than the one that runs develop. When it finds no listener or cannot read the tables, it logs a warning and continues. On a host other than Linux it skips the check. A pure parser works on the table text, and a thin reader feeds it.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ed6a9258d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var loopbackListenAddrs = map[string]bool{ | ||
| "0100007F": true, | ||
| "00000000": true, | ||
| "00000000000000000000000000000000": true, |
There was a problem hiding this comment.
Ignore IPv6-only wildcard listeners
When another user owns an IPv6-only [::]:<api-port> listener while develop's server owns the IPv4 listener on the same port, Linux permits both sockets, but /proc/net/tcp6 does not indicate IPV6_V6ONLY. This entry therefore misclassifies the unrelated IPv6-only socket as accepting connections to 127.0.0.1; checkAPIListener sees its foreign UID and aborts setup even though every API request goes to develop's own IPv4 socket. Avoid treating every IPv6 wildcard listener as IPv4-capable without confirming that it is dual-stack.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 09c4a91. When a socket of the uid that runs develop listens on 127.0.0.1 or 0.0.0.0 on the API port, the check now ignores sockets on ::. Linux refuses a dual-stack socket next to an IPv4 listener, so such a socket must be IPv6-only and gets no request. A foreign IPv4 socket or a foreign ::ffff:127.0.0.1 socket still makes setup refuse, and so does a foreign :: socket when no own IPv4 socket listens on the port.
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 0ed6a9258d
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| case errors.Is(err, errListenerCheckUnsupported): | ||
| logger.Debug(ctx, "skipping API listener ownership check", | ||
| slog.F("goos", runtime.GOOS), slog.F("api_port", port)) | ||
| return nil |
There was a problem hiding this comment.
🛡️ Codex Security Review
Security: Fail closed when listener ownership cannot be checked
On a non-Linux host where a lower-privileged local user can hold the configured API port, this branch treats errListenerCheckUnsupported as successful verification. The attacker can spoof /api/v2/buildinfo and /healthz; setup may then send the saved Coder-Session-Token or admin password before the asynchronously started child reports its bind failure. Fresh evidence after the prior thread is that the new mitigation explicitly returns nil for every non-Linux host, as well as lookup errors or no listener. Fail closed or authenticate the exact child before any setup request. Credential theft is in scope.
SECURITY.md reference: SECURITY.md:L13-L15
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I am declining this one. The check is meant to skip on a host without /proc/net/tcp, because failing closed there would refuse every macOS developer. When the check finds no listener, it warns and continues. A listener that another account holds in the same network namespace shows up in /proc/net/tcp, so a missing row means that no other account holds the port. A read error on Linux also keeps the warning, so a sandbox without /proc/net still works. On Linux, a listener of another uid on the API port is refused before setup sends anything.
The API port check treated every socket on `::` as able to take a connection to 127.0.0.1. `/proc/net/tcp6` does not show `IPV6_V6ONLY`, so an IPv6-only socket of another user next to develop's own IPv4 listener made setup refuse, although every request goes to develop's own socket. Linux refuses a dual-stack socket on a port that an IPv4 socket listens on, so when a socket of the uid that runs develop listens on 127.0.0.1 or 0.0.0.0 on the port, any socket on `::` must be IPv6-only and no longer counts. A foreign IPv4 socket and a foreign `::ffff:127.0.0.1` socket still make setup refuse, and so does a foreign `::` socket when no own IPv4 socket listens on the port. The docs paragraph about `--health-timeout` now says that the timeout error names the configured timeout.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
… API port The API port check matched the local addresses of the socket table against a fixed list of strings. A socket of another user on `::ffff:0.0.0.0` takes connections to 127.0.0.1, but it was not in the list. The check then found no listener, logged a warning and let setup send the saved session token and the admin password to it. The check now decodes each local address, with the 32-bit words in host byte order, and counts a socket when it listens on 127.0.0.1 or 0.0.0.0, on `::`, or on the IPv4-mapped form of 127.0.0.1 or 0.0.0.0. The rule that ignores sockets on `::` next to an own IPv4 listener keeps its scope and does not hide an IPv4-mapped socket. The tests also catch more regressions. The unsupported-host case now checks for the `[warn]` marker that sloghuman prints. A canceled parent context must give an error that wraps `context.Canceled`. The probe handler of the timeout test never blocks, so a real-clock regression fails within the test timeout.
|
Pushed 65a4460. It answers a verifier finding on 09c4a91: a socket of another user on the IPv4-mapped wildcard address |
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
ethanndickson
left a comment
There was a problem hiding this comment.
Could we drop the listener check (listener.go, listener_test.go and the call in setupFirstUser)? I don't think it protects against anything real, and it adds about 600 lines of /proc/net/tcp parsing and IPv6 dual-stack rules that we then have to maintain.
The race it closes is real on paper: another OS user binds the API port after the port check and before coder server binds, then receives the saved token or the admin password. But that attacker doesn't need the race:
- The dev server listens on all interfaces by default, and the admin login is
admin@coder.com/SomeSecurePassword!, which is in the repo. Any local user can log in as admin directly. As admin they can push a template and run code as the developer through the embedded provisioners. - If the developer sets a custom password with
--password, it is in the process arguments, and other users can read it withps. - The same race on the frontend port lets the attacker serve a fake login page instead, and the check does not cover that.
- The check accepts any listener of the same uid, and it does nothing on macOS.
So on a host with untrusted users, develop.sh is already unsafe, and this check doesn't change that. On a normal single-user machine or workspace, it never triggers. I'd decline the Codex finding as outside the threat model for a dev script.
Generated by an agent on behalf of the user
scripts/develop.shwaits a fixed 60 seconds for the API server's/healthzafter it starts the server, then fails withserver did not become ready in 1m0s. A cold first start (a new.coderv2, embedded Postgres setup and migrations) takes about 61 to 64 seconds on a shared host, even at low load. The first launch then fails although the server comes up a moment later.This adds
--health-timeout(CODER_DEV_HEALTH_TIMEOUT), a duration that sets that wait. The default stays 60 seconds. A value that is zero or negative is refused before anything starts, and a value that is not a duration is refused by flag parsing. The timeout error now names the configured value.waitForHealthyreads the timeout from the config and sends its first/healthzrequest at once, so even a timeout below the 500 ms poll interval reaches a server that is already healthy..claude/docs/DEV_ISOLATION.mdlists the flag, following the pattern of #31815./proc/net/tcpand/proc/net/tcp6and looks at the sockets that can take a connection to 127.0.0.1 on that port:127.0.0.1,0.0.0.0,::and the IPv4-mapped forms::ffff:127.0.0.1and::ffff:0.0.0.0. It refuses, with an error that names the port and the uid, when another OS user owns one of them. It ignores a socket on::when a socket of the developer's uid listens on IPv4 on that port, because Linux then allows only an IPv6-only socket on::. When it finds no listener it logs a warning and continues. On other systems it skips the check.The
verify-coderskill in #31782 startsscripts/develop.shand needs this flag to pass a longer wait on a cold first start. That PR will use the flag after this one merges.Verification:
go test ./scripts/develop/...passes, also with-race. The tests cover the default, the flag and the environment variable, the zero and negative refusal, the timeout error text, a healthy server with a 100 ms timeout, the poll ticks, the deadline and a canceled parent on a mock clock, the/proc/net/tcpparser (own and foreign uid, IPv6 dual-stack, IPv4-mapped addresses, other ports and rows that are not listening), the reader against real sockets (including one on::ffff:0.0.0.0), and setup sending no request to a foreign listener. Removing the zero check, ignoring the configured value inwaitForHealthy, skipping the immediate first request, not binding the option, letting a foreign uid pass the check, not calling the check from setup, ignoring::ffff:0.0.0.0and hiding IPv4-mapped sockets behind the rule for::each turn a test red. A builtdevelopbinary refused--health-timeout 0s,--health-timeout=-5sandCODER_DEV_HEALTH_TIMEOUT=boguswith exit status 1 before it started anything. With a listener of another user (uidnobody) on127.0.0.1,0.0.0.0,::ffff:127.0.0.1and::ffff:0.0.0.0, setup refused and sent nothing but the/healthzrequest. golangci-lint (full and new-code configs) reports 0 issues. I did not run the repo git hooks locally.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh