coloa

Gateway (implemented — roadmap weeks 1–4)

The first shipped piece: a default-deny egress proxy with credential injection and a hash-chained audit log. Useful on its own in front of any sandbox (Docker, E2B, Modal) and the base layer for everything else.

Code layout

Crate What
crates/coloa-audit Append-only JSONL log; hash = sha256("coloa-audit-v1\n" ‖ canonical entry), prev links entries; file lock so CLI + gateway share one chain
crates/coloa-config coloa.yaml model (unknown sections such as budget: preserved), host matching, .coloa/secrets.json store (0600)
crates/coloa-gateway The proxy (hyper + reqwest/rustls): policy, DNS/SSRF filter, injection, leak blocking, response redaction
crates/coloa-sandbox Docker sandbox: internal network + single-port relay so the gateway is the only way out
crates/coloa coloa CLI binary

Commands

coloa init [dir] [--name app]
coloa egress allow <host> [--port N]... [--no-tls] [--allow-private]   # human only
coloa egress remove <host> | list
coloa secret set NAME --host <host>...    # value from hidden prompt or stdin; human only
coloa secret rm NAME | list
coloa gateway [--listen 127.0.0.1:4100]
coloa run [--as agent:claude] -- <cmd>    # sets *_PROXY, secret placeholders, COLOA_ACTOR (not enforced)
coloa run --sandbox docker --image <img> [--as agent:x] -- <cmd>   # enforced
coloa sandbox down
coloa audit tail [-n 20] | verify

Guarantees

Guarantee How
Deny by default No rule in egress.allow → 403 egress_not_allowed. Ports checked too. No allow-all mode exists
DNS / SSRF control Gateway resolves names itself and drops private, loopback, link-local (169.254.169.254), CGNAT, reserved and NAT64-mapped-private addresses unless the rule sets allow_private. Connects only to the addresses it checked (no rebinding window)
Secrets never reach code Code holds __COLOA_SECRET_NAME__; gateway substitutes in headers (incl. inside Authorization: Basic), URL and body, only for hosts in the secret’s hosts
No exfiltration of real values A real secret value (≥ 8 bytes) headed to a host it isn’t scoped to → 403 secret_leak
No echo-back When a secret was injected, the response (headers + streamed body) is scanned and the value replaced by its placeholder; Accept-Encoding is stripped so the body is scannable
Agents can’t widen their own policy egress allow, secret set/rm refuse when COLOA_ACTOR starts with agent: (and the refusal is audited)
Nothing unrecorded Each decision is sealed in the audit log before traffic flows; if the write fails the request fails (503)
Live policy coloa.yaml / secrets are re-read when they change; a broken edit keeps the last good version

Denials return 403 with header x-coloa-denied: <code> and a one-line fix an agent can relay to a human.

Two paths through the gateway

App calls Path Injection / redaction / leak scan
http://api.stripe.com/... Absolute-form proxy request; gateway originates TLS upstream (tls: true, default) ✅
https://api.stripe.com/... CONNECT tunnel ❌ (end-to-end encrypted) — allowlist, DNS filter and audit still apply

So: call APIs that need secrets via http:// through the gateway; the hop from app to gateway is local and the gateway→internet hop is TLS. TLS interception with a per-project CA is an open question.

Docker sandbox (enforced egress)

 app container ── on coloa-<app> (docker network --internal: no route, no external DNS)
      │ HTTP_PROXY=http://<relay>:4100
 relay (alpine/socat, pinned) ── forwards exactly one port ──▶ host.docker.internal:<gateway port>
                                                                 └▶ coloa gateway ──▶ internet
Escape attempt Result (tested in crates/coloa/tests/docker_sandbox.rs)
Ignore proxy, connect directly No route
DNS exfiltration External names don’t resolve
Read .coloa/secrets.json .coloa/ hidden behind an empty tmpfs
Edit coloa.yaml to widen egress Mounted read-only
Plant .git/hooks/* to run on the host later .git/ mounted read-only
Privilege escalation --cap-drop ALL, no-new-privileges, PID limit, runs as the project owner’s uid

Run the test with COLOA_TEST_DOCKER=1 cargo test -p coloa --test docker_sandbox. On Linux Docker Engine, host.docker.internal is the bridge address, so start the gateway with --listen 172.17.0.1:4100; the CLI’s preflight check explains this if it fails.

Known limits (MVP)

Next steps

  1. Docker sandbox ✅
  2. LLM token tracking: parse usage from OpenAI/Anthropic/Gemini responses passing through (cost MVP).
  3. Record response status + bytes in the audit log; per-app usage counters → hard budget caps.
  4. Then roadmap weeks 5–10: schema.coloa, Postgres proxy, TS functions in WASM.

Metering and budgets (cost MVP)

Crate crates/coloa-meter. Every egress request, LLM call and (later) function invocation is appended to .coloa/usage/usage-YYYY-MM.jsonl; processes tail the file, so the gateway and app server share one month-to-date total (caps can overshoot by in-flight requests).