fix: security and reliability fixes from audit - #2
Conversation
…pback Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
|
Warning Review limit reached
Next review available in: 34 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (6)
Comment |
Fixes confirmed audit findings, one file per commit. All findings verified by reading the code. Full typecheck needs installed deps (bare sandbox), so this relies on CI; the changed files parse cleanly and are self-contained.
Critical: network-exposed remote code execution by default
The runtime API (
/api/runtime/exec,/api/runtime/terminal,/api/runtime/fs) runs arbitrary shell commands and reads/writes files, yet auth is bypassed whenBOLT_AUTH_TOKENis unset and the server bound all interfaces. The real production entrypoint isreact-router-serve(not the customserver.ts), which binds0.0.0.0by default, so I enforce a bind policy ininstrument.server.mjs(loaded vianode --importon thestartpath) and wire that same guard into the container CMD:The Dockerfile now sets
HOST=0.0.0.0(needed for published ports) and runs with--import ./instrument.server.mjs, so a container published to the network refuses to start untilBOLT_AUTH_TOKENis set rather than silently exposing shell access.server.ts(the WebSocket-capable custom server) gets the same guard as defense-in-depth. This is a deliberate "secure by default" change to the deployment contract; flagging it explicitly so you can adjust the policy if you prefer a warning over a hard refusal.Terminal SSE listener leak
api.runtime.terminal.tspushed a listener ontosession.dataListenerson every stream connect but never removed it on disconnect, so each reconnect/refresh accumulated a dead listener that kept enqueuing on a closed controller. Listeners are now tracked and removed onabort(with an already-aborted guard for the resolve race):Other
cookies.ts: a cookie value that failed to decrypt (missing decryptor / key rotation) returned the raw ciphertext, which was then handed to providers as if it were a real API key. Now returnsnulland the caller drops the key.security.ts: rate limiting keyed onx-forwarded-for/x-real-ip/cf-connecting-ip, which are client-spoofable, so the limiter was trivially bypassed. These are now trusted only whenTRUST_PROXY_HEADERS=true; otherwise a single non-spoofable bucket is used.test-01-loaded.pngandtest-04-failedload.png.