|
| 1 | +# CLAUDE.md — guidance for a Claude Code session picking up interactive enforcement |
| 2 | + |
| 3 | +You're working on `vshalpnjabi/OpenShell`, branch |
| 4 | +`1-interactive-enforcement/vshalpnjabi`. The feature adds |
| 5 | +`EnforcementMode::Interactive` to the sandbox proxy — holds a denied request |
| 6 | +open while consulting an HTTP decision endpoint. |
| 7 | + |
| 8 | +Full design background: `DESIGN.md` in this directory. |
| 9 | +agentbox integration guide: `AGENTBOX_INTEGRATION.md` in this directory. |
| 10 | + |
| 11 | +## Current status (as of 2026-05-28) |
| 12 | + |
| 13 | +**All phases complete. PR is open at `vshalpnjabi/OpenShell#2` (draft).** |
| 14 | + |
| 15 | +| Phase | Status | |
| 16 | +|-------|--------| |
| 17 | +| 1 — Types + policy schema | ✅ Done | |
| 18 | +| 2 — `consult_interactive_endpoint()` + tests | ✅ Done | |
| 19 | +| 3 — Wired into proxy decision path | ✅ Done | |
| 20 | +| 4 — Compile-check + tests + commits | ✅ Done | |
| 21 | +| 5 — Security review findings addressed | ✅ Done | |
| 22 | +| 6 — PR open (`vshalpnjabi/OpenShell#2`) | ✅ Done (draft) | |
| 23 | + |
| 24 | +## Latest commit (HEAD) |
| 25 | + |
| 26 | +``` |
| 27 | +4ac551a fix(sandbox): warn when interactive enforcement falls back in WebSocket path |
| 28 | +bc9175e fix(sandbox): address security review findings in interactive enforcement |
| 29 | +491afc7 fix(sandbox): cap interactive enforcement timeout at 300 s |
| 30 | +e0f6152 fix(sandbox): remove unnecessary clone in websocket enforcement match |
| 31 | +25a1ac3 style: apply rustfmt to all changed files |
| 32 | +d203fdf docs(sandbox): document interactive enforcement mode |
| 33 | +ed6734c chore(docs): add fork-local Claude Code session instructions |
| 34 | +``` |
| 35 | + |
| 36 | +## Key implementation files |
| 37 | + |
| 38 | +| File | What changed | |
| 39 | +|------|-------------| |
| 40 | +| `crates/openshell-sandbox/src/l7/interactive.rs` | Core decision client; 15 tests | |
| 41 | +| `crates/openshell-sandbox/src/l7/mod.rs` | `EnforcementMode::Interactive` with `secret`; `INTERACTIVE_MAX_TIMEOUT = 300s` | |
| 42 | +| `crates/openshell-sandbox/src/l7/relay.rs` | Interactive arms destructure `secret`, pass to client | |
| 43 | +| `crates/openshell-sandbox/src/l7/websocket.rs` | Interactive fallback arms with `tracing::warn!` | |
| 44 | +| `crates/openshell-sandbox/src/proxy.rs` | Interactive arm: strips query string, passes `secret` | |
| 45 | +| `crates/openshell-policy/src/lib.rs` | `InteractiveEnforcementDef { secret }`, SSRF validation | |
| 46 | +| `crates/openshell-sandbox/Cargo.toml` | Added `serial_test = "3"` to dev-deps | |
| 47 | + |
| 48 | +## Known limitations (documented, not blocking) |
| 49 | + |
| 50 | +1. **`{`-heuristic proto encoding** — the policy value is stored as a JSON |
| 51 | + string in the proto `enforcement` field; detected by `{`-prefix. Needs a |
| 52 | + wire-breaking proto schema change to fix cleanly. |
| 53 | +2. **Hostname-based SSRF gap** — SSRF check blocks loopback/link-local IPs but |
| 54 | + not hostnames that resolve to them. DNS resolution at validation time is |
| 55 | + unreliable; fix belongs in a separate PR. |
| 56 | +3. **`secret` in plaintext YAML** — no secret injection mechanism yet. |
| 57 | + Separate feature request. |
| 58 | +4. **WebSocket per-message fallback** — Interactive cannot consult the async |
| 59 | + decision endpoint from the sync WebSocket per-message path; applies |
| 60 | + `fallback` and logs `warn!`. Fixing this requires an async WebSocket |
| 61 | + refactor phase. |
| 62 | +5. ~~**`pid` is `None` at relay sites**~~ — RESOLVED. `L7EvalContext` now |
| 63 | + carries `binary_pid` (the PID resolved for the L4 network decision, i.e. the |
| 64 | + same identity the allow/deny path bound to), and the three relay Interactive |
| 65 | + arms forward it as `InteractiveContext.pid`. The shared L4 identity |
| 66 | + resolution is unchanged, so allow/deny behavior is unaffected — only the |
| 67 | + Interactive decision request now includes the pid. |
| 68 | + |
| 69 | +## Test results (last full run) |
| 70 | + |
| 71 | +- `cargo test -p openshell-sandbox --lib` — 868 tests, all pass |
| 72 | +- `cargo test -p openshell-policy --lib` — all pass |
| 73 | + |
| 74 | +## Wire protocol summary |
| 75 | + |
| 76 | +POST `<endpoint>` with: |
| 77 | + |
| 78 | +```json |
| 79 | +{ |
| 80 | + "schema_version": 1, |
| 81 | + "request_id": "<uuid>", |
| 82 | + "sandbox_name": "<name>", |
| 83 | + "binary": "/path/to/binary", |
| 84 | + "pid": 1234, |
| 85 | + "host": "api.example.com", |
| 86 | + "port": 443, |
| 87 | + "method": "GET", |
| 88 | + "path": "/some/path", |
| 89 | + "protocol": "rest", |
| 90 | + "policy_name": "my-policy" |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +`Authorization: Bearer <secret>` header is added when `secret` is set. |
| 95 | + |
| 96 | +Response: `{"decision":"allow"|"deny","reason":"..."}`, HTTP 2xx. |
| 97 | + |
| 98 | +## Build notes |
| 99 | + |
| 100 | +See `SANDBOX_BUILD_ENVIRONMENT.md` (in memory) for tarball bootstrap and |
| 101 | +gold-linker OOM workaround details. |
| 102 | + |
| 103 | +```bash |
| 104 | +cargo build --workspace |
| 105 | +cargo test -p openshell-policy |
| 106 | +cargo test -p openshell-sandbox --lib -- l7::interactive |
| 107 | +``` |
0 commit comments