Skip to content

feat: add a --health-timeout flag to scripts/develop - #31968

Closed
ThomasK33 wants to merge 7 commits into
mainfrom
develop-health-timeout
Closed

ThomasK33 wants to merge 7 commits into
mainfrom
develop-health-timeout

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

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) 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. waitForHealthy reads the timeout from the config and sends its first /healthz request at once, so even a timeout below the 500 ms poll interval reaches a server that is already healthy. .claude/docs/DEV_ISOLATION.md lists the flag, following the pattern of #31815.

  • On Linux, setup now checks who owns the listening socket on the API port before it sends the saved session token or the admin password. It reads /proc/net/tcp and /proc/net/tcp6 and 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.1 and ::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-coder skill in #31782 starts scripts/develop.sh and 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/tcp parser (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 in waitForHealthy, 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.0 and hiding IPv4-mapped sockets behind the rule for :: each turn a test red. A built develop binary refused --health-timeout 0s, --health-timeout=-5s and CODER_DEV_HEALTH_TIMEOUT=bogus with exit status 1 before it started anything. With a listener of another user (uid nobody) on 127.0.0.1, 0.0.0.0, ::ffff:127.0.0.1 and ::ffff:0.0.0.0, setup refused and sent nothing but the /healthz request. 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

`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.
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 15:15 — with GitHub Actions Inactive
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 15:15 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T19:56:07.801701Z 65a4460 Manual request
🔒 Security Review ✅ Completed 2026-11-10T19:57:34.220379Z 65a4460 Manual request

Security findings

Advisory findings (2)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread scripts/develop/main.go
Comment on lines +411 to +412
if c.healthTimeout <= 0 {
return xerrors.Errorf("--health-timeout must be greater than zero, got %s", c.healthTimeout)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 7d0ae28e58

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ 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.

`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`.
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 16:14 — with GitHub Actions Inactive
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 16:16 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread scripts/develop/main_test.go Outdated
Comment on lines +726 to +727
cfg := &devConfig{healthTimeout: 100 * time.Millisecond}
err := waitForHealthy(ctx, logger, cfg, srv.URL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: f7620e2229

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ 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.

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.
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 17:41 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 1ba69ca7e1

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ 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.

Comment thread scripts/develop/main.go
// 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review

P3 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@coderagents coderagents 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.

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.

Comment thread .claude/docs/DEV_ISOLATION.md Outdated
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

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.

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.

Suggested change
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 09c4a91. The paragraph now says that the error names the configured timeout, with the example server did not become ready in 1m0s.

@coderagents

coderagents Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Check

Re-review of PR #31968 after new commits (head 1ba69ca7e1). This covers whether the previous round's feedback was addressed and whether the new commits introduced any doc gap.

Previously raised, now resolved

  • The "Readiness without new probes" section of .claude/docs/DEV_ISOLATION.md no longer contradicts the new --health-timeout paragraph added earlier on the page: it now says "...for up to 60 seconds by default (set --health-timeout to change that)...", matching the configurable behavior.
  • The code bug where a --health-timeout below the 500ms poll interval would time out without a single health check is fixed (waitForHealthy now checks immediately before polling), and is pinned by TestWaitForHealthyImmediate.
  • The real-time test flakiness Codex flagged is fixed via quartz.Clock injection; production still uses the real clock (quartz.NewReal()), so no user-facing behavior changed.

Suggestions

  • .claude/docs/DEV_ISOLATION.md (not a published docs page; .claude/docs/ is contributor/agent tooling guidance, not under docs/) - The new paragraph doesn't say the timeout error names the configured duration; see inline comment.

Related open PRs

None 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: true

Automated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong.

@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 18:36 — with GitHub Actions Inactive
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.
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 18:36 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread scripts/develop/listener.go Outdated
var loopbackListenAddrs = map[string]bool{
"0100007F": true,
"00000000": true,
"00000000000000000000000000000000": true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ 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.

Comment on lines +107 to +110
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review

P3 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 18:54 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 09c4a91b2a

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 09c4a91b2a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ 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.

… 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.
@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 19:53 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

Pushed 65a4460. It answers a verifier finding on 09c4a91: a socket of another user on the IPv4-mapped wildcard address ::ffff:0.0.0.0 takes connections to 127.0.0.1, but the API port check did not list that address, so setup could send the saved session token and the admin password to it. The check now decodes each local address and counts the IPv4-mapped forms of 127.0.0.1 and 0.0.0.0. The rule that ignores sockets on :: next to an own IPv4 listener does not hide them.

@ThomasK33
ThomasK33 temporarily deployed to main November 10, 2026 19:53 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 65a4460029

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 65a4460029

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ 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.

@ethanndickson ethanndickson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 with ps.
  • 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

@ThomasK33 ThomasK33 closed this Nov 12, 2026
@ThomasK33
ThomasK33 temporarily deployed to main November 12, 2026 09:58 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026

This branch was previously deployed

1 inactive deployment
main — 65a44600 Deployed Nov 12, 2026 by ThomasK33 via cla #254833
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants