T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- skillshieldd/src/sandbox.rs:52
- Finding
- Arbitrary Host Directory Is Mounted Read-Write Inside the Sandbox<![CDATA[ ## Vulnerability Details **File Location**: `skillshieldd/src/sandbox.rs:52-55`, with attacker-controlled input propagated through `skillshieldd/src/main.rs:103-131` and `skillshield-exec.sh:91-92` **Vulnerability Type**: Insufficient sandbox filesystem isolation **Risk Level**: High ### Vulnerable Code `skillshield-exec.sh:91-92`: ```bash REQUEST_JSON="$(python3 -c 'import json,os,sys; print(json.dumps({"command": sys.argv[1], "cwd": os.getcwd()}))' "$COMMAND")" RESPONSE_JSON="$(curl -fsS --unix-socket "$SOCKET_PATH" -H 'Content-Type: application/json' -X POST http://localhost/v1/execute -d "$REQUEST_JSON")" ``` `skillshieldd/src/main.rs:103-131`: ```rust async fn execute( State(state): State<AppState>, Json(payload): Json<ExecuteRequest>, ) -> Json<ExecuteResponse> { let request = ActionRequest { request_id: "exec".into(), session_id: "exec".into(), timestamp: timestamp_now(), actor: Actor { agent_name: "skillshield-wrapper".into(), tool_name: Some("skillshield-exec.sh".into()), run_id: None, }, action: Action::ShellExec(ShellExecAction { command: payload.command.clone(), args: vec![], env_diff: vec![], }), context: RequestContext { cwd: payload.cwd.clone(), workspace_root: payload.cwd.clone(), requires_approval: false, }, }; let decision = policy::evaluate(&request); let executor_name = state.executor.name().to_string(); match decision.execution_plan { models::ExecutionPlan::Execute | models::ExecutionPlan::Sandbox => { match state .executor .execute_shell(&payload.command, payload.cwd.as_deref()) .await ``` `skillshieldd/src/sandbox.rs:52-55`: ```rust if let Some(dir) = working_dir { cmd.arg("--bind").arg(dir).arg(dir); cmd.current_dir(dir); } ``` ### Technic ...[truncated 2237 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Configure a trusted workspace root independently of request data. 2. Canonicalize both the configured root and requested working directory before execution. 3. Reject any path that is not a strict descendant of the configured workspace root. 4. Explicitly reject sensitive or overly broad paths such as `/`, the user's home directory, and system configuration directories. 5. Resolve symlinks before authorization to prevent path traversal through symlinked components. 6. Use `--ro-bind` for the workspace by default. 7. Expose only narrowly scoped output or temporary directories as writable bind mounts. 8. Do not derive `workspace_root` directly from the untrusted `cwd` field. 9. Apply restrictive ownership and permissions to the cache directory and Unix socket so other local users cannot submit requests. 10. Add tests covering `/`, `..`, symlink escapes, nonexistent paths, and paths outside the approved workspace. ]]>
