feat(edge): Anubis PoW gate behind stage.ymrtech.com (rung 2, NCFG#1990) #2979
No reviewers
Labels
No labels
backlog
bug
enhancement
in-progress
library
needs-rebase
review
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ymrtech/nix-config!2979
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "kb/NCFG-1990-anubis-pow-rung2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Rung 2 of the edge ladder in nix-config#1984: put the challenge arm in front of one vhost,
stage.ymrtech.com, and prove the exempt arm still gets the origin byte-identically before anything is widened.Card: nix-config#1990 (parent nix-config#1984).
What lands
hosts/common/optional/anubis-challenge.nix(new) —fleet.edgeChallenge:blockis the Caddyfile fragment a challenge-classified vhost prepends: named matchers for the internal/external split plus onehandle. Ahandlerather than a barereverse_proxybecause Caddy orders a bare proxy after every handle block, so a handle-routed vhost would serve those paths to a challenged client unproxied.internalCidrsdefers tofleet.edgeLimits.internalCidrsinstead of copying it — "our own traffic" must mean one thing across limiting, CrowdSec whitelisting and challenging.http-01is exempt from the challenge (a challenge page answered to a CA is a renewal failure; the edge limiter exempts the same path).header_up X-Real-Ip {http.request.remote.host}— Anubis readsX-Real-Ipand does not fall back toX-Forwarded-For; with neither set it answers 500 to every request (measured), i.e. a missing header is the gate failing closed on real visitors.REDIRECT_DOMAINSpinned to the vhost name — unset, Anubis honours anyredira client passes topass-challenge.hosts/public/default.nix— enables the option, names the origin (https://11.0.0.7:443, Host/SNIstage.ymrtech.com) and prefixes thestage.ymrtech.comvhost with the fragment.Blast radius
The vhost keeps its WG0-only listen set (nix-config#1221): every source that can reach it today is in the exempt set, so the challenged arm is armed and unexercised and nothing a client can reach changes. What a deploy can regress is the exempt arm — hence the card's proof is that the mesh request is still byte-identical.
Verified before commit (local, real binaries)
Fleet's own aarch64 Caddy 2.11.4 + caddy-ratelimit and Anubis 1.27.0, one sandbox vhost carrying the generated fragment:
caddy adaptorder/preview/*,/account*, fallback127.0.0.0/8Making sure you're not a bot!,main.mjs/account/login/.well-known/acme-challenge/*nix evalpublicanubis-stagepresent with expected envLive verification on the host after deploy is recorded on the card.
Rung 2 of the edge ladder in nix-config#1984: prove the challenge arm before anything is widened. One vhost is challenge-classified — stage.ymrtech.com — and the module, not the vhost, owns every part of the gate, so a second vhost cannot drift from the first. `hosts/common/optional/anubis-challenge.nix` (new) exposes `fleet.edgeChallenge`: - `block` is the Caddyfile fragment a classified vhost prepends: named matchers for the internal/external split plus ONE `handle`. A `handle` and not a bare `reverse_proxy`, because Caddy orders a bare proxy AFTER every handle block — a vhost whose paths are handle-routed (this fleet's are) would then serve those paths to a challenged client unproxied. Handles are mutually exclusive and run in written order, so first means an external request reaches nothing else. - `internalCidrs` DEFERS to `fleet.edgeLimits.internalCidrs` rather than copying it: "our own traffic" must mean one thing across limiting, CrowdSec whitelisting and challenging. - ACME http-01 is exempt from the challenge. A challenge page answered to a CA is a certificate renewal failure. - The reverse_proxy sets `X-Real-Ip` from the client address. Anubis reads X-Real-Ip and does not fall back to X-Forwarded-For; with neither set it answers 500 to every request (measured), i.e. an unset header is the gate failing closed on real visitors. - `REDIRECT_DOMAINS` is pinned to the vhost name: unset, Anubis honours any `redir` a client passes to `pass-challenge`. The origin leg is the host's own vhost over loopback-by-IP, so a passed request re-enters the same vhost, matches the internal arm and is answered by the routes that were already there — no second route table to drift. `hosts/public/default.nix`: enables the option, names that origin (https://11.0.0.7:443, Host/SNI stage.ymrtech.com) and prefixes the stage.ymrtech.com vhost with the fragment. Rung 2 changes nothing a client can reach: the vhost keeps its WG0-only listen set (nix-config#1221), so every source that can reach it is in the exempt set and the challenged arm is armed and unexercised. What a deploy can regress is the exempt arm, which is why the card's proof is that the mesh request is still byte-identical. Verified locally before commit, with the fleet's own aarch64 Caddy 2.11.4 + caddy-ratelimit and Anubis 1.27.0, both arms on one sandbox vhost: - caddy adapt: the external handle is subroute index 0, ahead of /preview/*, /account* and the fallback; - source in 127.0.0.0/8 -> origin body byte-identical, no challenge; - source outside the set -> Anubis PoW page (200, title "Making sure you're not a bot!", main.mjs), and /account/login from that source reaches Anubis, never the portal proxy; - a passed request comes back with the origin body (the loopback leg); - /.well-known/acme-challenge/* still passes through; - nix eval of nixosConfigurations.public: toplevel drv evaluates, unit anubis-stage present with the expected environment.0dc32d990a92b4ef77cd