Skip to content

fix: security and reliability fixes from audit - #2

Merged
DevFlex-AI merged 8 commits into
mainfrom
audit-security-fixes
Aug 6, 2026
Merged

fix: security and reliability fixes from audit#2
DevFlex-AI merged 8 commits into
mainfrom
audit-security-fixes

Conversation

@DevFlex-AI

Copy link
Copy Markdown

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 when BOLT_AUTH_TOKEN is unset and the server bound all interfaces. The real production entrypoint is react-router-serve (not the custom server.ts), which binds 0.0.0.0 by default, so I enforce a bind policy in instrument.server.mjs (loaded via node --import on the start path) and wire that same guard into the container CMD:

const host = process.env.HOST;
const isLoopback = !host || host === '127.0.0.1' || host === '::1' || host === 'localhost';
if (!host) {
  process.env.HOST = '127.0.0.1';                    // safe default for local runs
} else if (!isLoopback && !process.env.BOLT_AUTH_TOKEN) {
  console.error('[Bolt] Refusing to bind ' + host + ' without authentication: ...');
  process.exit(1);                                    // no unauthenticated LAN exposure
}

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 until BOLT_AUTH_TOKEN is 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.ts pushed a listener onto session.dataListeners on 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 on abort (with an already-aborted guard for the resolve race):

session.dataListeners.push(onData);
const dispose = () => {
  const idx = session.dataListeners.indexOf(onData);
  if (idx !== -1) session.dataListeners.splice(idx, 1);
};
if (request.signal.aborted) { dispose(); return; }
disposers.push(dispose);

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 returns null and the caller drops the key.
  • security.ts: rate limiting keyed on x-forwarded-for / x-real-ip / cf-connecting-ip, which are client-spoofable, so the limiter was trivially bypassed. These are now trusted only when TRUST_PROXY_HEADERS=true; otherwise a single non-spoofable bucket is used.
  • Removed committed test artifacts test-01-loaded.png and test-04-failedload.png.

DevFlex-AI and others added 8 commits August 6, 2026 06:06
…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>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@DevFlex-AI, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5fd5f7d8-7355-4f0c-880e-06786d5390a3

📥 Commits

Reviewing files that changed from the base of the PR and between dab11ad and b9d7f89.

⛔ Files ignored due to path filters (2)
  • test-01-loaded.png is excluded by !**/*.png
  • test-04-failedload.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • Dockerfile
  • app/lib/api/cookies.ts
  • app/lib/security.ts
  • app/routes/api.runtime.terminal.ts
  • instrument.server.mjs
  • server.ts

Comment @coderabbitai help to get the list of available commands.

@DevFlex-AI
DevFlex-AI merged commit 86239e7 into main Aug 6, 2026
3 of 4 checks passed
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.

1 participant