- Erlang 78.5%
- Python 14.2%
- Dockerfile 4.4%
- Shell 2.9%
| .github | ||
| apps/mcl_warden | ||
| architecture | ||
| assets | ||
| config | ||
| deploy | ||
| scripts | ||
| .gitignore | ||
| .tool-versions | ||
| CHANGELOG.md | ||
| Containerfile | ||
| LICENSE | ||
| README.md | ||
| rebar.config | ||
| SECURITY.md | ||
mcl-warden
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_ensnaredwith how long it was held. Capped atMCL_WARDEN_MAX_CONNSheld 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_idandlabelare self-asserted display attribution. - Values are binaries, integers and lists of binaries. No booleans (
tarpitis 1/0), no floats (coordinates are integer micro-degrees), no atoms. source_ipis 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_msis milliseconds since the epoch.- A change to any of this is a new
_v2topic, not an edit. The contract is pinned inapps/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:
downwhen the log is missing or unreadable (usually the mount) or the sensor is not answering;degradedwhen a sensor that has been reading has seen nothing for an hour;okotherwise, 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:
- Set
MCL_REALM(the 64-hex tag) andMCL_REALM_NAME(io.macula); the warden refuses to start unless sha256 of the name is the tag. - Mount the host's log directory read-only and a named volume at
/etc/mcl/secrets(both are indeploy/docker-compose.yml). - Start it and read
[warden] node id: <64 hex>from the log. Add that id to mcl-sentinel'sMCL_SENTINEL_WARDENS, or the sentinel ignores this warden. - 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.
License
Apache-2.0. See LICENSE.