Skip to content

security: fix workspace sandbox bypass, env race condition, and unsafe SAFETY docs#1244

Open
BunnyMoth wants to merge 2 commits into
RightNow-AI:mainfrom
BunnyMoth:fix/security-sandbox-env-race
Open

security: fix workspace sandbox bypass, env race condition, and unsafe SAFETY docs#1244
BunnyMoth wants to merge 2 commits into
RightNow-AI:mainfrom
BunnyMoth:fix/security-sandbox-env-race

Conversation

@BunnyMoth

Copy link
Copy Markdown

Summary

Three security fixes identified during a code-level audit of the codebase.

Changes

HIGH: Workspace sandbox bypass in media tools

tool_media_describe and tool_media_transcribe bypassed the workspace
sandbox entirely, allowing agents to read arbitrary host files regardless
of the configured workspace root. Both now use resolve_file_path the
same way all other file tools do, with workspace_root threaded in from
execute_tool.

HIGH: std::env::set_var/remove_var in async Axum handlers

Six call sites in routes.rs used the process environment as a live
config store from multi-threaded request handlers — undefined behaviour
under concurrent requests and a hard compile error on Rust 1.81+.
Replaced with RwLock<HashMap<String, String>> in AppState,
pre-populated from resolve_credential at startup. New method
detect_auth_with_keys added to model_catalog.rs.

LOW: Missing SAFETY comment on unsafe libc::kill

Documented the three invariants: PID origin, Mutex guard held, and
ESRCH no-op case.

Testing

  • cargo fmt --all --check — clean
  • cargo clippy --workspace --all-targets -- -D warnings — zero warnings
  • cargo test --workspace — 2,074 tests, 0 failures

BunnyMoth added 2 commits June 7, 2026 19:57
- tool_media_describe/transcribe now route through workspace sandbox
- API keys moved from process env to RwLock<HashMap> in AppState
- Add SAFETY comment to libc::kill in kernel.rs
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