# Sandboxed vulnerability validation

URL: https://docs.hanzo.ai/docs/cybersecurity/vulnerability-validation

> Eliminate false-positive security alerts by reproducing candidate vulnerabilities deterministically inside ephemeral /v1/sandbox leases and scoring severity with Kai.

**Static analyzers drown engineering teams in unverified alerts.** The cure is empirical reproduction: never page an engineer or open a remediation PR until a minimal test fails deterministically inside an isolated `/v1/sandbox` microVM.

## Sandboxed validation workflow

1. **Lease an isolated environment** (`POST /v1/sandbox/lease`) matching the target runtime image with no production credentials mounted.
2. **Stage the target commit and minimal reproducer** (`POST /v1/sandbox/{id}/fs` or repo checkout inside the sandbox).
3. **Run the reproducer** (`POST /v1/sandbox/{id}/exec`) and capture exact exit code, stdout/stderr, and sanitizer traces.
4. **Classify impact with Kai** (`POST /v1/decisions`): `exploitable` (`noul`), `severity` (`score`: `low`, `medium`, `high`, `critical`), and `owner_team` (`choice`).
5. **Tear down immediately** (`POST /v1/sandbox/stop` or `DELETE /v1/sandbox/{id}`).

## Validate a finding across all four surfaces

**CLI**

```bash
# 1. Lease an isolated sandbox
SANDBOX_ID=$(hanzo sandbox lease --data '{"image":"alpine:3.20","ttl_seconds":300}' | jq -r '.id')

# 2. Execute minimal vulnerability proof-of-reproduction test
hanzo sandbox exec "$SANDBOX_ID" --data '{"cmd":["sh","-c","pytest tests/security/test_auth_bypass.py"]}'

# 3. Always release sandbox when done
hanzo sandbox stop --data "{\"id\":\"${SANDBOX_ID}\"}"
```

**SDK**

**TypeScript**

```ts
import { Configuration, SandboxApi } from 'hanzoai';

const sb = new SandboxApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data: lease } = await sb.postSandboxLease({ image: 'alpine:3.20', ttl_seconds: 300 });
try {
  const { data: exec } = await sb.postSandboxByIdExec(lease.id, {
    cmd: ['sh', '-c', 'pytest tests/security/test_auth_bypass.py'],
  });
  console.log(exec);
} finally {
  await sb.postSandboxStop({ id: lease.id });
}
```

**Python**

```python
import os
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import SandboxApi

api = SandboxApi(ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"])))
lease = api.post_sandbox_lease({"image": "alpine:3.20", "ttl_seconds": 300})
try:
    result = api.post_sandbox_by_id_exec(
        lease["id"], {"cmd": ["sh", "-c", "pytest tests/security/test_auth_bypass.py"]}
    )
    print(result)
finally:
    api.post_sandbox_stop({"id": lease["id"]})
```

**HTTP**

```bash
SANDBOX_ID=$(curl -s -X POST https://api.hanzo.ai/v1/sandbox/lease \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image":"alpine:3.20","ttl_seconds":300}' | jq -r '.id')

curl -s -X POST "https://api.hanzo.ai/v1/sandbox/${SANDBOX_ID}/exec" \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cmd":["sh","-c","pytest tests/security/test_auth_bypass.py"]}' | jq '.'

curl -s -X POST https://api.hanzo.ai/v1/sandbox/stop \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"id\":\"${SANDBOX_ID}\"}"
```

**MCP**

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "sandbox",
      "arguments": {"op": "get_sandbox_quota", "input": {}}
    }
  }'
```

## Authorization rule

Only validate vulnerabilities against repositories, staging environments, and assets you own or hold explicit written authorization to test. Sandbox leases inherit your org's network egress policy and audit logging (`GET /v1/audit`).

## Related courses & docs

- [CYB 201 — Agentic Cybersecurity](https://hanzo.university/agentic-cybersecurity) ([Interactive Lab](https://hanzo.app/learn/agentic-cybersecurity))
- [CYB 301 — Autonomous SecOps](https://hanzo.university/autonomous-secops) ([Interactive Lab](https://hanzo.app/learn/autonomous-secops))
- [Autonomous Remediation](https://docs.hanzo.ai/docs/cybersecurity/remediation)
