Lion Cipher Lab
Lock down a coding agent with permission rules before it touches your repo: protect .env and block destructive commands
- AI Security
- Intermediate
- ~60 min
- Free · no account required
Why it matters
A coding agent is a program that reads your files and runs shell commands on your behalf, guided by text it reads along the way: your prompt, but also README files, issues, web pages and tool output. If any of that text is hostile or just confusing, the agent can be steered into reading a secrets file, deleting a folder or pushing code. OWASP calls the underlying problem Excessive Agency: damaging actions taken in response to unexpected or manipulated model output, whatever caused the malfunction. You cannot fix that by asking the model nicely. Claude Code's own docs make the point:…
What you'll learn
- explaining how Claude Code evaluates deny, ask and allow rules, and why deny wins
- writing Read deny rules that protect .env files and Bash deny rules for destructive commands
- writing a PreToolUse hook that blocks by exit code 2, and testing it with no model
- turning on the sandbox and denying reads of a secrets file at the operating system level
- recording which test attempts a rule stops and which it does not
- applying the same least-privilege idea to any coding agent
Steps in this lab
- What can go wrong, and where the controls sit
- Install Claude Code, or use the free local route
- Build a throwaway repo with a fake .env
- Learn the rule order before you write any rules
- Write the permission rules
- Write two hooks and test them with no model at all
- Start a session and confirm the rules loaded
- Test every rule and write down what happened
- Know what these controls do not cover
- The same idea for any coding agent
- Clean up
Open the full interactive lab →