Skip to the content.

🔐 Security & sandbox

← Home

NanoResearch executes LLM-generated Python code as part of Stage II. Read this before exposing the API to anything other than 127.0.0.1.

Threat model

We assume the LLM is honest but unreliable:

We do not defend against a malicious LLM with internet egress; that would require a stronger sandbox (Docker / gVisor / firejail) which is on the roadmap.

Current sandbox guarantees

src/nanoresearch/agents/sandbox.py enforces:

Layer Mechanism Effect
Path traversal write_files() resolves each target and refuses anything outside the workspace LLM cannot drop a file in ~/.ssh
Memory RLIMIT_AS = 2 GB OOM-killed after 2 GB
CPU time RLIMIT_CPU and subprocess.run(timeout=…) Killed after 240 s by default
Network HTTP_PROXY, HTTPS_PROXY env stripped; NO_PROXY=* DNS still resolves; doesn’t block raw sockets
Filesystem cwd set to workspace directory Relative paths land inside the sandbox
Environment PYTHONSTARTUP, proxies removed; clean child env No shell escape via dotfiles
Imports Coding prompt restricts allowed packages Soft guarantee — debug loop catches violations

What’s NOT blocked

Do not run NanoResearch on a machine with secrets that the local user shouldn’t see. Run on a personal dev box or inside a VM.

Prompt injection from literature

OpenAlex abstracts are inlined into the Ideation prompt. A maliciously crafted abstract can attempt to redirect the model. We mitigate by:

If you operate in a high-sensitivity setting, disable literature retrieval or restrict the OpenAlex search to a curated allow-list of paper IDs.

Azure AD auth

  1. Put the FastAPI app behind an authenticated reverse proxy (Cloudflare Access, oauth2-proxy, AAD App Proxy).
  2. Switch the Stage II sandbox to Docker — drop --network=none, --cap-drop=ALL, --security-opt=no-new-privileges, read-only root filesystem, tmpfs /tmp.
  3. Persist nothing user-supplied beyond data/users/<id>/ and runs/. Both directories are local-only by default.
  4. Rate-limit POST /api/runs and POST /api/intent (intent costs LLM tokens; runs cost LLM tokens + CPU).

Reporting a vulnerability

Please email the maintainer listed in pyproject.toml instead of opening a public issue.