[Security] `DynamicEvaluator._run_command` executes user-supplied strings with `shell=True`
Severity: Critical
File: backend/app/code/eval/dynamic_eval.py:124-132
result = subprocess.run(
command,
shell=True,
cwd=cwd,
capture_output=True,
text=True,
timeout=timeout,
env=run_env,
)
evaluate() accepts a commands: Optional[List[str]] (line 238) that comes from API callers, and evaluate_in_sandbox() constructs python -m py_compile {main_file} by f-string into the same path. There is no allow-list, escaping, or chroot.
Repro
curl -X POST http://127.0.0.1:8005/api/v1/code/jobs \
-H 'Content-Type: application/json' \
-d '{"sessionId":"x","mode":"quick","command":"echo pwned > /tmp/proof; rm -rf /var/data"}'
The job worker hands the command verbatim to _run_command, which executes it as bash -c "..." in the workspace directory.
Why this is more than theoretical
The README positions FAROS as a multi-tenant AutoResearch runtime; the code_jobs API is reachable without authentication (no Authorization header is checked in backend/app/modules/code/code_jobs_api.py). Even in single-tenant mode, an LLM-authored "experiment" can ship arbitrary shell payloads through commands=.
Mitigations (in order of cost)
- Short term: require
shell=Falseand acceptcommandsaslist[list[str]]; reject any token containing;,|,&&,>,<, backtick, or$(. - Medium term: run the subprocess in a
firejail/bubblewrapprofile, no network, read-only root, writeable only atcwd. - Long term: the obvious place for this is a container/VM sandbox (gVisor, Firecracker, nsjail). Reuse
repo_scanner.MAX_FILE_SIZEstyle limits for stdout/stderr.
Until something like (1) is in place, DynamicEvaluator should not be exposed to any untrusted input — including LLM-generated commands.