|
| 1 | +--- |
| 2 | +name: harden-sandbox-policy |
| 3 | +description: Harden sandbox policies to minimum-access using the OpenShell Policy Prover (OPP). Fetches policies from local files or GitHub repos, runs formal verification to find gaps (L4-only endpoints, overpermissive methods, data exfiltration paths, write bypass attacks), and suggests concrete policy changes. Trigger keywords - harden policy, verify policy, prove policy, policy gaps, policy audit, opp, policy prover. |
| 4 | +--- |
| 5 | + |
| 6 | +# Harden Sandbox Policy |
| 7 | + |
| 8 | +Run the OpenShell Policy Prover (OPP) against a sandbox policy to find security gaps and suggest hardening changes. |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +- Python 3.12+ with the prover dependencies installed: `uv pip install 'openshell[prover]'` |
| 13 | +- A sandbox policy YAML file |
| 14 | +- A credential descriptor YAML file |
| 15 | + |
| 16 | +## Workflow |
| 17 | + |
| 18 | +### Step 1: Locate inputs |
| 19 | + |
| 20 | +Find or receive the following files: |
| 21 | +1. **Policy YAML** — the sandbox network/filesystem policy to verify |
| 22 | +2. **Credentials YAML** — describes what credentials the sandbox has and their scopes |
| 23 | +3. **Accepted risks YAML** (optional) — previously acknowledged risks to filter from results |
| 24 | + |
| 25 | +If the user provides a GitHub URL or repo path, fetch the policy from there. |
| 26 | +If the user points to a running sandbox, use `openshell policy get <name> --full` to export the current policy. |
| 27 | + |
| 28 | +### Step 2: Run the prover |
| 29 | + |
| 30 | +```bash |
| 31 | +python3 -m openshell.prover.cli prove \ |
| 32 | + --policy <policy.yaml> \ |
| 33 | + --credentials <credentials.yaml> \ |
| 34 | + [--accepted-risks <accepted.yaml>] \ |
| 35 | + --compact |
| 36 | +``` |
| 37 | + |
| 38 | +Or via the Rust CLI: |
| 39 | +```bash |
| 40 | +openshell policy prove \ |
| 41 | + --policy <policy.yaml> \ |
| 42 | + --credentials <credentials.yaml> \ |
| 43 | + [--accepted-risks <accepted.yaml>] \ |
| 44 | + --compact |
| 45 | +``` |
| 46 | + |
| 47 | +### Step 3: Interpret findings |
| 48 | + |
| 49 | +The prover returns findings at these risk levels: |
| 50 | +- **CRITICAL** — data exfiltration via L4-only or wire protocol bypass |
| 51 | +- **HIGH** — write bypass violating read-only intent, overpermissive HTTP methods, inconsistent L7 enforcement |
| 52 | +- **MEDIUM** — L4-only endpoints without sibling L7, binary inheritance chains |
| 53 | +- **ADVISORY** — inference.local side channel (architectural, always reported) |
| 54 | + |
| 55 | +Exit code: 0 = PASS (advisories only), 1 = FAIL (critical/high gaps found), 2 = input error. |
| 56 | + |
| 57 | +### Step 4: Suggest hardening changes |
| 58 | + |
| 59 | +For each finding, suggest concrete policy YAML changes: |
| 60 | + |
| 61 | +- **L4-only endpoints**: Add `protocol: rest` with `enforcement: enforce`, `tls: terminate`, and explicit `access: read-only` or method rules |
| 62 | +- **Overpermissive methods**: Replace `method: "*"` with specific methods (e.g., `POST` for inference, `GET` for package registries) |
| 63 | +- **Write bypass via wire protocol**: Remove binaries like `git`, `ssh`, `nc` from the policy if write access is not intended, or restrict credential scopes |
| 64 | +- **Binary inheritance**: Review spawn chains — if a parent binary (e.g., `python3`) spawns children with L7-bypass capabilities, consider using a more specific binary path |
| 65 | + |
| 66 | +### Step 5: Generate report (optional) |
| 67 | + |
| 68 | +For a shareable HTML report with interactive Mermaid diagrams: |
| 69 | +```bash |
| 70 | +python3 -m openshell.prover.cli prove \ |
| 71 | + --policy <policy.yaml> \ |
| 72 | + --credentials <credentials.yaml> \ |
| 73 | + --html report.html |
| 74 | +``` |
| 75 | + |
| 76 | +## Workflow Chain |
| 77 | + |
| 78 | +This skill complements `generate-sandbox-policy`: |
| 79 | +1. `generate-sandbox-policy` — author a policy from requirements |
| 80 | +2. `harden-sandbox-policy` — verify and tighten the authored policy |
| 81 | +3. Iterate until the prover returns PASS |
| 82 | + |
| 83 | +## Output Format |
| 84 | + |
| 85 | +Report findings as a structured summary: |
| 86 | +``` |
| 87 | +## Policy Verification Results |
| 88 | +
|
| 89 | +**Verdict:** FAIL — 3 critical/high gaps |
| 90 | +
|
| 91 | +### Findings |
| 92 | +1. **CRITICAL** Data Exfiltration Paths Detected |
| 93 | + - ... |
| 94 | +2. **HIGH** Write Bypass — Read-Only Intent Violated |
| 95 | + - ... |
| 96 | +
|
| 97 | +### Suggested Changes |
| 98 | +- [ ] Add `protocol: rest` to `github.com:443` endpoint |
| 99 | +- [ ] Remove `/usr/bin/git` from `github_readonly` binaries |
| 100 | +- ... |
| 101 | +``` |
0 commit comments