# makit — full documentation > makit is an open-source (MIT) command-line tool for the security of Linux servers you run yourself (Ubuntu and > Debian): it checks the host and its Docker containers (makit scan), blocks attacks before they reach the app with a > request shield that also handles bots and AI agents (makit shield), sends alerts (makit notify), sets up and hardens > new servers (makit init) and shows a terminal dashboard (makit top). This file joins the README and every guide of the repository (https://github.com/runsnip/makit), version 0.7.0, generated 2026-10-04. Install: `curl -fsSL https://makit.sh/install.sh | sh` (as root). Website: https://makit.sh · Index: https://makit.sh/llms.txt --- # makit [![ci](https://github.com/runsnip/makit/actions/workflows/ci.yml/badge.svg)](https://github.com/runsnip/makit/actions/workflows/ci.yml) Security for Linux servers you run yourself — find what is wrong, block what attacks, and set up new servers safely. One command-line tool (`makit`), MIT-licensed, for Ubuntu and Debian. | | What makit does | | --- | --- | | **Check** — `makit scan` | Read-only security check of the host and every Docker container (with your consent): malware and miner indicators, suspicious processes and connections, persistence, vulnerable npm packages (OSV), and posture — SSH, firewall, Docker ports, updates, kernel, secrets. Every finding links to a guide. | | **Protect** — `makit shield` | A gate in front of your web traffic: its own IP set (millions of entries, no ipset), allowlist, the real client IP behind any CDN or load balancer, HTTP rules, request scoring (probes, XSS, SQL injection…), bots/crawlers/AI agents verified and handled by your policy, rate limits, automatic bans. Works with Caddy/nginx asking it, or in front of them. | | **Alert** — `makit notify`, `makit schedule` | Scheduled scans and ban reports to Telegram, Slack, Google Chat, Discord, Teams, ntfy, webhooks or email. | | **Set up and harden** — `makit init` | A fresh server in one command: upgrades, swap, Docker, firewall (Docker ports included), automatic updates, kernel and SSH hardening, fail2ban, AppArmor, auditd — idempotent, with `--dry-run`. | | **Watch** — `makit top` | A terminal dashboard: system, processes, containers, services, logs, setup. | The threat knowledge — rules, scoring sets, the bot catalog, vulnerabilities — is data in [`security/`](https://github.com/runsnip/makit/blob/main/security), updated with `makit rules update` and overridable per server. What the shield costs per request is measured in [`benchmark/`](https://github.com/runsnip/makit/blob/main/benchmark), reproducible with one command. Install (as root): ```bash curl -fsSL https://makit.sh/install.sh | sh ``` A given version: `curl -fsSL https://makit.sh/install.sh | sh -s -- v0.7.0` (or `https://makit.sh/v0.7.0/install.sh`). Website and guides: [makit.sh](https://makit.sh). Set up a new server — preview first, then apply: ```bash makit init --dry-run makit init ``` `makit init` runs, in order: system upgrade and base packages → swap → kernel settings → Docker → (optional) block-storage volume → firewall (with Docker-published ports behind ufw) → automatic security updates → hardening (kernel, /dev/shm, fail2ban, AppArmor, auditd) → key-only SSH. Every step checks what is already done, so running it again is harmless. Every command accepts `--dry-run`. ## Commands | Command | What it does | | --- | --- | | `makit init [options]` | Everything below, in a safe order. `makit init --help` lists the options. | | `makit system-upgrade [--full] [--autoremove]` | `apt-get update` + `upgrade` (or `dist-upgrade` with `--full`), non-interactive, keeps your config files, warns when a reboot is required. | | `makit base` | `makit system-upgrade`, then installs curl, git, rsync, ufw, fail2ban, unattended-upgrades, jq… | | `makit swap [SIZE\|auto]` | Creates `/swapfile` (auto: 2G below 2 GB of RAM, 4G up to 16 GB, none above) and sets `vm.swappiness=10`. Never resizes an existing swap file. | | `makit sysctl KEY=VALUE… \| opensearch` | Persists kernel settings in `/etc/sysctl.d/90-makit.conf` and applies them. `opensearch` = `vm.max_map_count=262144`. | | `makit docker` | Docker Engine + Compose plugin from download.docker.com; caps container logs at 3 × 20 MB (only if `/etc/docker/daemon.json` does not exist yet). | | `makit volume DEVICE\|auto MOUNTPOINT [--docker] [--format]` | Mounts a block-storage volume (DigitalOcean, Hetzner, GCP, AWS EBS) by UUID with `nofail`. `--docker` keeps Docker's named volumes on it and makes Docker wait for the mount. `--format` creates ext4 only on an empty device, after asking. | | `makit firewall [PORT/PROTO…] [--docker] [--egress PORTS\|off]` | ufw: deny incoming except the given ports (default 22/tcp 80/tcp 443/tcp 443/udp) **plus every port sshd listens on**; existing rules are kept. `--docker` puts Docker-published ports behind ufw; `--egress "443/tcp"` lets containers connect out only to those ports (+ DNS). | | `makit updates` | Unattended security upgrades (reboots stay manual). | | `makit harden [--tmp-noexec]` | Kernel hardening sysctls, `/dev/shm` noexec, SSH limits, fail2ban sshd jail, AppArmor, auditd rules for programs run from temporary directories. | | `makit ssh` | Disables SSH password login, root keeps key login. **Skipped if root has no authorized key.** | | `makit status` | Read-only summary: RAM, swap, disks, Docker, firewall, SSH, kernel settings, pending reboot. | | `makit list [--json]` | Each part makit manages and whether it is in place (the Setup tab uses this). | | `makit top` | Terminal dashboard with mouse support — see below. | | `makit scan [options]` | Read-only security check of the host and/or containers — see below. | | `makit rules list\|update\|path` | The security catalog `scan` uses; `update` fetches the newest one from this repository. | | `makit schedule scan daily\|weekly\|hourly\|off [--webhook=URL]` | Scheduled read-only scans (systemd timer) with a webhook alert when something MEDIUM or worse is found. Consent is asked once. | | `makit shield on\|off\|ban\|allow\|list\|log\|snippet …` | IP gate for web traffic — its own block set and allowlist, real client IPs behind any CDN or load balancer, HTTP rules with automatic bans, request snapshots. Caddy/nginx ask it, or it sits in front of them — see below. | | `makit docs [topic\|RULE-ID]` | The [security guides](https://raw.githubusercontent.com/runsnip/makit/main/docs/security/README.md), offline: what each finding means and how to fix it. | | `makit upgrade [--check] [vX.Y.Z]` | Checks GitHub for a newer makit and installs it after asking (`--check` only reports: exit 10 when an update exists). `self-update` is an alias. | | `makit version`, `makit -v`, `makit --version` | Prints the installed version. | Global options: `--dry-run` (change nothing), `--yes` (confirm prompts, e.g. `--format` without a terminal). Output is coloured at a terminal and plain when it is piped or saved; `NO_COLOR=1` turns colour off, `FORCE_COLOR=1` keeps it on (CI logs, `less -R`). Reports that are saved or sent as notifications never carry colour codes. ### Example: a Docker host with OpenSearch and a DigitalOcean volume ```bash makit init --sysctl opensearch --volume auto --mount /mnt/data --docker-volumes --format ``` ## makit top A terminal dashboard, no htop needed. Mouse: click tabs, click column headers to sort, scroll with the wheel, click a row to select it (click again to open), click buttons. Keyboard: `1`–`8`, arrows, `/` to filter, `q` to quit. The version line on the right is green when makit is up to date and yellow when a newer release exists (`makit upgrade` installs it; checked at start and every 6 hours). | Tab | Shows | Actions (asks first, needs root) | | --- | --- | --- | | Overview | CPU per core + history, memory, swap, network, disks, top processes, health summary | — | | Processes | All processes: CPU%, memory, threads, state, command | `k` send SIGTERM | | Containers | Docker containers with CPU and memory | logs, restart, start/stop | | Services | systemd services (`f` failed only) | journal, restart | | Disks | Usage per filesystem, read/write per disk | — | | Logs | System journal (follows the end) | — | | Shield | The gate: service, **Ask** (Caddy/nginx ask makit) and **Edge** (makit checks and blocks in front) as separate switches, mode, counters; bans, allowlist, bot IPs and bot IP sources | turn on/off, toggle ask/edge/mode, + Ban IP, + Allow IP, + Bot IP, + Bot URL (typed inline), remove, latest reports | | Setup | Everything `makit init` manages, ✓/✗ per item | Install / re-run with a live log, "install all missing" | ## makit scan A **read-only** security check: a search for malware dropped on a server or inside containers — for example the Go backdoor dropped through CVE-2025-55182 (React2Shell) as `/tmp/vim`, started with `nohup` and then deleted ([analysis](https://github.com/ngvcanh/CVE-2025-55182-Attack-Analysis)). ```bash makit scan # the host (all processes, including those in containers) makit scan --container web # one container's filesystem, seen from the host — no docker exec makit scan --all-containers --host # everything makit scan --json --consent > report.json # automation: --consent replaces the interactive confirmation ``` Before anything is read, makit lists what it will look at and asks you to type `yes`. **It never modifies, deletes, moves, quarantines, executes or uploads anything** — it prints findings with evidence and suggested next steps. What it looks for (every finding links its [guide](https://raw.githubusercontent.com/runsnip/makit/main/docs/security/README.md); `makit docs ` shows it offline): - **Processes** running a deleted executable (run-then-`rm`), from `/tmp`, `/dev/shm` or a hidden directory, from memory only (memfd), disguised as kernel threads (`[kworker/0:1]`) or named like a system tool they are not. - **Network** connections to known-bad IPs, to common miner/backdoor ports, or from those suspicious processes. - **Files** in temporary and home directories: unexpected or hidden executables, SHA256 matches with known malware, Go binaries with backdoor traits (HTTP + SOCKS5 + TLS/ChaCha20), downloader scripts (`wget … -O /tmp/…; chmod +x; nohup`); in containers, every file added or changed since the image (`docker diff`). - **Persistence**: cron, systemd units, `rc.local`, `/etc/ld.so.preload`, shell profiles, recently changed SSH keys. - **Entry points**: installed packages affected by advisories in the catalog (e.g. Next.js / React for CVE-2025-55182). - **Configuration**: SSH password login, firewall, databases/admin ports reachable from the internet, Docker ports bypassing ufw, containers that are privileged / have the Docker socket / run as root / have an executable `/tmp`, pending security updates, kernel settings, `/dev/shm`, fail2ban, AppArmor, auditd, log shipping, `.env` permissions. `makit scan --only malware|posture|vulns` runs a subset. Everything it knows — indicators, patterns, severities, vulnerabilities (OSV format) — is data in [`security/`](https://raw.githubusercontent.com/runsnip/makit/main/security/README.md), read from the bundled catalog, the newest one from this repository (`makit rules update`) and your own (`--rules DIR`). Each finding names its rule (`MK-…`) and references (CVE ids). Exit status: `0` nothing above LOW, `1` MEDIUM or worse, `2` error, `3` consent not given. ## makit shield Blocks visitors by IP before they reach your app, with its own set (IPs/CIDRs with expiry — no ipset) and an allowlist that always wins. Behind a CDN, a load balancer or both it finds the visitor in `X-Forwarded-For`, walking back through the proxies you trust (`trusted_proxies`); a visitor faking headers is judged on its own IP. HTTP rules from the catalog ban scanners, secret probing, path traversal and the React2Shell exploitation pattern automatically. ```bash makit shield on # --observe to only log what would be blocked makit shield snippet caddy # Caddy/nginx ask makit before every request (forward_auth / auth_request) makit shield ban 198.51.100.7 --for 24h makit shield allow 192.0.2.10 makit shield log --blocked ``` Or put makit in front of Caddy/nginx (it terminates TLS and forwards to localhost). Guide: [docs/security/shield.md](https://raw.githubusercontent.com/runsnip/makit/main/docs/security/shield.md). Every request is also scored (probes, XSS and SQL injection in the URL, scanners, floods — the scoring set is [online in this repo](https://github.com/runsnip/makit/blob/main/security/scoring/http.yaml) and you can override it per server). Bots, crawlers and AI agents are recognised and verified (a fake Googlebot is caught), and you choose per category or per bot: ```bash makit shield bots set ai-crawler block # no AI training crawlers makit shield bots set gptbot "limit 30/1m" # …or let one in slowly makit shield customize scoring # your own copy of the scoring set in /etc/makit/security ``` One server, many domains: the top of `shield.yaml` is the global policy and `sites:` overrides it per domain (mode, bans for the site only or the whole server, bot policy, scoring profiles, rules, report channels). Guide: [docs/security/bots.md](https://raw.githubusercontent.com/runsnip/makit/main/docs/security/bots.md). Check a config before it is loaded — every key, value, listener and catalog setting, with the line and the fix — and see what it would change on your real traffic (`--replay` runs an access log through the current and the new config; nothing is written). `makit shield edit` saves only a file that passes. Or build one in the browser: [makit.sh/playground.html](https://makit.sh/playground.html), checked by the same code compiled to WebAssembly. ![makit shield config check finds a misspelt key and a wildcard ACME name](https://github.com/runsnip/makit/blob/main/docs/img/config-check.png) ![makit shield config check --replay shows which requests a new config would block](https://github.com/runsnip/makit/blob/main/docs/img/config-replay.png) ### Behind a load balancer, and in Kubernetes Behind AWS ALB or any proxy, the visitor is read from the right of `X-Forwarded-For` (trusted proxies skipped), so nobody picks their own IP; an NLB's PROXY protocol works too. In a cluster, makit-shield runs as a small Deployment (signed image, Helm chart) that Envoy Gateway, Istio, Traefik or ingress-nginx ask before every request, and its replicas share bans, rate limits and scores: banned on one pod means banned on all within milliseconds, and `limit 60/1m` stays 60 for the cluster — while every decision is still made from local memory. Bans can be pushed to AWS WAF so the load balancer drops that traffic first, `/metrics` feeds Prometheus, and ALB access logs can be analysed with the same policy. Guide: [docs/security/kubernetes.md](https://raw.githubusercontent.com/runsnip/makit/main/docs/security/kubernetes.md). ```bash helm install shield oci://ghcr.io/runsnip/charts/makit-shield -n makit --create-namespace makit shield snippet envoy-gateway --service shield-makit-shield --namespace makit --gateway eg ``` ![tests/k8s-e2e.sh: bans, live config and a shared rate limit across 3 replicas on kind](https://github.com/runsnip/makit/blob/main/docs/img/k8s-e2e.png) What it costs, measured — the full method and more numbers in [benchmark/](https://github.com/runsnip/makit/blob/main/benchmark): ![go test -bench: a decision in about 6 µs, the same with and without a cluster; a ban reaches the other replicas in about 2 ms](https://github.com/runsnip/makit/blob/main/docs/img/bench-micro.png) End to end on a Linux runner, Envoy and Caddy asking makit next to the same paths without it (4 shared vCPUs carry the load generator, the proxies and makit at once, so part of the added latency is waiting for a CPU — the report says how to measure makit alone): ![benchmark/run.sh http: makit in front, Caddy and Envoy asking makit, normal and attack traffic, no errors](https://github.com/runsnip/makit/blob/main/docs/img/bench-http.png) ## makit notify Alerts for bans and scan findings on Telegram, Slack, Google Chat, Discord, Microsoft Teams, ntfy, webhooks or email: ```bash makit notify add telegram --name ops --token BOT_TOKEN --chat-id CHAT_ID makit notify test ``` Guide: [docs/security/notifications.md](https://raw.githubusercontent.com/runsnip/makit/main/docs/security/notifications.md). ## Safety - **No lock-out.** `makit ssh` only disables passwords when root has a key in `/root/.ssh/authorized_keys`, validates the config with `sshd -t` before reloading (and reverts if invalid), then checks the effective setting with `sshd -T`. Its drop-in is `sshd_config.d/00-makit.conf`: sshd keeps the first value it reads, so a `99-…` file would lose to cloud-init's `50-cloud-init.conf`. The firewall always allows the port sshd actually listens on. - **No data loss.** Volumes are formatted only with `--format`, only when they have no filesystem, and only after a confirmation. Existing swap files and `daemon.json` are left untouched. - **Docker and ufw.** Ports published by Docker bypass ufw. Bind internal services to `127.0.0.1` in compose (`"127.0.0.1:5432:5432"`); publish only what must be public. ## Verify before running `makit.sh/install.sh` only picks the version and runs that release's own `install.sh` from GitHub, which checks the source and the `makit-core` binary against the release's `SHA256SUMS` before installing. To read everything first, take the release's installer straight from GitHub (pinned to a tag, never `main`): ```bash curl -fsSL https://raw.githubusercontent.com/runsnip/makit/v0.7.0/install.sh -o install.sh less install.sh bash install.sh ``` The installer puts each version in `/opt/makit/`, points `/opt/makit/current` at it and links `/usr/local/bin/makit`. ## Requirements Ubuntu 20.04+ or Debian 11+ (or derivatives), amd64 or arm64, run as root. ## License MIT — free for any use. ## Development ```bash tests/smoke.sh # makit in throwaway ubuntu:24.04 and debian:12 containers tests/scan-e2e.sh # replays a React2Shell-style compromise in Docker and checks every finding of makit scan scripts/build.sh # gofmt + vet + tests, then makit-core for linux/amd64 and arm64 into dist/ scripts/release.sh X.Y.Z # bump, tag, push, build and publish the GitHub release docker run --rm -v "$PWD:/mnt" -w /mnt koalaman/shellcheck:stable -x -s bash bin/makit lib/common.sh lib/cmd/*.sh install.sh ``` CI (GitHub Actions) runs all of the above on every push, plus `makit init` for real — twice — on Ubuntu 22.04 and 24.04 VMs, then checks with `makit list` that every part is in place. Shell commands are one file each in `lib/cmd/` defining `cmd_`; `bin/makit` dispatches to them. `makit top` and `makit scan` live in `core/` (Go, no cgo): `core/sys` reads `/proc` and the Docker socket, `core/top` is the dashboard, `core/scan` the scanner. ## Roadmap v0.6 brought the shield to clusters behind cloud load balancers, and v0.7 made it read whatever stands in front. Next is v0.8: bans pushed to more edges (Cloudflare Lists, Google Cloud Armor), more load balancer logs, and `makit scan` for pods and images. Everything planned, and what is not, is in [ROADMAP.md](https://raw.githubusercontent.com/runsnip/makit/main/ROADMAP.md) (also at https://makit.sh/docs.html?p=roadmap). --- # Request shield `makit shield` decides, for every request, whether the visitor may reach your app: its own **block set** (IPs and CIDRs, with expiry — no ipset needed), an **allowlist** that always wins, and **HTTP rules** that ban scanners and exploit attempts automatically. Every decision is recorded as a request snapshot. ## Two ways to use it **1. Caddy/nginx ask makit (recommended).** Your proxy keeps TLS and HTTP/3 and calls makit before each request. ```bash makit shield on # or: makit shield on --observe (log what would be blocked, block nothing) makit shield snippet caddy # or nginx — paste it, reload the proxy ``` Caddy (`import makit_shield` in each site): ``` (makit_shield) { forward_auth 127.0.0.1:9180 { uri /check header_up X-Forwarded-For "{http.request.header.X-Forwarded-For}, {remote_host}" copy_headers X-Makit-Client } } ``` The `X-Forwarded-For` line is what any proxy does when it forwards a request: the chain as received, plus the address it got the request from (Caddy alone would replace the chain unless it trusts that address; nginx's snippet uses `$proxy_add_x_forwarded_for`). makit needs nothing else from the proxy — no header of its own. makit answers with `X-Makit-Client` (the visitor it judged) and `X-Makit-Verdict`. They tell your infrastructure the request went through makit and what it found; whether they reach the app is the proxy's choice (`copy_headers` above, `auth_request_set` in nginx). makit promises nothing about the headers your app sees: when Caddy or nginx is the outer layer, only they set them. A header listed in `copy_headers` is replaced by makit's answer, so a value the visitor sent never reaches the app under that name. Caddy in Docker cannot reach the host's 127.0.0.1: set `admin: 172.17.0.1:9180` (the host's bridge address) in `/etc/makit/shield.yaml` and use that address in the snippet (`makit shield snippet caddy --addr 172.17.0.1:9180`). `/check` only answers callers on loopback or private networks. **2. makit in front of Caddy/nginx.** makit owns ports 80/443, terminates TLS (Let's Encrypt via TLS-ALPN, a Cloudflare Origin Certificate, or your files) and forwards allowed requests to the service on localhost. Blocked direct visitors are disconnected right after the TCP handshake. Configure `listeners` in `/etc/makit/shield.yaml` (`makit shield edit`); move Caddy/nginx to `127.0.0.1:8080`. HTTP/3 is not offered in this mode. `tcp://` upstreams pass any TCP service through after the IP check (with a PROXY v1 header when `proxy_protocol: true`). ### Gateways in Kubernetes ask makit The same ask mode works for the gateway in front of a cluster. `makit shield snippet` prints a ready setup: | Gateway | Command | How it asks | | --- | --- | --- | | Envoy Gateway (Gateway API) | `makit shield snippet envoy-gateway --gateway NAME --gateway-namespace NS` | `SecurityPolicy` `extAuth.http` + a `ReferenceGrant` | | Istio | `makit shield snippet istio` | `envoyExtAuthzHttp` provider + `AuthorizationPolicy` `CUSTOM` | | Envoy | `makit shield snippet envoy` | the `ext_authz` HTTP filter | | Traefik | `makit shield snippet traefik` | `forwardAuth` middleware | | ingress-nginx | `makit shield snippet ingress-nginx` | `auth-url` annotation (`?deny=403`: nginx passes only 401/403 on) | Envoy-based gateways send the auth service only a few headers unless told otherwise; the snippets list every header makit reads (`X-Forwarded-For`, `User-Agent`, `Accept-*`, `Sec-Fetch-Mode`, `Sec-CH-UA`, `Next-Action`, the Web Bot Auth signature headers, Cloudflare's) — without them a real browser would score like a script. Envoy asks on `/check/`; ingress-nginx sends the original URL in `X-Original-URL`; both are read as the visitor's request. The snippets fail open (`failOpen: true`, `failure_mode_allow`): if makit is unreachable, traffic goes on rather than the site going down — run two or more replicas with `/readyz`. ingress-nginx is retired upstream (no fixes after March 2026): prefer Envoy Gateway. Contour asks over gRPC only, which makit does not speak yet. In Kubernetes the admin address listens on the pod's address (`admin: 0.0.0.0:9180`); `/check`, `/status` and `/metrics` still answer only callers on private networks. ## The visitor's address: behind a CDN, a load balancer, or both makit reads what every proxy writes, whatever sits in front: `X-Forwarded-For` (else RFC 7239 `Forwarded`), a list each hop appends to — Cloudflare, CloudFront, Fastly, a DigitalOcean or AWS load balancer, HAProxy, nginx, Caddy: `, , …`. The left part is written by the visitor, so makit reads the list **from the right**: it skips the addresses of your trusted proxies and takes the first one that is not. A visitor who sends `X-Forwarded-For: 192.0.2.10` (an allowlisted address, or a random one to dodge a ban) is still judged on its real address. `X-Real-IP` counts only when there is no chain, from a trusted hop. A provider's own header — `CF-Connecting-IP`, `True-Client-IP`, `Fastly-Client-IP` — is never read. Any proxy behind the provider passes it on as it received it: with a load balancer between Cloudflare and the server, a client that skips Cloudflare and sends the balancer `CF-Connecting-IP: ` would choose its own address (or get that address banned). The chain carries the same visitor, appended by the provider itself. ```yaml trusted_proxies: [cloudflare, 10.104.0.0/20] # Cloudflare, then the load balancer's VPC subnet ``` Lock the origin so it only accepts web traffic from what is in front (provider firewall, or `ufw allow from `): a visitor who reaches it directly is judged on its own address, but skips whatever the CDN does. | `trusted_proxies` | Trusts | | --- | --- | | `cloudflare` | Cloudflare's published ranges, refreshed daily. | | `aws-alb`, `vpc` | The private ranges a VPC uses (10/8, 172.16/12, 192.168/16, 100.64/10, fc00::/7). AWS publishes no range for load balancer nodes: they take addresses in your subnets. List those subnets instead when other machines in the VPC can reach makit directly — anything trusted may name its own client. | | `loopback` | 127.0.0.0/8 and ::1, for a proxy on the same machine. | | CIDRs | Anything else, e.g. `203.0.113.0/28` for your own proxies. | Presets and CIDRs combine: `[cloudflare, aws-alb]` reads a chain Cloudflare → ALB → makit correctly. Every line of the header counts (a visitor cannot hide behind a second `X-Forwarded-For` line), and the walk stops after 16 hops. A trusted proxy is never banned automatically — a ban on it would block every visitor it carries — and `makit shield ban` refuses a range that overlaps one (`--force` to insist). In ask mode the asking proxy's own hop is the right-most `X-Forwarded-For` entry, so that proxy must append it (every snippet does; a hand-written nginx `auth_request` without `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for` passes the visitor's header unchanged, and the visitor would pick its own hop). Measured cost: ~270 ns and no allocation to resolve a three-hop chain against Cloudflare and the VPC ranges (`go test ./shield -bench ClientIPChain`, Apple M1). ### PROXY protocol (AWS NLB, HAProxy) A TCP load balancer does not touch HTTP, so there is no header to read: with PROXY protocol it puts the visitor's address in front of the connection instead. Turn it on for the listener behind it: ```yaml edge: true trusted_proxies: [aws-alb] # the NLB's subnets listeners: - name: web listen: ":443" upstream: http://127.0.0.1:8080 accept_proxy_protocol: true # v1 and v2; enable "Proxy protocol v2" on the NLB target group tls: { acme: [example.com] } ``` The header is read **only from trusted proxies**: from anyone else the bytes go on untouched, so a visitor who sends its own `PROXY TCP4
` line gets a broken request, never a new address. A trusted peer that sends no header (a TCP health check) and the `LOCAL` command keep the connection's own address; TLVs such as the AWS VPC endpoint id are skipped. The visitor is checked against bans and lists right after the header, before TLS. Headers are read off the accept loop with a 5-second limit, so a stalled connection cannot hold up the others; malformed headers are dropped and counted as `proxy-protocol-error` in `makit shield status`. With an NLB that preserves client IPs (IP targets, no PROXY protocol), the connection already comes from the visitor and nothing needs to be set. ## Several replicas behind one load balancer Behind a load balancer, requests from one visitor land on any replica. Each replica alone would count only its share: a rate limit of 60 a minute would let 60 × N through, and a scan spread over the pods would never escalate. With `cluster:` the replicas share what they learn: ```yaml cluster: listen: ":9181" # inside the cluster only peers: ["dns:makit-shield-headless.makit.svc.cluster.local:9181"] # or host:port, one per replica # secret: MAKIT_CLUSTER_SECRET in the environment (a Kubernetes Secret), or secret_file: /etc/makit/cluster.key sync: 250ms ``` - **Bans, unbans and allow entries** — automatic ones and those made with `makit shield ban/allow` on any replica — reach every replica at once, without waiting for the sync: ~2 ms on average, 31 ms at worst on localhost (`go test ./shield -bench ClusterBanPropagation`, Apple M1). Under a flood they travel in batches, at most 50 a second. - **Rate limits** count across replicas: windows are aligned on the clock, and each replica adds the others' counts to its own, so `limit 60/1m` stays 60 a minute for the whole cluster. A replica sees the others' requests one sync later, plus the time the counts take to travel, so a burst can get about (request rate × that delay) more through: at 10 requests a second and the default 250 ms, two or three on a quiet network, six measured on a loaded CI runner. - **Request scores** add up across replicas (suspicious requests, bursts), so a scan spread over the pods escalates and is banned as if it hit one. - A replica that starts copies the bans and allow entries of a running one first. **A decision never waits on the network.** Each replica decides from its own memory; changes travel in the background. Measured: deciding a request costs the same with and without a cluster (6.3–6.6 µs, 18 allocations, on the shared benchmark — `go test ./shield -bench DecideCluster`, Apple M1). If a peer cannot be reached, list changes wait for it (up to 200,000) and counts are dropped: they matter only for the current window. **What an attacker inside the network cannot do.** Every message is signed (HMAC-SHA256 with the shared secret, at least 32 characters: `openssl rand -hex 32`) over its time and body and carries a sequence number. A forged message, one older than 30 seconds, or a replayed one is refused and counted — otherwise anyone who reaches port 9181 could inflate a visitor's count to get it banned, or unban an attacker. Clocks must agree within 30 seconds (NTP; every cloud provides it). The listen port carries ban lists in clear text: keep it inside the cluster (a NetworkPolicy allowing only the makit pods). Peers listed by `dns:` are looked up every 15 seconds, so pods that come and go are followed; a replica finds its own address in the list and leaves it out. `makit shield status` lists the peers and how far each is behind; `/metrics` has `makit_shield_cluster_peer_sync_age_seconds` and the refused messages. Changing `cluster:` needs a restart. ## The set and the allowlist ```bash makit shield ban 198.51.100.7 --for 24h --reason "credential stuffing" makit shield ban 203.0.113.0/24 makit shield unban 198.51.100.7 makit shield allow 192.0.2.10 --reason office # never blocked (or `allow:` in shield.yaml) makit shield list makit shield check --peer 104.16.1.1 --client 198.51.100.7 --uri /admin # what would happen? ``` Lists live in `/var/lib/makit/shield/state.json`; the running gate picks up changes within two seconds. makit refuses to ban your own SSH address or a Cloudflare range (that would block every proxied visitor) unless you add `--force`. ## Rules HTTP rules come from the catalog (`security/http/*.yaml`), match method, path, user agent and headers, and ban the client for `ban_for`: | Rule | Bans | | --- | --- | | MK-HTTP-PROBE | Requests for `/.env`, `/.git/`, database dumps, `wp-login.php`, phpMyAdmin… (24h) | | MK-HTTP-TRAVERSAL | `../` and system-file requests (24h) | | MK-HTTP-SCANNER | sqlmap, nikto, nuclei, masscan… user agents (24h) | | MK-HTTP-R2S | Scripted `POST` with a `Next-Action` header — the React2Shell exploitation pattern (7 days) | | MK-HTTP-NEXT-MIDDLEWARE | `x-middleware-subrequest` from a client — the Next.js middleware bypass, CVE-2025-29927 (7 days) | | MK-HTTP-SPRING-CLOUD-FUNCTION | `spring.cloud.function.routing-expression` — SpEL injection, CVE-2022-22963 (7 days) | | MK-HTTP-STRUTS-OGNL | An OGNL expression in `Content-Type` — Apache Struts, CVE-2017-5638 (7 days) | | MK-HTTP-F5-ICONTROL | `/mgmt/tm/util/bash`, `/mgmt/shared/authn/login` — F5 BIG-IP, CVE-2022-1388 (7 days) | | MK-HTTP-FORTINET-AUTH | `User-Agent: Report Runner` on `/api/v2/` — Fortinet, CVE-2022-40684 (7 days) | | MK-HTTP-ACCEPT-TRAVERSAL | `../` in `Accept` — Rails file disclosure, CVE-2019-5418 (24h) | | MK-HTTP-REWRITE-URL | `X-Rewrite-URL` from a client — path override past access rules, Symfony CVE-2018-14773 (24h) | The header rules only name headers that browsers, crawlers, CDNs and load balancers never send, and each is replayed from its public proof of concept in the tests, next to real browser, CDN and API traffic that must pass (`go test ./shield -run Header`). Two header exploits are scored instead (see [Scoring](#scoring)): Shellshock (`() { :; };` at the start of any header, critical) and `X-Original-URL` (40: some gateways set it themselves). In ask mode, what the asking proxy writes about the request — `X-Forwarded-Uri`/`-Method`/`-Host`, ingress-nginx's `X-Original-URL` — is not the visitor's and is not matched. A Next.js middleware that `fetch()`es its own public URL sends `x-middleware-subrequest` too: call it by its internal address, or put the server's address in `allow:`. Caddy 2.11 and later drop a header whose name has a dot (`spring.cloud.function.routing-expression`) on receipt, so behind them that exploit never reaches makit or the app; Caddy 2.8, HAProxy and makit at the edge pass it, and the rule stops it. A server that hosts WordPress should override MK-HTTP-PROBE (copy it into your own catalog with `disabled: true` or without the WordPress paths) — see [the catalog](https://raw.githubusercontent.com/runsnip/makit/main/security/README.md). ## Scoring Rules ban on one unmistakable request. Scoring catches the rest: every request gets points from the signals it matches, and each IP keeps a score over a window. The scoring set is part of the online catalog ([`security/scoring/http.yaml`](https://github.com/runsnip/makit/blob/main/security/scoring/http.yaml)) and updates with `makit rules update`. - **Request score** — the sum of the signals that match (each counted once, capped at 200). Values are decoded first (URL encoding up to three layers, HTML entities, NUL bytes), so `%253Cscript%253E` is seen as `