T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/devbridge_cmd.sh:350- Finding
Wildcard sourcing of cross-sandbox environment files enables arbitrary shell execution
- Content
View full analysis
Vulnerability Details
File Location:
scripts/devbridge_cmd.sh, lines 350–354
Vulnerability Type: Cross-sandbox arbitrary shell execution through unsafe environment-file sourcing
Risk Level: HighVulnerable Code
bash db_init() { # Automatically discover and source job environment hw-env files if [ -d /root/job-envs/sandboxes ]; then for _db_envf in /root/job-envs/sandboxes/*-hw-env; do [ -f "$_db_envf" ] && . "$_db_envf" 2>/dev/null done unset _db_envf fiTechnical Analysis
Every call to
db_initenumerates all files matching/root/job-envs/sandboxes/*-hw-envand sources each one with the shell.command.Sourcing a file does not merely import environment variables. It evaluates the complete file as shell code in the current process, allowing command substitutions, function definitions, redirections, external command execution, and modifications to the caller's environment.
The implementation has no restriction tying the selected file to the current sandbox. It also performs no ownership, permission, regular-file, or content validation beyond
[ -f "$_db_envf" ]. Consequently, any lower-trust sandbox able to create or modify a matching file can cause its contents to execute when a more privileged Skill invocation callsdb_init.The loop also imports credentials from every matching file. A later file can overwrite
JOB_ENV_HW_DEVBRIDGE_API_KEY, causing_db_ensure_authto authenticate with another sandbox's credential:bash local api_key="${DEVBRIDGE_API_KEY:-${HW_API_KEY:-${JOB_ENV_HW_DEVBRIDGE_API_KEY:-}}}"This crosses both an operating-system execution boundary and a cloud-account credential boundary.
Attack Path
- A lower-trust sandbox or job gains write access to a file matching
/root/job-envs/sandboxes/*-hw-env. - It places executable shell syntax in that file, for example a command substitution or a direct shell command, or assigns an attack ...[truncated 1280 chars]
- A lower-trust sandbox or job gains write access to a file matching
- Remediation
View remediation
Remediation Suggestions
- Remove wildcard sourcing of environment files.
- Resolve only the environment file belonging to the current sandbox through a trusted, non-user-controlled identifier.
- Do not evaluate environment files as shell programs. Parse an allowlisted key such as
JOB_ENV_HW_DEVBRIDGE_API_KEYas data. - Reject unexpected lines, command substitutions, shell metacharacters, function definitions, and additional variable names.
- Before reading the file, verify that it:
- Is a regular file and not a symbolic link.
- Is owned by the expected privileged account.
- Is not writable by group or other users.
- Resides beneath the expected directory after canonical path resolution.
- Prevent credentials from unrelated sandboxes from entering the current process.
- Prefer passing the current job's credential directly through a protected process environment or secret manager rather than searching a shared directory.
