[WIP] fix(daemon): enforce box auth token on toolbox routes (opt-in)#776
[WIP] fix(daemon): enforce box auth token on toolbox routes (opt-in)#776G4614 wants to merge 1 commit into
Conversation
The toolbox daemon registered process-execute, file read/write, PTY and an open forward proxy with NO authentication — the authToken set via /init was only used as a telemetry attribute. Anyone able to reach TOOLBOX_API_PORT (firewall misconfig, shared host network, neighbor box, or SSRF) got unauthenticated RCE and full file access in the box, bypassing the API's org guards. Add toolboxAuthMiddleware, which enforces the token as a Bearer credential (constant-time compare) on all non-exempt routes when TOOLBOX_REQUIRE_AUTH=true, fail-closed when the token is unset. /init and /version stay exempt. The daemon side is fully tested (see below). It is gated OFF by default and is [WIP] for production enablement because turning it on requires the upstream proxy (runner→proxy→daemon) to forward the token on every request — a separate, coordinated change that needs the full multi-service stack to verify end to end. Two-sided test: TestToolboxAuth_EnforcesTokenWhenRequired rejects missing/wrong tokens (401) and accepts the exact token; reverting the middleware to a pass-through makes the unauthenticated RCE route return 200 and the test fails. TestToolboxAuth_DisabledByDefault confirms the default path is unaffected. Audit finding boxlite-ai#7 (medium). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
boxlite security fixes seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
1 similar comment
|
boxlite security fixes seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Problem
The toolbox daemon registered
/process/execute,/files/*,/process/pty/*and an open
/proxy/:port/*forward proxy with no authentication. TheauthTokenset via/initwas only used as a telemetry attribute. Anyone ableto reach
TOOLBOX_API_PORT(firewall misconfig, shared host network, neighborbox, SSRF) got unauthenticated RCE and full file access in the box.
Change
Add
toolboxAuthMiddleware: enforces the token as aBearercredential(constant-time compare) on all non-exempt routes when
TOOLBOX_REQUIRE_AUTH=true,fail-closed when the token is unset.
/initand/versionstay exempt.Gated off by default so the existing path is not broken.
Test (two-sided) — daemon side, runs locally
TestToolboxAuth_EnforcesTokenWhenRequiredrejects missing/wrong tokens (401)and accepts the exact token; reverting the middleware to a pass-through makes the
unauthenticated RCE route return 200 → test fails.
TestToolboxAuth_DisabledByDefaultconfirms the default path is unaffected.
go test ./pkg/toolbox/passes.What needs a resource to verify (enablement)
(it currently sends Bearer only to the API, not the daemon). That + setting
TOOLBOX_REQUIRE_AUTH=trueneeds the full runner→proxy→daemon path (a runningbox) to confirm legitimate requests still pass. Not run in this environment.
Audit finding #7 (medium).
🤖 Generated with Claude Code