# Airlock – Egress firewall for AI agents with hash-chained immutable ledger

> Source: <https://github.com/rcortez056-spec/airlock>
> Published: 2026-12-04 21:55:02+00:00

**Key takeaway:** Airlock scores each agent API call before it fires — +40 for blocked methods like DELETE, +50 for internal or AWS-metadata endpoints, +20 per sensitive payload field — blocking at 40 and quarantining at 25, with every verdict written to a SHA-256 hash-chained ledger checked by /verify.

**Egress & API Action Firewall for Autonomous AI Agents**

Airlock intercepts every outbound API call an AI agent attempts to make — scoring it against a threat rules engine before it fires. Blocked and quarantined actions are logged to a tamper-evident immutable ledger. Nothing gets out without clearance.

Built to bridge threat detection and immutable state into an active defense layer.

Autonomous agents make decisions fast. Too fast. Without a firewall layer, a misconfigured agent can:

- Exfiltrate sensitive data through an unguarded API call
- Hit internal endpoints it was never meant to reach
- Fire DELETE requests that can't be undone
- Leak credentials or tokens in outbound payloads

Airlock stops all of that — before it happens.

```
Agent Action Request
        │
        ▼
┌───────────────────┐
│   Airlock Server  │  POST /intercept
│                   │
│  ┌─────────────┐  │
│  │ Rules Engine │  │  Scores: method, endpoint, payload, headers
│  └──────┬──────┘  │
│         │         │
│  ┌──────▼──────┐  │
│  │   Verdict   │  │  ALLOW / QUARANTINE / BLOCK
│  └──────┬──────┘  │
│         │         │
│  ┌──────▼──────┐  │
│  │   Ledger    │  │  Append-only, hash-chained, tamper-evident
│  └─────────────┘  │
└───────────────────┘
        │
        ▼
  200 ALLOW or 403 BLOCK
```

| Method | Route | Description | 
|---|---|---|
| `POST` | `/intercept` | Evaluate an action before it fires | 
| `POST` | `/rollback` | Trigger rollback on a previously allowed action | 
| `GET` | `/ledger` | Read the full immutable action log | 
| `GET` | `/verify` | Verify ledger integrity (hash chain check) | 
| `GET` | `/health` | Health check | 

```
git clone https://github.com/rcortez056-spec/airlock.git
cd airlock
node src/index.js
```

Server starts on port `3000` (configurable via `PORT` env var).

```
curl -X POST http://localhost:3000/intercept \
  -H "Content-Type: application/json" \
  -d '{
    "method": "POST",
    "endpoint": "https://api.example.com/submit",
    "payload": { "data": "clean payload" },
    "agent_id": "my-agent",
    "source": "relevance-ai"
  }'
```

**ALLOW response (200):**

```
{
  "allowed": true,
  "verdict": "ALLOW",
  "score": 0,
  "reasons": [],
  "ledger_id": "uuid-here",
  "timestamp": "2026-12-04T..."
}
```

**BLOCK response (403):**

```
{
  "allowed": false,
  "verdict": "BLOCK",
  "score": 75,
  "reasons": ["Blocked endpoint pattern: /localhost/", "Endpoint failed format validation"],
  "ledger_id": "uuid-here",
  "timestamp": "2026-12-04T..."
}
curl -X POST http://localhost:3000/rollback \
  -H "Content-Type: application/json" \
  -d '{ "ledger_id": "uuid-of-action", "reason": "Agent misfired" }'
curl http://localhost:3000/verify
```

| Trigger | Score Added | 
|---|---|
| Blocked HTTP method (DELETE) | +40 | 
| Blocked endpoint (localhost, internal, AWS metadata) | +50 | 
| Sensitive field in payload (api_key, secret, token, etc.) | +20 each | 
| Sensitive field in headers | +15 each | 
| Endpoint fails format validation | +25 | 

**Thresholds:**

- `BLOCK` → score ≥ 40
- `QUARANTINE` → score ≥ 25
- `ALLOW` → score < 25

Every intercepted action is logged to `ledger.jsonl` as an append-only, hash-chained record. Each entry includes:

- Unique ID and timestamp
- Hash of the previous entry (tamper-evident chain)
- Verdict, score, and reasons
- Action metadata (method, endpoint, agent_id, payload size)

The `/verify` endpoint checks the full chain and reports any tampering.

```
node src/test.js
```

All 13 tests pass. Covers: safe actions, blocked methods, sensitive payloads, internal endpoints, rollback, and ledger integrity.

- **Runtime:** Node.js (zero dependencies)
- **Storage:** Append-only JSONL ledger
- **Integrity:** SHA-256 hash chain
- **Transport:** HTTP (deploy behind your existing infrastructure)

Built by [Ramon Cortez](https://www.linkedin.com/in/ramon-cortez-a227a2112) — AI Systems Architect

Part of the autonomous defense stack alongside:

- [GitBridge AI](https://github.com/rcortez056-spec/gitbridge-ai) — GitHub event automation
- Sentinel Guard Engine — pre-execution safety layer
- Email Threat Detector — AI triage pipeline
