Repository navigation
Description
Summary
A managed QA job can send a bare bb plugin config write to the default production server. Add an accidental-routing guard in the CLI transport: reject non-GET/HEAD/OPTIONS requests to loopback port 38886 when HOST_CARE_JOB_ID is nonempty, unless BB_ALLOW_DEFAULT_SERVER_WRITES=1.
The reported October 20, 2026 incident overwrote a production PostHog API key. The original script's job ancestry is unknown, so this guard cannot be claimed to have prevented that exact invocation.
Versions and environment
Reproduced from source at b0bb68655adcc6cd79e495d3484f4011a0640e2e, Linux, in a real host-care job. All fetch calls were intercepted in process; no request reached production.
Steps to reproduce
- Build
@bb/clithrough Turbo. - Save a fetch stub that logs and intercepts every request locally as
mock-fetch.mjs. - Run with a disposable log path:
env -u BB_CLI -u BB_PROJECT_ID -u BB_THREAD_ID -u BB_ENVIRONMENT_ID \
HOST_CARE_JOB_ID=guard-repro BB_CLI_ERROR_LOG=0 \
BB_SERVER_URL=http://127.0.0.1:38886 GUARD_PROBE_LOG="$PWD/requests.jsonl" \
node --import "$PWD/mock-fetch.mjs" apps/cli/dist/index.js \
plugin config guard-probe set probe fake-qa-value --jsonExpected vs actual
Expected: nonzero exit, JSON error code managed_job_default_server_write, and zero PUT calls.
Observed exit code: 0. Intercepted requests:
{"url":"http://127.0.0.1:38886/api/v1/plugins/guard-probe/settings","method":"GET"}
{"url":"http://127.0.0.1:38886/api/v1/plugins/guard-probe/settings","method":"PUT"}Evidence
What was ruled out
- Duplicate search for managed job production writes and PostHog QA found no matching issue.
- Thread context does not redirect an explicit isolated URL; verified by the investigation.
- The regression reproduces with all transport stubbed, without touching production settings.
Acceptance
Cover implicit and explicit default URLs, loopback aliases, read methods, alternate ports, absent markers, exact override, Request methods/init overrides, BB_CLI re-exec, core SDK writes, and both plugin JSON command forms. Preserve behavior outside managed jobs. No host-care runtime changes.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 20, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotcli; no existing values were replaced.confirmed-repro.origin/maincheckouts atb0bb68655adcc6cd79e495d3484f4011a0640e2eproduced identical results. Marked implicit-default, explicit-default and localhost cases exited 0 and dispatched PUT to the intercepted transport. The guard regression failed as expected; all six existing plugin-config tests passed. No production HTTP request was sent; historical incident causality remains unverified.