Lion Cipher Lab

Sandbox AI-generated code with a locked-down executor (contain the code your agent writes)

Why it matters

Give an LLM a 'code interpreter' or 'run this code' tool and you have built the most dangerous endpoint in your stack: one where an attacker's goal (getting you to run their code) is the FEATURE, not the bug. The model writes Python; your harness runs it. If your harness runs it with `exec()` or `subprocess.run()`, you have wired a stranger's keyboard straight into your process — and the OWASP Top 10 for LLM Applications is explicit that model output must be treated as untrusted (Improper Output Handling: unvalidated output flows downstream into code execution; Excessive Agency: an agent with…

What you'll learn

Steps in this lab

  1. The threat model: model output is untrusted input
  2. Build the naive executor — the one you must never ship
  3. The four escapes the model's code might contain
  4. Watch the naive executor fail all four
  5. Build the locked-down executor (Docker: the primary path)
  6. Re-run all four escapes — and name what stopped each
  7. The fallback: pure-Python setrlimit — and where it stops
  8. Named failure modes — a sandbox is defense-in-depth, not one flag
  9. Wire it into the agent — and clean up

Open the full interactive lab →