T09 · Insecure Skill Coding Practices
- Location
researchclaw/experiment/sandbox.py:315- Finding
LLM-Generated Experiment Code Executes in an Unisolated Host Process with Inherited Secrets
- Content
View full analysis
Vulnerability Details
File Location:
researchclaw/experiment/sandbox.py:315-326,researchclaw/experiment/sandbox.py:408-419,researchclaw/experiment/factory.py:28-34, andconfig.researchclaw.example.yaml:59-66
Vulnerability Type: Untrusted code execution without an effective sandbox
Risk Level: CriticalVulnerable Code
researchclaw/experiment/sandbox.py:315-326:python result: SandboxResult try: env = {**os.environ, "PYTHONUNBUFFERED": "1"} completed = subprocess.run( command, capture_output=True, text=True, timeout=timeout_sec, cwd=self.workdir, env=env, check=False, )The same unsafe execution model is used for multi-file projects in
researchclaw/experiment/sandbox.py:408-419:python result: SandboxResult try: env = {**os.environ, "PYTHONUNBUFFERED": "1"} completed = subprocess.run( command, capture_output=True, text=True, timeout=timeout_sec, cwd=sandbox_project, env=env, check=False, )Docker failure causes an automatic downgrade to this host process in
researchclaw/experiment/factory.py:28-34:python if not DockerSandbox.check_docker_available(): logger.warning( "Docker daemon is not reachable — " "falling back to subprocess sandbox." ) return ExperimentSandbox(config.sandbox, workdir)The distributed example configuration selects the local execution mode:
yaml experiment: # ★ mode 决定实验结果的真实性 # "sandbox" — 在本地沙盒中实际执行生成的 Python 代码,产出真实实验数据 # "docker" — 在 Docker 容器中执行,支持 GPU 直通、依赖自动安装、内存隔离 # "simulated" — 不执行代码,使用公式生成假数据(仅用于框架开发调试,不应用于论文生成) mode: "sandbox"Technical Analysis
ExperimentSandboxis named as a sandbox but is an ordinary Python subprocess running with the current user's operating-sys ...[truncated 2520 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the automatic Docker-to-host fallback. If an isolated backend is unavailable, fail closed and require an explicit, separate unsafe-mode confirmation.
- Do not describe an ordinary subprocess as a sandbox.
- Execute generated code only in a container, micro-VM, or dedicated remote worker with:
- No network by default.
- A read-only root filesystem.
- A minimal writable output mount.
- A non-root user and dropped Linux capabilities.
no-new-privileges, syscall filtering, process limits, memory limits, and time limits.- No host socket, SSH agent, home directory, or credential mounts.
- Build a minimal environment allowlist instead of copying
os.environ. Pass only non-sensitive variables required by the experiment. - Keep AST validation as defense in depth only. Improve alias and data-flow handling, but never rely on static filtering to contain hostile Python.
- Centralize all generated-code execution behind one mandatory policy gate so direct callers cannot bypass validation and isolation.
- Make Docker or equivalent isolation the secure default in generated configuration.
- Add regression tests proving that generated code cannot read parent environment secrets, access files outside the workspace, open network connections, or spawn unrestricted subprocesses.
