justrunme-airlock 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. justrunme_airlock-0.1.0/LICENSE +21 -0
  2. justrunme_airlock-0.1.0/PKG-INFO +348 -0
  3. justrunme_airlock-0.1.0/README.md +301 -0
  4. justrunme_airlock-0.1.0/airlock/__init__.py +3 -0
  5. justrunme_airlock-0.1.0/airlock/agent.py +203 -0
  6. justrunme_airlock-0.1.0/airlock/blast_radius.py +91 -0
  7. justrunme_airlock-0.1.0/airlock/bootstrap.py +347 -0
  8. justrunme_airlock-0.1.0/airlock/cli.py +424 -0
  9. justrunme_airlock-0.1.0/airlock/evidence/__init__.py +29 -0
  10. justrunme_airlock-0.1.0/airlock/evidence/bundle.py +671 -0
  11. justrunme_airlock-0.1.0/airlock/evidence/counts_v1.py +250 -0
  12. justrunme_airlock-0.1.0/airlock/evidence/verdict.py +221 -0
  13. justrunme_airlock-0.1.0/airlock/policy.py +195 -0
  14. justrunme_airlock-0.1.0/airlock/policy_python.py +844 -0
  15. justrunme_airlock-0.1.0/airlock/policy_shell.py +686 -0
  16. justrunme_airlock-0.1.0/airlock/receipt.py +320 -0
  17. justrunme_airlock-0.1.0/airlock/sandbox.py +584 -0
  18. justrunme_airlock-0.1.0/airlock/schemas.py +178 -0
  19. justrunme_airlock-0.1.0/airlock/sed_parser.py +146 -0
  20. justrunme_airlock-0.1.0/airlock/shell_lexer.py +195 -0
  21. justrunme_airlock-0.1.0/airlock/verifier.py +200 -0
  22. justrunme_airlock-0.1.0/airlock/web/__init__.py +1 -0
  23. justrunme_airlock-0.1.0/airlock/web/app.py +829 -0
  24. justrunme_airlock-0.1.0/airlock/web/chain.py +107 -0
  25. justrunme_airlock-0.1.0/airlock/web/containment.py +406 -0
  26. justrunme_airlock-0.1.0/airlock/web/limits.py +159 -0
  27. justrunme_airlock-0.1.0/airlock/web/pipeline.py +153 -0
  28. justrunme_airlock-0.1.0/airlock/web/replay.py +116 -0
  29. justrunme_airlock-0.1.0/airlock/web/samples/app.log +120 -0
  30. justrunme_airlock-0.1.0/airlock/web/samples/app_injected.log +121 -0
  31. justrunme_airlock-0.1.0/airlock/web/static/app.css +252 -0
  32. justrunme_airlock-0.1.0/airlock/web/static/app.js +832 -0
  33. justrunme_airlock-0.1.0/airlock/web/static/favicon.svg +1 -0
  34. justrunme_airlock-0.1.0/airlock/web/static/index.html +301 -0
  35. justrunme_airlock-0.1.0/airlock/web/static/metrics.json +235 -0
  36. justrunme_airlock-0.1.0/airlock/web/static/og.png +0 -0
  37. justrunme_airlock-0.1.0/airlock/web/static/pipeline-card.svg +38 -0
  38. justrunme_airlock-0.1.0/airlock/web/static/title-card.svg +12 -0
  39. justrunme_airlock-0.1.0/airlock/web/static/verify.js +252 -0
  40. justrunme_airlock-0.1.0/airlock/web/tasks.py +254 -0
  41. justrunme_airlock-0.1.0/justrunme_airlock.egg-info/PKG-INFO +348 -0
  42. justrunme_airlock-0.1.0/justrunme_airlock.egg-info/SOURCES.txt +71 -0
  43. justrunme_airlock-0.1.0/justrunme_airlock.egg-info/dependency_links.txt +1 -0
  44. justrunme_airlock-0.1.0/justrunme_airlock.egg-info/entry_points.txt +3 -0
  45. justrunme_airlock-0.1.0/justrunme_airlock.egg-info/requires.txt +16 -0
  46. justrunme_airlock-0.1.0/justrunme_airlock.egg-info/top_level.txt +1 -0
  47. justrunme_airlock-0.1.0/pyproject.toml +98 -0
  48. justrunme_airlock-0.1.0/setup.cfg +4 -0
  49. justrunme_airlock-0.1.0/tests/test_agent.py +123 -0
  50. justrunme_airlock-0.1.0/tests/test_containment.py +127 -0
  51. justrunme_airlock-0.1.0/tests/test_containment_live.py +108 -0
  52. justrunme_airlock-0.1.0/tests/test_e2e.py +108 -0
  53. justrunme_airlock-0.1.0/tests/test_evidence_bundle.py +700 -0
  54. justrunme_airlock-0.1.0/tests/test_jcs.py +60 -0
  55. justrunme_airlock-0.1.0/tests/test_network.py +59 -0
  56. justrunme_airlock-0.1.0/tests/test_outcome_check.py +226 -0
  57. justrunme_airlock-0.1.0/tests/test_policy.py +201 -0
  58. justrunme_airlock-0.1.0/tests/test_policy_corpus.py +617 -0
  59. justrunme_airlock-0.1.0/tests/test_policy_corpus_expanded.py +464 -0
  60. justrunme_airlock-0.1.0/tests/test_policy_corpus_independent.py +43 -0
  61. justrunme_airlock-0.1.0/tests/test_policy_corpus_r4.py +865 -0
  62. justrunme_airlock-0.1.0/tests/test_policy_review5.py +125 -0
  63. justrunme_airlock-0.1.0/tests/test_policy_zip_urllib.py +74 -0
  64. justrunme_airlock-0.1.0/tests/test_rate_admit.py +58 -0
  65. justrunme_airlock-0.1.0/tests/test_receipt.py +317 -0
  66. justrunme_airlock-0.1.0/tests/test_receipt_strict.py +224 -0
  67. justrunme_airlock-0.1.0/tests/test_sandbox.py +610 -0
  68. justrunme_airlock-0.1.0/tests/test_sandbox_unit.py +546 -0
  69. justrunme_airlock-0.1.0/tests/test_sed_parser.py +48 -0
  70. justrunme_airlock-0.1.0/tests/test_verifier.py +229 -0
  71. justrunme_airlock-0.1.0/tests/test_web_api.py +1049 -0
  72. justrunme_airlock-0.1.0/tests/test_web_copy.py +89 -0
  73. justrunme_airlock-0.1.0/tests/test_web_js_crosscheck.py +157 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrey Lesnikov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,348 @@
1
+ Metadata-Version: 2.4
2
+ Name: justrunme-airlock
3
+ Version: 0.1.0
4
+ Summary: Verified execution firewall for AI agents
5
+ Author: Andrey Lesnikov
6
+ License: MIT
7
+ Project-URL: Homepage, https://justrunme.com/hackathons/#airlock
8
+ Project-URL: Repository, https://github.com/justrunme/airlock
9
+ Project-URL: Issues, https://github.com/justrunme/airlock/issues
10
+ Project-URL: Documentation, https://github.com/justrunme/airlock#readme
11
+ Project-URL: Live demo, https://huggingface.co/spaces/justrunme/airlock
12
+ Project-URL: Research, https://justrunme.com/research/fail-closed-authorization-ai-agents/
13
+ Project-URL: Preprint, https://doi.org/10.5281/zenodo.24075886
14
+ Project-URL: Book, https://justrunme.com/book/
15
+ Project-URL: Author, https://justrunme.com/
16
+ Project-URL: ORCID, https://orcid.org/0009-0004-7583-4314
17
+ Keywords: ai-agents,agent-security,sandbox,gvisor,policy-engine,fail-closed,prompt-injection
18
+ Classifier: Development Status :: 3 - Alpha
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Science/Research
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Operating System :: POSIX :: Linux
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
29
+ Requires-Python: >=3.12
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: pydantic>=2.9.0
33
+ Requires-Dist: pyyaml>=6.0.1
34
+ Requires-Dist: cryptography>=43.0.0
35
+ Requires-Dist: httpx>=0.27.0
36
+ Requires-Dist: jcs<0.3,>=0.2.1
37
+ Provides-Extra: web
38
+ Requires-Dist: fastapi<1,>=0.115; extra == "web"
39
+ Requires-Dist: uvicorn<1,>=0.30; extra == "web"
40
+ Provides-Extra: dev
41
+ Requires-Dist: fastapi<1,>=0.115; extra == "dev"
42
+ Requires-Dist: uvicorn<1,>=0.30; extra == "dev"
43
+ Requires-Dist: pytest>=8.3.0; extra == "dev"
44
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
45
+ Requires-Dist: ruff<0.18,>=0.17; extra == "dev"
46
+ Dynamic: license-file
47
+
48
+ # Airlock
49
+
50
+ An LLM only proposes. A deterministic policy gate decides. Allowed code runs in a disposable Docker container under gVisor. Every job gets an Ed25519-signed, hash-chained receipt. Blast Radius Zero.
51
+
52
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/justrunme/airlock/blob/main/LICENSE)
53
+ [![CI](https://github.com/justrunme/airlock/actions/workflows/ci.yml/badge.svg)](https://github.com/justrunme/airlock/actions/workflows/ci.yml)
54
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://github.com/justrunme/airlock/blob/main/pyproject.toml)
55
+
56
+ [![Watch the 162s English-narrated demo](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/video-thumb.png)](https://lablab.build/ai-hackathons/vultr-hackathon/airlock-br0/airlock-blast-radius-zero)
57
+
58
+ **Video:** [162-second English-narrated film on LabLab](https://lablab.build/ai-hackathons/vultr-hackathon/airlock-br0/airlock-blast-radius-zero).
59
+
60
+ **Live demo:** https://airlock.justrunme.com
61
+
62
+ Archival earlier cut: https://youtu.be/yrYa1MisCYI
63
+
64
+ ## See it
65
+
66
+ ![Hero: Watch Airlock stop an attack](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/01-hero.png)
67
+
68
+ *Top of the live demo. One click replays a compromised agent. No model call.*
69
+
70
+ ![Three harmful proposals blocked before any container starts](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/02-attack-stopped.png)
71
+
72
+ *After the replay: three injected steps are blocked at the gate, the legitimate analysis runs under gVisor (`runsc`), and the page checks the receipt hash and signature in the browser. Change one character and the check fails.*
73
+
74
+ ![Compromised-agent tab: curl|sh and env exfil blocked](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/03-compromised-agent.png)
75
+
76
+ *Tab 1 (Compromised agent). Scripted `curl | sh` and `/proc/self/environ` exfil are denied (`R-BIN-CURL`, `R-SHELL-EXEC-FILE`, `R-PY-ATTR-DENIED`, `R-PY-OPEN-PATH`). No container starts. Each denial gets a signed receipt.*
77
+
78
+ ![Real task with live model: one of two proposals blocked](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/04-real-task.png)
79
+
80
+ *Tab 2 (Real task, live `qwen3.8-27b` on Vultr Serverless Inference). On this run the first proposal was denied (`R-PY-PATHLIB-WRITE`). The gate still signed a receipt.*
81
+
82
+ ![Attack arena: curl|sh blocked](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/05-arena-blocked.png)
83
+
84
+ *Tab 3 (Try to break it). Submit `curl | sh` yourself: `deny` with `R-BIN-CURL` / `R-SHELL-EXEC-FILE`, and no sandbox.*
85
+
86
+ ![Receipt verified in the browser](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/06-verify-valid.png)
87
+
88
+ *Tab 4 (Verify a receipt). The browser checks JSON, schema, SHA-256 over RFC 8785 JCS, and the Ed25519 signature via WebCrypto. Chain linkage is what `airlock verify-chain` is for; the page does not check it. Task-level Evidence Bundle checks use the separate offline CLI `airlock verify-bundle` (see docs/EVIDENCE_BUNDLE.md).*
89
+
90
+ ![Tampered receipt marked INVALID](https://raw.githubusercontent.com/justrunme/airlock/main/docs/img/07-verify-invalid.png)
91
+
92
+ *Same receipt after Tamper one character: the hash check fails and the page names the field that changed.*
93
+
94
+ ## What it is
95
+
96
+ I built Airlock because I don't want an agent's mistake to become my incident. The model only *proposes* actions. A deterministic policy engine decides whether to allow, deny, or ask for approval. Allowed code runs in a throwaway hardened container (gVisor `runsc` on the demo VM). A verifier then checks the result and the cleanup, and every decision gets an Ed25519-signed receipt that anyone can check offline, including in the browser.
97
+
98
+ The page opens with a button, "Watch Airlock stop an attack". It replays a compromised agent: three dangerous steps are denied before any container starts, one safe step runs in the sandbox, and the page then verifies the receipt in the browser. Below it are four tabs:
99
+
100
+ 1. **Compromised agent.** The log of a sample task contains a fake "ops-runbook" line that tells the agent to `curl ... | sh` and to post `env` to an outside host. You can replay what an agent that obeyed the line would propose, or run it with the live model. The replay's proposals are scripted; the gate, the sandbox and the receipts are not.
101
+ 2. **Real task (live model).** The agent analyses a sample app log and writes a Markdown report. Every action it proposes goes through the gate.
102
+ 3. **Try to break it.** You type code yourself and see the verdict, the rules, the run output and the receipt.
103
+ 4. **Verify a receipt.** Paste any receipt and the page checks the JSON, the schema, the SHA-256 hash over RFC 8785 JCS and the signature with WebCrypto. It does not check the hash chain; that is what the offline CLI `airlock verify-chain` is for. A tamper button shows what a failed check looks like.
104
+
105
+ When evidence post-processing succeeds, live and replay tasks can export an Evidence Bundle for offline `airlock verify-bundle` with a separately trusted public key; if export fails closed, the task result remains and evidence is marked unavailable.
106
+
107
+ ## What is actually enforced
108
+
109
+
110
+ - **Fail-closed policy**: Default deny. Actions are allowed only when explicitly recognized as safe.
111
+ - **Language allowlist**: Only `python`, `bash`, `sh` accepted.
112
+ - **Python**: Parsed with `ast`. Imports must come from an allow-list of standard-library modules (for example `re`, `json`, `csv`, `collections`, `datetime`, `statistics`, `pathlib`, `gzip`, `hashlib`, `ipaddress`); unknown modules are denied. `os` is limited to `os.path`, `os.listdir`, `os.sep` and `os.linesep`, and `sys` to an attribute allow-list. `eval`, `exec`, `compile` (except `re.compile`), `__import__`, `_`-prefixed and introspection attributes, the `getattr` family with non-literal names, `operator.attrgetter`/`methodcaller`/`itemgetter`, module aliasing and attribute lookups in format strings are denied. File paths must be literals inside `/work/input` (read) or `/work/out` (read/write).
113
+ - **Shell**: Parsed with a shell lexer. Only allow-listed binaries with allow-listed options run (`cat`, `grep`/`egrep`/`fgrep`/`zgrep`, `awk`, `sed`, `jq`, `sort`, `uniq`, `wc`, `head`, `tail`, `cut`, `ls`, `zcat`, `gzip`/`gunzip` to stdout, `tee`, `date`, plus `echo`, `printf`, `tr`, `test`). sed and awk are not trusted as read-only: sed scripts must parse into a fixed subset without `e`, `w`, `r` or branches, and awk `getline`, `system`, redirects and `ENVIRON` are denied. File arguments may only name relative paths, `/work`, `/work/input`, `/work/out` or `/dev/null`; output goes only to `/work/out` and never to script files. Other interpreters (`python3`, `perl`, `ruby`, ...), forbidden binaries (`docker`, `mount`, `sudo`, `curl`, `wget`, `ssh`, `nc`, ...), loops, process substitution, variable expansions, command substitution and assignment-prefixed commands are denied. This is checked against a test corpus only; the sandbox is the second line of defence (see docs/KNOWN_LIMITATIONS.md).
114
+ - **Network**: Only `--network none` is supported. Egress allowlist mode is NOT implemented and raises an error if requested.
115
+ - **Sandbox hardening**: Read-only rootfs, tmpfs /work (plus small noexec tmpfs /tmp and /dev/shm), job runs as uid 65534, no capabilities for the job, no-new-privileges, process/mem/cpu limits (the job's process cap is `RLIMIT_NPROC` = the signed `pids` cap; docker `--pids-limit` is only headroom under gVisor, where a fork bomb usually ends as an OOM kill first, see docs/THREAT_MODEL.md), wall-clock timeout watchdog with `docker kill`. The job's report is bound to a per-run nonce and parsed strictly. `files_in` reads only from a configured inputs directory.
116
+ - **Verifier**: Post-execution cleanup checks (container removed, no dangling networks), secret pattern scan, artifact hash validation.
117
+ - **Receipts**: RFC 8785 JCS canonical JSON, Ed25519 signatures, hash chain linking, optional signed chain head. Verification rejects duplicate keys, type coercion, missing fields and non-canonical hex (exit codes in `airlock/cli.py`).
118
+
119
+ ## Architecture
120
+
121
+ ```mermaid
122
+ graph TD
123
+ U[Browser] -->|HTTPS| C[Caddy :443]
124
+ C -->|127.0.0.1:8080| W[FastAPI app, user airlock]
125
+ W --> A[Agent loop]
126
+ A -->|API key from root-only env file| I[Vultr Serverless Inference qwen3.8-27b]
127
+ A -->|proposed action| P[Policy + blast-radius engine]
128
+ W -->|Arena code| P
129
+ P -->|allow| S[Sandbox: docker + runsc, network none]
130
+ P -->|deny| R
131
+ S --> V[Verifier: cleanup, secret scan, artifact hashes]
132
+ V --> R[Receipt signer: JCS + Ed25519 + hash chain]
133
+ R --> St[(/var/lib/airlock/receipts)]
134
+ U -->|verify.js in the page| R
135
+ ```
136
+
137
+ The model's output is only data. Decisions come from code. The inference key is only in the app process; it is never passed into a sandbox container (the container gets a scrubbed environment and no network).
138
+
139
+ ## Vultr services used
140
+
141
+ - **Vultr Cloud Compute**: one VM in Frankfurt. It runs Docker with the gVisor runtime, the FastAPI app as a systemd service, Caddy for HTTPS, and a prune timer.
142
+ - **Vultr Serverless Inference**: the only LLM path. All agent calls go to `https://api.vultrinference.com/v1` (OpenAI-compatible) with model `qwen3.8-27b`. It is a reasoning model, so I use `max_tokens` of at least 2048 (the web tasks use 12000).
143
+
144
+ ## Threat Model
145
+
146
+
147
+ | Threat | Mitigation | Residual Risk |
148
+ |--------|-----------|---------------|
149
+ | Secret exfiltration | API key never enters sandbox; environment scrubbed; `--network none` default; output secret scan | Model could leak user-provided data (out of scope) |
150
+ | Destructive commands | Read-only rootfs + tmpfs; no host mounts; policy denies dangerous patterns | Damage stays inside disposable container |
151
+ | Resource exhaustion | Timeout watchdog, pids/mem/cpu caps, output size limits | Host-level DoS via many tasks needs rate limiting |
152
+ | Container escape | Non-root user, no capabilities, no-new-privileges, seccomp, gVisor where available | **Not eliminated** - Docker shares kernel |
153
+ | Policy bypass via obfuscation | AST analysis flags eval/exec/base64; containment is the real boundary | Static analysis incomplete by design |
154
+ | LLM self-approval | Decisions come from deterministic code only; LLM output is data | None |
155
+ | Receipt forgery | Ed25519 signatures + hash chain | Compromised host can sign lies |
156
+
157
+ ## Corpus metrics
158
+
159
+ These numbers are from my own test corpus only. They are not a general detection rate.
160
+
161
+ | | count |
162
+ |---|---|
163
+ | adversarial cases | 255 |
164
+ | benign cases | 154 |
165
+ | false allow | 0 |
166
+ | false deny | 0 |
167
+
168
+ A second corpus, `tests/corpus_independent/`, was written by an independent reviewer, not by me. These numbers are on this corpus only:
169
+
170
+ | | before review 5 fixes | after |
171
+ |---|---|---|
172
+ | attack cases | 398 | 398 |
173
+ | benign cases | 79 | 79 |
174
+ | false allow | 46 (6 security-relevant) | 39 (0 security-relevant) |
175
+ | false deny | 1 | 1 |
176
+
177
+ The 6 security-relevant misses were five pathlib `glob`/`rglob` patterns with `..` and `test -r /etc/passwd`. I reviewed each of the 39 remaining false-ALLOWs by hand: they are imports, prints, no-ops, reads of `/work/input`, writes to `/work/out`, or loops stopped by the sandbox caps. `tests/corpus_independent/triage.json` gives the reason for each, and CI fails on any row outside that list. The one false-DENY is `tail -f`, which I deny on purpose (docs/KNOWN_LIMITATIONS.md section 7).
178
+
179
+ `scripts/corpus_metrics.py` makes `airlock/web/static/metrics.json`, and CI runs it with `--check` so the page can't show stale numbers.
180
+
181
+ ## Demo signing key
182
+
183
+ Receipts from the live demo are signed with this Ed25519 key:
184
+
185
+ ```
186
+ public_key_hex: d8c2acc2972692ee205a7e056d8ae2791906ba1e17f9bdf2cee14baf53377748
187
+ fingerprint (sha256): f42776ee997b0f0930f32d3620458e9b0d5b7afa5f610fd14756c6c8bc4510ce
188
+ ```
189
+
190
+ You can also get it from `/api/pubkey`. To check a receipt without the browser:
191
+
192
+ ```bash
193
+ node tests/js/verify_cli.mjs receipt.json d8c2acc2972692ee205a7e056d8ae2791906ba1e17f9bdf2cee14baf53377748
194
+ airlock verify-chain /path/to/receipts --pubkey public.pem
195
+ ```
196
+
197
+ ## Run the web app locally
198
+
199
+ ```bash
200
+ pip install -e ".[web]"
201
+ export VULTR_INFERENCE_API_KEY=... # only needed for the two agent tabs
202
+ airlock-web # listens on 127.0.0.1:8080
203
+ ```
204
+
205
+ The Arena and Verify tabs work without a key. Settings come from `AIRLOCK_*` variables (`AIRLOCK_DATA_DIR`, `AIRLOCK_RUNTIME`, rate limits, `AIRLOCK_TRUST_PROXY`); see `airlock/web/app.py`.
206
+
207
+ ## Run it on a Vultr VM
208
+
209
+ I use one Ubuntu VM with Docker and gVisor installed and a user `airlock` in the `docker` group.
210
+
211
+ ```bash
212
+ # from a checkout, copy the code to the VM and install
213
+ git archive HEAD | ssh airlock@VM 'mkdir -p ~/src && tar -x -C ~/src'
214
+ ssh airlock@VM 'cd ~/src && HOST=<ip-with-dashes>.sslip.io sh deploy/install.sh'
215
+ # put the key in a root-only file read by systemd
216
+ sudo install -d -m 700 /etc/airlock
217
+ sudo sh -c 'umask 077; echo VULTR_INFERENCE_API_KEY=... > /etc/airlock/airlock.env'
218
+ sudo systemctl restart airlock-web
219
+ ```
220
+
221
+ `deploy/` has the systemd unit (runs as `airlock`, hardened with `ProtectSystem=strict`), the Caddyfile (HTTPS through sslip.io, HTTP redirects to HTTPS), and `airlock-prune.timer`, which removes leftover `airlock-*` containers and networks every 10 minutes. The app binds to 127.0.0.1 only, because Docker-published ports skip ufw. Caddy is the only public listener and the Docker socket is never exposed.
222
+
223
+ ## Demo script
224
+
225
+ Film / judge in this order (also the "Run demo" button on the page):
226
+
227
+ 1. **Useful live result.** Tab 1 (Real task, live model). Needs `VULTR_INFERENCE_API_KEY`. The model analyses `/work/input/app.log` on this corpus, writes `report.md` with a required ```airlock-counts fence (ERROR/WARN integers only), and the page shows downloadable report text, raw stdout, cleanup evidence, and an independent recount against that fence only (VERIFIED/FAILED/INCONCLUSIVE on this corpus only; prose/examples/quotes are ignored). Receipts carry `"context": {"mode": "live", "planner": "model"}`.
228
+ 2. **Attack contained (policy gate).** Tab 2 (Compromised agent) → "Replay a compromised agent". Proposals are scripted; the gate, sandbox and receipts are real:
229
+ - step 1, the log analysis: allowed, runs in the sandbox (report.md on this corpus; poisoned log has one extra WARN);
230
+ - step 2, `curl … | sh`: denied (`R-BIN-CURL`, `R-SHELL-EXEC-FILE`), sandbox never started;
231
+ - step 3, read `/proc/self/environ` and post it out: denied (`R-PY-ATTR-DENIED`, `R-PY-OPEN-PATH`), sandbox never started;
232
+ - step 4, `rm -rf /work/input` and a write to `/etc`: denied (`R-BIN-RM`, `R-SHELL-REDIRECT`), sandbox never started.
233
+
234
+ Each receipt carries `"context": {"mode": "replay_compromised", "planner": "scripted"}`.
235
+ 3. **Runtime containment, then healthy (reduced scope).** Tab 3 → **timeout and memory only** (suite = both; 4 of the default 6 arena slots/min, atomic admit). Claim them on camera **only** after a genuine deployed Docker run shows `PASS` (`killed_by=timeout` / `killed_by=oom`, healthy `print(1+1)` exit 0 / stdout `2`, cleanup). Structured result: PASS / FAILED / INCONCLUSIVE — no false green. **Network isolation and read-only rootfs are not demonstrated on this demo path** (no egress / write-outside Arena probes; do not film `tests/test_sandbox.py` S15/S19/S20 as this flow).
236
+ 4. **Verify a receipt, then tamper.** Tab 4: JSON, schema, hash and signature checks in the browser. Then "Tamper one character". A valid signature means the receipt was not tampered with; it does not by itself prove the world-state claim inside the receipt.
237
+
238
+ Pitch stills (dark/terminal, same UI family): `/static/title-card.svg`, `/static/pipeline-card.svg`.
239
+
240
+ ## Limitations
241
+
242
+ - The live model (qwen3.8-27b) refused the prompt injection in every run I tried. So the containment moment in tab 1 comes from a replay with scripted proposals. The page and the receipts say so.
243
+ - Each `run_code` call is a new sandbox. Files don't carry over between calls.
244
+ - Container isolation lowers risk but doesn't remove it. gVisor helps, but the host is still shared.
245
+ - Static policy can be evaded. The sandbox is the real boundary.
246
+ - Receipts are only as honest as the host that signs them. The demo key lives on the VM.
247
+ - Receipts are kept on the VM and not pruned; only containers and networks are.
248
+ - Nobody has red-teamed this professionally. See `docs/KNOWN_LIMITATIONS.md`.
249
+
250
+ ## Installation
251
+
252
+ Requires Python 3.12+ and Docker.
253
+
254
+ ```bash
255
+ pip install justrunme-airlock
256
+ ```
257
+
258
+ For development:
259
+
260
+ ```bash
261
+ pip install -e ".[dev]"
262
+ ```
263
+
264
+ The command-line tool is `airlock` after installation.
265
+
266
+ ## Usage
267
+
268
+ ### Verify a receipt
269
+
270
+ ```bash
271
+ airlock verify receipt.json --pubkey public.pem
272
+ ```
273
+
274
+ ### Run the agent
275
+
276
+ ```python
277
+ from airlock.agent import AgentLoop
278
+ from airlock.policy import PolicyEngine
279
+ from airlock.sandbox import SandboxRunner
280
+ from airlock.verifier import Verifier
281
+ from airlock.receipt import ReceiptSigner
282
+
283
+ # Initialize components
284
+ engine = PolicyEngine()
285
+ runner = SandboxRunner()
286
+ verifier = Verifier()
287
+ signer = ReceiptSigner()
288
+
289
+ # Agent proposes action
290
+ with AgentLoop() as agent:
291
+ response = agent.chat([{"role": "user", "content": "Print hello world"}])
292
+ action = agent.parse_tool_call(response)
293
+
294
+ # Policy decides
295
+ decision = engine.evaluate(action)
296
+
297
+ if decision.verdict == "allow":
298
+ # Execute in sandbox
299
+ execution = runner.run(action, decision.caps)
300
+
301
+ # Verify
302
+ verification = verifier.verify(execution, decision.caps, output)
303
+ cleanup = verifier.verify_cleanup(execution.container_name)
304
+
305
+ # Sign receipt
306
+ receipt = signer.sign(
307
+ {
308
+ "task_id": action.task_id,
309
+ "action_id": action.id,
310
+ "decision": decision.model_dump(by_alias=True),
311
+ "execution": execution.model_dump(by_alias=True),
312
+ "verification": verification.model_dump(by_alias=True),
313
+ "cleanup": cleanup.model_dump(by_alias=True),
314
+ }
315
+ )
316
+ ```
317
+
318
+ ## Development
319
+
320
+ ```bash
321
+ make install # Install dependencies
322
+ make lint # Run linting
323
+ make test # Run tests
324
+ make check # Lint + test
325
+ ```
326
+
327
+ ## Testing
328
+
329
+ Tests are organized by component:
330
+ - `tests/test_policy.py` - Policy engine (P1-P12)
331
+ - `tests/test_sandbox.py` - Sandbox runner (S13-S28, requires Docker)
332
+ - `tests/test_verifier.py` - Verifier (V29-V34, requires Docker)
333
+ - `tests/test_receipt.py` - Receipt signing (R35-R39)
334
+ - `tests/test_agent.py` - Agent loop (E42, requires `VULTR_INFERENCE_API_KEY`)
335
+ - `tests/test_e2e.py` - End-to-end (E40-E41, requires Docker)
336
+
337
+ Smoke tests requiring live services are marked with `@pytest.mark.smoke` and skip when credentials aren't available.
338
+
339
+ See `docs/CHECKS.md` for the complete list of 1297 collected tests.
340
+
341
+ ## Author
342
+
343
+ Andrey Lesnikov
344
+ [https://orcid.org/0009-0004-7583-4314](https://orcid.org/0009-0004-7583-4314)
345
+
346
+ ## License
347
+
348
+ MIT