Erlang distribution listens on every interface with the cookie this repo publishes (mcl_mail on 0.0.0.0, cookie mcl_mail) #17

Open
opened 2026-11-23 13:52:31 +00:00 by uranus · 2 comments
Member

Purpose (defect): mcl-mail's Erlang distribution listens only on loopback, and no shipped file names a cookie, so a self-hoster who follows this repo's compose file does not expose a node that anyone holding a published cookie can drive.

What is wrong (measured 2026-11-23)

  • config/vm.args.src:2-3 names the node ${MCL_NODE_NAME}@${MCL_NODE_HOST} and sets -setcookie ${MCL_COOKIE}. It has no -kernel inet_dist_use_interface, and the image sets no ERL_EPMD_ADDRESS.
  • deploy/docker-compose.yml:35 runs network_mode: host, and :70 hard-codes MCL_COOKIE=mcl_mail. README.md:213 gives the same default.
  • On beam02.lab, epmd -names inside the container reads name mcl_mail at port 36413, and ss -ltn on the host shows 0.0.0.0:36413 and 0.0.0.0:4369. mcl_chess on the same box is at 127.0.0.1:46805.
  • So a node started from this repo's compose file listens on every interface with a cookie published in this repository. A distribution connection with the cookie runs any code in the node. I have not attempted a connection; the listener and the published cookie are what was measured.

The fleet is less exposed: macula-fleet's edge/scripts/docker-compose.mcl-mail.yml:33-34 takes a random per-box cookie from the box's secrets. The listener on every interface is the same there.

The fix already exists in the class

mcl-chess carries it (its architecture/README.md, "Distribution stays, bound to loopback, with the cookie from the box, never the image", from mcl-om#24): ERL_EPMD_ADDRESS=127.0.0.1 in the image, -kernel inet_dist_use_interface {127,0,0,1} in vm.args.src, the compose file refusing to start without ${MCL_COOKIE:?}, and a service test asserting all three.

Done when

  • ss -ltn on a box running mcl-mail shows its dist port and epmd on 127.0.0.1 only.
  • No shipped file (compose, README, image) carries a cookie value, and the compose file refuses to start without one.
  • A test asserts the three pins, as mcl_chess_service_tests does.

Found while measuring #16 (self-hosting). Every other mcl-* service on a host network may need the same check; that is not part of this issue.

Purpose (defect): mcl-mail's Erlang distribution listens only on loopback, and no shipped file names a cookie, so a self-hoster who follows this repo's compose file does not expose a node that anyone holding a published cookie can drive. ## What is wrong (measured 2026-11-23) - `config/vm.args.src:2-3` names the node `${MCL_NODE_NAME}@${MCL_NODE_HOST}` and sets `-setcookie ${MCL_COOKIE}`. It has no `-kernel inet_dist_use_interface`, and the image sets no `ERL_EPMD_ADDRESS`. - `deploy/docker-compose.yml:35` runs `network_mode: host`, and `:70` hard-codes `MCL_COOKIE=mcl_mail`. README.md:213 gives the same default. - On beam02.lab, `epmd -names` inside the container reads `name mcl_mail at port 36413`, and `ss -ltn` on the host shows `0.0.0.0:36413` and `0.0.0.0:4369`. mcl_chess on the same box is at `127.0.0.1:46805`. - So a node started from this repo's compose file listens on every interface with a cookie published in this repository. A distribution connection with the cookie runs any code in the node. I have not attempted a connection; the listener and the published cookie are what was measured. The fleet is less exposed: macula-fleet's `edge/scripts/docker-compose.mcl-mail.yml:33-34` takes a random per-box cookie from the box's secrets. The listener on every interface is the same there. ## The fix already exists in the class mcl-chess carries it (its `architecture/README.md`, "Distribution stays, bound to loopback, with the cookie from the box, never the image", from mcl-om#24): `ERL_EPMD_ADDRESS=127.0.0.1` in the image, `-kernel inet_dist_use_interface {127,0,0,1}` in `vm.args.src`, the compose file refusing to start without `${MCL_COOKIE:?}`, and a service test asserting all three. ## Done when - `ss -ltn` on a box running mcl-mail shows its dist port and epmd on 127.0.0.1 only. - No shipped file (compose, README, image) carries a cookie value, and the compose file refuses to start without one. - A test asserts the three pins, as mcl_chess_service_tests does. Found while measuring #16 (self-hosting). Every other mcl-* service on a host network may need the same check; that is not part of this issue.
Member

Step 1, reachability probe (read-only), 2026-11-23, by Jupiter.

Result: reachable from the LAN, not from the internet. Dist 36413 (v4) and epmd 4369 (v4 and v6) answer from other LAN hosts. From two internet VPSes, both the router's public v4 and beam02's global v6 time out (filtered), and a positive control shows those VPSes do reach the internet on v4 and v6.

Listeners on beam02

$ ssh -n beam02 'sudo -n ss -ltnpH "( sport = :36413 or sport = :4369 )"'
LISTEN 0 128   0.0.0.0:36413 0.0.0.0:*  users:(("beam.smp",pid=1734645,fd=23))
LISTEN 0 4096  0.0.0.0:4369  0.0.0.0:*  users:(("epmd",pid=1710,fd=3))
LISTEN 0 4096     [::]:4369     [::]:*  users:(("epmd",pid=1710,fd=4))
$ ssh -n beam02 'sudo -n iptables -S INPUT; sudo -n ip6tables -S INPUT; sudo -n nft list ruleset'
-P INPUT ACCEPT
-P INPUT ACCEPT
sudo: nft: command not found
$ ssh -n beam02 'ip -br addr'   (relevant line)
enp3s0  UP  192.168.1.12/20 2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b/64 fe80::21e:6ff:fe45:2d3b/64
$ ssh -n beam02 'sudo -n docker inspect -f "{{.Name}} {{.HostConfig.NetworkMode}}" 25688a9d790b'
/mcl-mail host

pid 1734645 is /app/bin/mcl_mail ... -boot /app/releases/0.6.1/start in container 25688a9d790b. The host's epmd (pid 1710) is what holds 4369 on v4 and v6.

LAN (probe = timeout 5 bash -c "</dev/tcp/$h/$p")

=== host00.lab
v4 36413 OPEN
v4 4369 OPEN
v6 4369 OPEN        (2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b)
=== msi00.lab
192.168.1.12 port 36413 OPEN
192.168.1.12 port 4369 OPEN
2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 4369 OPEN
2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 36413 closed (rc=1)

Internet

The home's public v4 was read from the VPS side, as ssh -4 nuremberg 'echo ${SSH_CLIENT%% *}', which gave 109.133.95.139.

=== relays-hetzner-nuremberg
2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 4369 closed (rc=124)
2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 36413 closed (rc=124)
109.133.95.139 port 4369 closed (rc=124)
109.133.95.139 port 36413 closed (rc=124)
=== paris (relays-linode-paris)
(same four lines, all rc=124)

Positive control from the same VPS:

=== relays-hetzner-nuremberg
2600:3c1a::2000:71ff:fea3:f1e5 port 22 OPEN   (paris v6)
172.232.219.239 port 22 OPEN                  (paris v4)

rc=124 is a timeout, so the packets are dropped (filtered) at the router, not refused. Even beam02's v6 port 22 times out from outside (rc=124).

The live node does not run the published mcl_mail. Its -setcookie value is a 62-character string that comes from the container env (env | grep -ic cookie = 1), which matches the fleet compose's per-box secret. So the repo-published cookie does not open beam02. Anyone on the LAN who learns the real cookie does get in, because the listener is on every interface. The value is not reproduced here.

What this means

  • Not internet-exposed today. That rests on the router's inbound filter on v4 and v6, not on anything on beam02 (INPUT ACCEPT, no nft).
  • LAN-exposed: any LAN device can reach dist and epmd.
  • The box action (a beam02 firewall rule before the release) is the Supervisor's call. The fix itself is step 2 (loopback bind, ERL_EPMD_ADDRESS=127.0.0.1, ${MCL_COOKIE:?}, a fresh cookie on beam02).
Step 1, reachability probe (read-only), 2026-11-23, by Jupiter. **Result: reachable from the LAN, not from the internet.** Dist 36413 (v4) and epmd 4369 (v4 and v6) answer from other LAN hosts. From two internet VPSes, both the router's public v4 and beam02's global v6 time out (filtered), and a positive control shows those VPSes do reach the internet on v4 and v6. ### Listeners on beam02 ``` $ ssh -n beam02 'sudo -n ss -ltnpH "( sport = :36413 or sport = :4369 )"' LISTEN 0 128 0.0.0.0:36413 0.0.0.0:* users:(("beam.smp",pid=1734645,fd=23)) LISTEN 0 4096 0.0.0.0:4369 0.0.0.0:* users:(("epmd",pid=1710,fd=3)) LISTEN 0 4096 [::]:4369 [::]:* users:(("epmd",pid=1710,fd=4)) $ ssh -n beam02 'sudo -n iptables -S INPUT; sudo -n ip6tables -S INPUT; sudo -n nft list ruleset' -P INPUT ACCEPT -P INPUT ACCEPT sudo: nft: command not found $ ssh -n beam02 'ip -br addr' (relevant line) enp3s0 UP 192.168.1.12/20 2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b/64 fe80::21e:6ff:fe45:2d3b/64 $ ssh -n beam02 'sudo -n docker inspect -f "{{.Name}} {{.HostConfig.NetworkMode}}" 25688a9d790b' /mcl-mail host ``` pid 1734645 is `/app/bin/mcl_mail ... -boot /app/releases/0.6.1/start` in container 25688a9d790b. The host's epmd (pid 1710) is what holds 4369 on v4 and v6. ### LAN (probe = `timeout 5 bash -c "</dev/tcp/$h/$p"`) ``` === host00.lab v4 36413 OPEN v4 4369 OPEN v6 4369 OPEN (2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b) === msi00.lab 192.168.1.12 port 36413 OPEN 192.168.1.12 port 4369 OPEN 2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 4369 OPEN 2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 36413 closed (rc=1) ``` ### Internet The home's public v4 was read from the VPS side, as `ssh -4 nuremberg 'echo ${SSH_CLIENT%% *}'`, which gave `109.133.95.139`. ``` === relays-hetzner-nuremberg 2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 4369 closed (rc=124) 2a02:a03f:8b7b:1200:21e:6ff:fe45:2d3b port 36413 closed (rc=124) 109.133.95.139 port 4369 closed (rc=124) 109.133.95.139 port 36413 closed (rc=124) === paris (relays-linode-paris) (same four lines, all rc=124) ``` Positive control from the same VPS: ``` === relays-hetzner-nuremberg 2600:3c1a::2000:71ff:fea3:f1e5 port 22 OPEN (paris v6) 172.232.219.239 port 22 OPEN (paris v4) ``` rc=124 is a timeout, so the packets are dropped (filtered) at the router, not refused. Even beam02's v6 port 22 times out from outside (rc=124). ### Cookie actually running The live node does not run the published `mcl_mail`. Its `-setcookie` value is a 62-character string that comes from the container env (`env | grep -ic cookie` = 1), which matches the fleet compose's per-box secret. So the repo-published cookie does not open beam02. Anyone on the LAN who learns the real cookie does get in, because the listener is on every interface. The value is not reproduced here. ### What this means - Not internet-exposed today. That rests on the router's inbound filter on v4 and v6, not on anything on beam02 (INPUT ACCEPT, no nft). - LAN-exposed: any LAN device can reach dist and epmd. - The box action (a beam02 firewall rule before the release) is the Supervisor's call. The fix itself is step 2 (loopback bind, `ERL_EPMD_ADDRESS=127.0.0.1`, `${MCL_COOKIE:?}`, a fresh cookie on beam02).
Member

Note: while I checked the cookie for step 1, part of the live cookie printed into my local session output (not posted anywhere). The rollout of this fix makes a fresh cookie on beam02, which retires it.

Note: while I checked the cookie for step 1, part of the live cookie printed into my local session output (not posted anywhere). The rollout of this fix makes a fresh cookie on beam02, which retires it.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
macula-services/mcl-mail#17
No description provided.