FAROS icon indicating copy to clipboard operation
FAROS copied to clipboard

[Security] `DynamicEvaluator._run_command` executes user-supplied strings with `shell=True`

Open hunterwhip opened this issue 3 months ago • 1 comments

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)

  1. Short term: require shell=False and accept commands as list[list[str]]; reject any token containing ;, |, &&, >, <, backtick, or $(.
  2. Medium term: run the subprocess in a firejail / bubblewrap profile, no network, read-only root, writeable only at cwd.
  3. Long term: the obvious place for this is a container/VM sandbox (gVisor, Firecracker, nsjail). Reuse repo_scanner.MAX_FILE_SIZE style limits for stdout/stderr.

Until something like (1) is in place, DynamicEvaluator should not be exposed to any untrusted input — including LLM-generated commands.

hunterwhip avatar Aug 30 '26 18:08 hunterwhip