No description
  • Erlang 78.5%
  • Python 14.2%
  • Dockerfile 4.4%
  • Shell 2.9%
Find a file
2026-11-24 01:13:13 +01:00
.github ci: call the C4 gate that reads the front page 2026-10-23 21:10:12 +02:00
apps/mcl_warden The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:15 +01:00
architecture 0.4.0: macula 18 and mcl_om 1.6 (mcl-om#42) 2026-10-30 15:36:08 +01:00
assets 0.4.0: macula 18 and mcl_om 1.6 (mcl-om#42) 2026-10-30 15:36:08 +01:00
config The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:15 +01:00
deploy The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:15 +01:00
scripts The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:15 +01:00
.gitignore scaffold: rebar3 new mcl_service, from mcl_om 1c8321b's template 2026-09-23 12:39:16 +02:00
.tool-versions build: mcl_om 0.27 and the team image pair; the claim names the service and its box 2026-09-24 02:17:09 +02:00
CHANGELOG.md 0.4.0: macula 18 and mcl_om 1.6 (mcl-om#42) 2026-10-30 15:36:08 +01:00
Containerfile The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:15 +01:00
LICENSE scaffold: rebar3 new mcl_service, from mcl_om 1c8321b's template 2026-09-23 12:39:16 +02:00
README.md README: drop the GitHub Sponsors badge 2026-11-23 22:20:55 +00:00
rebar.config fix: rebar.config no longer claims the fleet is already on macula 18 (mcl-om#42 R2) 2026-10-30 20:27:20 +01:00
SECURITY.md SECURITY.md: response times, attachment and identity rules, drills (macula-io/macula#174) 2026-10-31 02:59:52 +01:00

mcl-warden

CI License ghcr.io BEAM Buy Me a Coffee

Macula

Deceptive threshold guard: senses intrusion attempts on a public box and reports them to the threat commons.


This exists so every public box contributes what it is being attacked with to a shared commons, and every box sees a campaign before it reaches the next door.

Status

Released as 0.2.0 on macula 14.2 through mcl_om 0.38. It replaces the macula 10 warden service and inherits nothing from it: no identity, no volume, no topic.

0.3.0 moves it to wire 1.0: macula 15.6 through mcl_om 1.0. The flag day (macula-io/macula-fleet#27) is past: edge/gitops/release-targets pins this image 0.3.0 on twelve boxes, canary first and the rest after it.

0.4.0 moves it to macula 18 through mcl_om 1.6, on the same wire 1.0, so a box that takes it talks to every wire 1.0 box it talked to before. Nothing an operator does changes: same config, same facts, and /health gains the empty subscriptions map every mcl_om 1.6 service carries. The warden runs on every station box, so the pin follows the release the way 0.3.0's did — each box takes the signed tag when macula-fleet pins it, canary first and the rest after it.

What it does

  • Senses. Tails the host's auth log (mounted read-only) for failed logins on the box's real sshd, IPv4 and IPv6. When one source address fails 5 times in 5 minutes it publishes attacker_sighted: the address, the count and the usernames tried. The same address is reported again at most every 10 minutes.
  • Ensnares (opt-in). Binds decoy ports (IPv4 only for now) and holds each connection open with an endless, slow stream of junk lines that an SSH client waits through before the banner it never gets. When the attacker gives up it publishes attacker_ensnared with how long it was held. Capped at MCL_WARDEN_MAX_CONNS held connections; past the cap a connection is closed.
  • Checks in every 60 s with warden_checked_in, so a consumer builds its roster live.

It never blocks, never stores or forwards the log, and holds no event store. Popped, an attacker gains a threat reporter for one box.

Mode Ports opened Risk added
Sensing-only (default) none none: it reads a log that is already written
Tarpit the decoy ports you list those ports

Never put the tarpit on the real sshd port unless admin SSH has moved first.

The fact contract

Three canonical macula app facts, org mcl-warden, app warden, domain watch, published in the realm the node is configured for:

Topic When
<realm>/mcl-warden/warden/watch/attacker_sighted_v1 a source crossed the threshold on the real sshd
<realm>/mcl-warden/warden/watch/attacker_ensnared_v1 the tarpit held a connection until it gave up
<realm>/mcl-warden/warden/watch/warden_checked_in_v1 heartbeat

<realm> is the realm name, for example io.macula.

Fact Keys
attacker_sighted source_ip, service (ssh), attempts, window_s, usernames (list), at_ms
attacker_ensnared source_ip, held_ms, at_ms
warden_checked_in tarpit (1/0), interval_s, at_ms, optional lat_e6, lng_e6

Every fact also carries tenant_id (which organisation runs it) and label (which box) when they are set, and omits them when they are not.

Rules a consumer can rely on:

  • The sender is not in the payload. macula delivers every event with the publisher its link verified, which is this warden's stored node identity. Attribute and allowlist by that. tenant_id and label are self-asserted display attribution.
  • Values are binaries, integers and lists of binaries. No booleans (tarpit is 1/0), no floats (coordinates are integer micro-degrees), no atoms.
  • source_ip is canonical: IPv6 is lower-case and compressed, and an IPv4-mapped address (::ffff:a.b.c.d) is reported as the IPv4 address, so one attacker is one key wherever it was seen.
  • at_ms is milliseconds since the epoch.
  • A change to any of this is a new _v2 topic, not an edit. The contract is pinned in apps/mcl_warden/test/mcl_warden_facts_tests.erl.

Like every mcl service, it also answers the open procedures mcl_om adds: mcl-warden/info gives its name, version and description, its org and claim labels, node id, the macula and mcl_om versions, uptime, the health word and the procedures it advertises; mcl-warden/get_limits gives the inbound guard's limits and current-window stats. Open to any mesh caller, public facts only.

Configuration

Variable Default Meaning
MCL_REALM required 64-hex realm tag, sha256 of the realm name
MCL_REALM_NAME required the realm name the topics carry, e.g. io.macula. The service refuses to start unless its sha256 is MCL_REALM
MCL_REALM_KEY required the realm's public signing key, hex. The trust anchor, public material
MACULA_STATION_SEEDS required station hosts, host[:port], comma-separated
MACULA_STATION_NODE_IDS required the matching 64-hex station node ids, index-paired
MCL_WARDEN_TENANT_ID unset who runs this warden, shown on every fact
MCL_SERVICE_NAME mcl-warden label on the boot claim the realm's operator sees on the Providers desk
MCL_BOX unset which box: on the boot claim, and on every fact as the warden's label
MCL_WARDEN_LAT_E6 / MCL_WARDEN_LNG_E6 unset declared map position, integer micro-degrees (for example 60170000 / 24940000). Self-asserted
MCL_WARDEN_TARPIT_PORTS [] decoy ports as an Erlang list, e.g. [2222,2323]. [] opens nothing
MCL_WARDEN_MAX_CONNS 65536 most tarpit connections held at once
MCL_WARDEN_AUTH_LOG /host/log/auth.log the log inside the container. RHEL family: /host/log/secure
MCL_WARDEN_LOG_DIR /var/log (compose) the host directory mounted read-only at /host/log
(none) /run/mcl/health.sock /health is served on this Unix socket inside the container (mcl_om health_socket); no health port is bound. scripts/health.sh asks it.

Two mounts matter, and deploy/docker-compose.yml has both:

  • The log directory, not the log file. A file bind-mount pins the inode, so after the first logrotate the sensor reads a file that never grows again.
  • A named volume at /etc/mcl/secrets. It holds the node identity key, which is the warden's verified identity on the mesh. Without the volume every recreate mints a new identity and every consumer that knew the warden forgets it.

Admission

None. There is no admission step: a warden links on the PQ profile and the identity puzzle, and invite-only is not enforced. A publish is refused only when its realm does not match.

Node id

At start the warden logs [warden] node id: <64 hex>. That is the id every consumer sees as this warden's verified publisher, and the one to list in mcl-sentinel's MCL_SENTINEL_WARDENS. It is stable as long as the identity volume is.

Health

/health reports the sensor, because a warden that is alive but blind looks exactly like a quiet night:

  • down when the log is missing or unreadable (usually the mount) or the sensor is not answering;
  • degraded when a sensor that has been reading has seen nothing for an hour;
  • ok otherwise, including a fresh start on a box that has had no traffic yet.

A dark mesh is not a health failure: the warden keeps sensing and drops the facts it cannot publish.

scripts/health.sh [container] asks a running node, over its health socket.

Deploy

What an operator does, in order:

  1. Set MCL_REALM (the 64-hex tag) and MCL_REALM_NAME (io.macula); the warden refuses to start unless sha256 of the name is the tag.
  2. Mount the host's log directory read-only and a named volume at /etc/mcl/secrets (both are in deploy/docker-compose.yml).
  3. Start it and read [warden] node id: <64 hex> from the log. Add that id to mcl-sentinel's MCL_SENTINEL_WARDENS, or the sentinel ignores this warden.
  4. Leave MCL_WARDEN_TARPIT_PORTS=[] unless decoy ports are open in the firewall.

Build and test

rebar3 eunit
rebar3 lint

OTP 28.4.3, pinned in .tool-versions, the Containerfile and CI, and a test fails when they disagree with the VM running it. The image builds in the team's ghcr.io/macula-io/macula-ci-otp and runs on ghcr.io/macula-io/macula-pq-runtime (Debian trixie, OpenSSL with ML-DSA), both pinned by dated tag and digest; CI runs in the same build image. macula's NIFs build from source there.

Deployment

A v* tag publishes ghcr.io/macula-services/mcl-warden:<version> and nothing else, signed by digest with its SBOM and provenance (macula-ci-images' attest-image.yml). A push to main publishes :main and :<sha>, which no box follows. Nothing moves :latest at all. The fleet runs a release by digest: macula-fleet's pin-releases workflow finds the signed release, verifies it was signed on its tag and pins <version>@sha256:<digest> (macula-fleet#14, #15), so a green v* tag is the deploy. To roll back, revert the pin and hold the image there.

Architecture

The C4 model is in architecture/README.md, with its diagrams drawn by architecture/c4_diagrams.py into assets/. Change the script, run it (python3 architecture/c4_diagrams.py), and look at the result before committing.

mcl-warden system context

License

Apache-2.0. See LICENSE.