Skip to content

fix(audit): enterprise hardening — sandbox, browser, session atomicity#11

Open
ForkedInTime wants to merge 1 commit intomainfrom
fix/enterprise-audit-2026-04-26
Open

fix(audit): enterprise hardening — sandbox, browser, session atomicity#11
ForkedInTime wants to merge 1 commit intomainfrom
fix/enterprise-audit-2026-04-26

Conversation

@ForkedInTime
Copy link
Copy Markdown
Owner

Summary

Four-pass enterprise audit before the millions-of-users launch. 14 fixes across security, data integrity, UX honesty, and dead-code removal. Build clean, 29 test groups green, 14 new unit tests.

Security

  • sandbox: shell-quote cwd in bwrap_wrap / firejail_wrap — paths with spaces or shell metacharacters no longer break the sandbox
  • browser: validate_navigation_url rejects javascript:, data:, file:, ftp:, … (only http/https/about allowed)
  • rag/indexer: skip symlinked files so a crafted repo can't redirect indexing into ~/.ssh, /etc
  • main: respect NO_COLOR and TERM=dumb to disable ANSI in pipes/CI

Data integrity

  • session: atomic_write (sibling tempfile → sync_all → atomic rename) replaces fs::write in SessionMeta::save() and Session::overwrite(); crashes mid-write can no longer leave truncated .meta or .jsonl files

Browser feature wiring

  • BrowserSession: console_buf (cap 500) + spawned listener for Runtime.consoleAPICalled and Runtime.exceptionThrown; aborted + drained on close
  • browser_console tool: drains and returns captured messages

API honesty

  • Agent tool: removed unimplemented run_in_background field from input schema (was advertising a feature the runtime ignored)
  • autofix: replaced stale "reserved for future" doc on max_retries — the multi-turn retry loop is fully wired

UX polish

  • commands: upgraded /login, /logout, /fast migration-helper messages to point at real, verified commands (/model <provider>:<name>, /model haiku, /router)
  • tui/diff: stripped aspirational "hunk-walker UI" comment

Dead code removed (~105 LOC)

  • browser/extraction.rs (full module, fully #[allow(dead_code)])
  • browser/actions::handle_dialog
  • browser/cdp::is_alive

Test plan

  • cargo build --release — clean
  • cargo test --release — 29 test groups, 0 failures
  • cargo clippy --release --all-targets — only pre-existing style nits
  • 14 new unit tests added (URL validation 3, console listener 8, atomic_write 3)
  • Manual smoke test of /browser_console, /login, /fast, sandbox with spaces in cwd

…omicity

Security:
- sandbox: shell-quote cwd in bwrap/firejail wrappers so paths with spaces
  or shell metacharacters can't break out of the sandbox
- browser/actions: validate_navigation_url rejects javascript:/data:/file:/
  ftp: and other non-http(s)/about schemes (+ 3 unit tests)
- rag/indexer: skip symlinked files so a crafted repo can't redirect
  indexing into ~/.ssh, /etc, etc.
- main: respect NO_COLOR and TERM=dumb to disable ANSI in pipes/CI

Data integrity:
- session: atomic_write helper (sibling tempfile → sync_all → rename)
  replaces fs::write in SessionMeta::save() and Session::overwrite();
  crashes mid-write can no longer leave truncated .meta or .jsonl files
  (+ 3 unit tests)

Browser feature wiring:
- browser/mod: BrowserSession gains console_buf (cap 500) + console_task;
  spawned listener captures Runtime.consoleAPICalled +
  Runtime.exceptionThrown; aborted + drained on close
- new browser_console tool drains and returns captured messages
  (+ 8 unit tests covering formatters, drain, overflow)

API honesty:
- tools/agent: remove unimplemented run_in_background field from the
  Agent tool's input schema and AgentInput struct (was advertising a
  feature the runtime ignored)
- autofix: replace stale "reserved for future" doc on max_retries —
  the multi-turn retry loop is fully wired in tui/run.rs

UX polish:
- commands: upgrade /login, /logout, /fast migration-helper messages to
  point at real, verified commands (/model <provider>:<name>, /model
  haiku, /router)
- tui/diff: strip aspirational "hunk-walker UI" comment; replace with a
  factual note that hunks/lines exist for the test suite

Dead code removed (~105 LOC):
- browser/extraction.rs (full module, fully #[allow(dead_code)])
- browser/actions::handle_dialog (unused)
- browser/cdp::is_alive (unused)

Build clean, 29 test groups green, 14 new unit tests added across the
audit (URL validation 3, console listener 8, atomic_write 3).

Co-Authored-By: Arch Linux <noreply@archlinux.org>
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