Skip to content

Guard managed jobs against default-server CLI writes - #5839

Closed
brsbl wants to merge 1 commit into
mainfrom
bb/block-production-writes-from-qa-jobs-thr_r9se63ek5v
Closed

brsbl wants to merge 1 commit into
mainfrom
bb/block-production-writes-from-qa-jobs-thr_r9se63ek5v

Conversation

@brsbl

@brsbl brsbl commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Managed jobs could send CLI writes to the default production server after environment sanitization removed their target URL. The approved proposal follows the October 20 QA config incident; that script's job ancestry remains unverified.

What changed

  • Managed jobs refuse HTTP writes to loopback production port 38886, including explicitly selected production URLs.
  • Both plugin command forms return the structured JSON guard error without exposing arguments or credentials.
  • CLI guide and configuration docs explain isolated targeting and the exact, per-invocation escape hatch.

This intentionally changes managed-job CLI behavior, including read-like plugin commands transported as POST. Intentional production invocations require BB_ALLOW_DEFAULT_SERVER_WRITES=1; ordinary non-job invocations retain existing behavior. No daemon protocol or host-care runtime changes.

How you verified

  • Baseline built CLI reproduced the incident path with stubbed transport: exit 0 and one attempted PUT.
  • Remote CI passed; the 29-case guard suite covers targets, methods, overrides, re-exec, SDK writes, and plugin JSON.
  • Full Slop Cop passed with one P2 follow-up (Preserve managed-job refusal codes through contextual CLI errors #5840); no validated P0/P1 findings remain within the approved scope.
  • Isolated-server E2E passed: managed refusals, explicit isolated writes, exact bypass, reads, and both plugin command forms.

Verified head: b1a3eadf7f20da98d76c227046a02704e864740d.

E2E used a fresh data directory and actual host-care jobs. Production-shaped URLs were intercepted and remapped exclusively to the isolated server; every mutation verified its exact dataDir. No test request reached production. The full changed-flow CLI/API pass recorded 50 observations, including identity preflights. Unrelated builtin plugin startup warnings did not affect the dependency-free fixture; app/provider/daemon flows were outside this change.

Scope remains accidental default/loopback routing. Wildcard and unrecognized aliases, redirects, remote production hosts, other production ports, and direct non-CLI clients are outside the guard.

Fixes #5838

BB-Thread-ID: thr_r9se63ek5v

AGENT GENERATED

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T06:46:25.722999Z b1a3ead PR opened
ℹ️ 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: b1a3eadf7f

ℹ️ 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 apps/cli/src/client.ts
Comment on lines +23 to +24
url.port === String(BB_PROD_SERVER_PORT) &&
isLoopbackHostname(url.hostname)

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 Block wildcard addresses that still reach production

When a managed job uses BB_SERVER_URL=http://0.0.0.0:38886 (or http://[::]:38886), this predicate permits mutating requests because isLoopbackHostname rejects wildcard addresses, even though Node on the inspected Linux runtime connects those addresses to the local server. The repository also supports 0.0.0.0 as a server bind host and classifies both wildcard forms as local-only in apps/app/src/lib/loopback-hostname.test.ts, so such a request can still write to the production server this guard is intended to protect; include local wildcard addresses in the blocked target classification.

Useful? React with 👍 / 👎.

@brsbl

brsbl commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Validated the wildcard-address bot finding against the approved scope. 0.0.0.0 and :: are wildcard/local-only addresses, not loopback addresses; the cited app helper also distinguishes those categories. The approved proposal explicitly selects @bb/config/loopback and excludes unrecognized aliases. This guard intentionally protects accidental default/loopback routing, not every address capable of reaching production. Wildcard, remote-host, redirect, and nondefault-port coverage remain outside this PR; no expansion was made during review.

The full five-panel Slop Cop at b1a3eadf7f20da98d76c227046a02704e864740d is PASS WITH FOLLOW-UP. Security, code quality, performance, and changed-flow isolated E2E passed. Architecture's nonblocking contextual-error-code finding was independently reproduced and recorded as #5840. No validated P0/P1 findings remain within the approved scope.

AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guard managed jobs against default-server CLI writes

1 participant