Defense in depth: every security layer between my coding agents and aiwow.dev

in Defense in depth

When coding agents write and ship your code, security is no longer one firewall but six layers, and you need to know which one stops which attack.

  1. What am I defending, and from whom?
  2. What stops a coding agent on my laptop?
  3. What stops a bad push?
  4. What does CI check before anything ships?
  5. How does code reach the server?
  6. What limits a break-in on the server?
  7. What does a visitor's request meet?
  8. How do I know it still holds?
  9. Strong and weak points
  10. Summary

I run aiwow.dev alone. Coding agents do most of the typing, in a harness of hooks and skills I share across six repos. So the risky actor can be a stranger on the internet, an agent on my own laptop that read a poisoned web page, or my own slip that pushes a private name. A firewall sees only the first.

So I asked an agent to map every measure I have, layer by layer, from the threat models I keep for each repo. This post follows one change from an agent's command to a visitor's browser, and names what stands in the way at each step. Defense in depth is the plain idea behind it: each layer assumes the one before it failed.

Tool Used for
ai-wow harness built on Claude Code, hooks and guardrails checks on every agent command and edit
gitleaks v8.21.2, semgrep 1.180.0, pip-audit 2.10.1, Trivy 0.70.0 secrets, code, dependency and image scans
OWASP ZAP 2.17.0 scanning the running site like an attacker
Docker Compose, Python 3.13 the app and its containers
Caddy 2.11.9 HTTPS, headers, rate limits, the scanner drop
Postgres 17 telemetry tables, no visitor data
agent harnesshooks ask first1 git gatesscrub, tests2 CI scanssecrets, deps, image3 deploy pathone sha, private net4 servernon-root, read-only5 edgeheaders, rate limits6 scan fails: back
Figure 1. Six layers a change passes before a visitor sees it.

The numbers follow the order a change passes the layers, and each layer gets its own section below. The dashed arrow is a failed scan sending the change back.

What am I defending, and from whom?

The site holds almost nothing worth stealing, so the targets are the server, the deploy pipeline and the pages themselves. Visitors are anonymous: no login, no upload, and one form that mails me and stores nothing. A defaced page or an injected script would hit every reader under my name.

The threat model for the site names eight attackers. The four that shape most measures:

  • a scanner hitting every public path,
  • a prompt-injected agent with my shell,
  • a malicious package or base image,
  • me, committing a draft or a private path by mistake.

What stops a coding agent on my laptop?

Hooks that run before each agent command stop the worst of it, by asking me first. The harness renders one hook list into every tool I use, so the same checks run in every repo.

  • guard-destructive asks before destructive SQL or git, a recursive delete of tracked work, piping a download into a shell, and reads of known secret files such as SSH keys and cloud credentials.
  • guard-dev-db asks before a write to a non-test database.
  • guard-migrations checks database migrations before they apply.
  • test-weaken-gate blocks once when a session added a skip marker or dropped assert lines in a test, compared with the commit before its first edit.
  • lane-scope-guard keeps a worker agent inside the files its brief owns.

Two more pieces live off the command path. The local dashboards bind to 127.0.0.1, and most check the Host or Origin header, so a web page in my browser can't read them. Session transcripts are copied off the machine at the end of a session only after a redaction step that fails closed: if it errors, nothing uploads.

The warning: these guards ask, they rarely deny, and they fail open. A command written to dodge a regex gets through. Why I test them by making them fire is in Guardrail testing, and what a delete taught me is in Agent guardrails.

What stops a bad push?

One script owns the push, and it checks what leaves the machine. push-main fetches first, refuses anything but a fast-forward, and scans every outgoing file for a private list of names. That list lives outside the repo, so the repo never holds the names it guards. Then the pre-push hook refuses a branch delete, runs the linter and runs the test suites.

A gitleaks pre-commit hook catches a secret one step earlier, at commit time. One agent owns pushing for the whole checkout, a setup I describe in Single pusher.

Warning: git push --no-verify skips the hook. The only defense is that agents never push raw.

What does CI check before anything ships?

Every push runs the scans, and a deploy starts only from a green run on a push from this repo. A fork's pull request never reaches deploy.

  • gitleaks reads the whole git history for secrets.
  • A second scan checks every served page against the private name list.
  • semgrep reads the code, pip-audit the Python lock file, and Trivy the built images.
  • ZAP scans the running site on pull requests.
  • Every GitHub Action is pinned to a commit sha, checkout keeps no credentials, and each workflow starts with no permissions.
  • Dependabot watches Python, Actions, Docker images and Compose files.

This layer is the one that has caught real problems. Trivy flagged CVE-2026-92392 in the curl inside the Caddy image, patched in one commit on 2026-10-26. On 2026-11-19 I moved Caddy to 2.11.9 for a Go flaw, CVE-2026-97054.

Warning: a scan's ignore file is part of the gate. Every line in it is a decision, so read it like code.

How does code reach the server?

Code reaches the server over a private network, through one command that accepts a commit id and nothing else. Since 2026-11-10, SSH is closed to the internet. The CI runner joins the private network for one run as a short-lived node, with no stored network secret.

Laptop CI Server agent runs a commandin any repo ✕ risky? ask me push-mainscrub, tests, no force scanssecrets, code, deps, image ✕ all pass? nothing ships forced commandone sha, nothing else new containersnon-root, read-only live push to main no yes, private network 1 2 3 4 5 6 7
  1. A coding agent runs a command on my laptop.
  2. A hook checks it and asks me first if it is risky.
  3. push-main scrubs private names, runs the tests and refuses a force push.
  4. On a push to main, CI scans secrets, code, dependencies and the image.
  5. If any scan fails, nothing ships.
  6. If all pass, the runner joins the private network and calls a forced command that takes one commit sha.
  7. The server starts new non-root, read-only containers, and the page is live.
Figure 2. One change from an agent's command to a live page.

On the server, the deploy key can run only a forced command. It accepts deploy plus a 40-character sha, gives no shell and no port forwarding, keeps only known names from the environment file, and pins the image repository in a root-owned file. Since 2026-11-15 the deploy user is no longer in the docker group: it may run that one script with sudo, and the script can't be swapped.

The host itself: key-only SSH, no root login, a firewall that allows SSH on the private network only, fail2ban, and unattended security upgrades.

Warning: the deploy script runs as root, so a parsing bug in it is a root bug. It stays short for that reason.

What limits a break-in on the server?

Each container gets the least it needs, so a bug in the app does not hand over the host.

  • The app runs as a non-root user with a read-only filesystem, all Linux capabilities dropped, no privilege gain, and memory and CPU limits.
  • The log shipper runs as its own user with no capabilities. A check from inside it on 2026-11-14 could not read the production secrets file.
  • It sees Docker through a proxy that allows GET requests only.
  • Only Caddy publishes a port.

Backups are encrypted to two keys before they leave the host. The key that uploads them can write and can't read or delete. A restore drill decrypts one on a timer and posts the result to the status page.

What does a visitor's request meet?

Caddy meets it first, with headers, rate limits and a drop list. Every response carries HSTS, a Content Security Policy of default-src 'self' with frame-ancestors 'none' and form-action 'self', nosniff, and no Server header. Each address gets 120 page requests a minute, and IPv6 is counted per /64 block. Known scanner paths such as /.env and /wp-admin are closed with no reply, as told in Edge defense. Metrics are blocked at the edge.

Then the app:

  • Markdown renders with raw HTML off, and a test lints every figure file for scripts, event handlers, iframes and forms.
  • Templates escape by default, which covers the search box that echoes its query.
  • Slugs must match a strict pattern, pages come from an allowlist, and the docs route checks the resolved path stays in its folder.
  • Error pages say nothing about the stack.
  • The contact form fixes the recipient, rejects header tricks, checks Origin, has a honeypot, and takes 5 posts per 10 minutes per address.
  • Logs, traces and error reports mask IP addresses and trim referrers before they leave the server.

On 2026-11-09 an agent probed the form with line-break, encoded-word and display-name tricks. None changed a recipient or a header.

How do I know it still holds?

A weekly sweep and two test suites re-check it, because a layer that was right in October can drift by November. The sweep scans all six repos with the same pinned scanners as CI and files each new hit on my task board with a due date: 7 days for critical, 30 for high, 90 for medium. On 2026-11-19 the site had 0 critical, 0 high, 2 medium and 3 low findings open, none overdue.

The tests attack on purpose. The real-Caddy rate-limit tests passed 41 of 41. A full active ZAP scan of the dev stack returned 0 FAIL and 135 PASS, covering SQL injection, XSS, path traversal and command injection. A daily attack report mails me what hit the edge, the habit that started on day one online.

Each repo also keeps a threat model: assets, entry points, attackers and known controls, with a gaps column.

Strong and weak points

Where it wins:

  • Layers that don't trust each other. The deploy key can't open a shell, the deploy user can't run Docker, and the app can't write its own disk. Each holds if the one before it falls.
  • The cheap checks run on every change. Hooks, push gates and CI cost seconds and catch the common slips.
  • It is written down. Every control points at a file, so a gap shows up as an empty cell.

Where it loses:

  • The agent layer only asks. Hooks fail open and parse commands by pattern. A determined prompt injection gets past them, and I am the last check.
  • No second person. My plan has no branch protection, so a push to main from my account deploys. My account is the whole perimeter.
  • Per-address limits. A flood from many addresses still reaches one app worker. Only the hosting provider stands in front of that.
  • Blocklists are hand lists. The private-name scrub catches only the names I remembered to add.

Summary

  • Defense in depth for a solo builder means six layers: agent hooks, push gates, CI scans, a narrow deploy path, locked-down containers, and the edge.
  • The agent on your own laptop is an attacker profile. Put checks on its commands, and know they only ask you; they stop nothing alone.
  • Make the deploy path accept one commit id over a private network, and nothing else.
  • Give every container the least it needs: non-root, read-only, no capabilities.
  • Re-check on a timer. A weekly sweep with due dates turns a scan into work that gets done.
  1. Write a threat model for your repo first. The gaps column tells you which layer to build next.
  2. Add one pre-command hook that asks before destructive git and database commands, then test it by making it fire.
  3. Close SSH to the internet and give your deploy key a forced command.