Distribution and epmd on loopback, no cookie in any shipped file (#1) #2

Closed
jupiter wants to merge 0 commits from jupiter/1-dist-loopback into main
Member

Refs #1

Distribution and epmd are bound to loopback, and no shipped file carries a cookie. This is the same change as macula-services/mcl-mail PR 18 (mcl-mail#17), so every mcl-* service can copy one pattern.

  • config/vm.args.src: -kernel inet_dist_use_interface {127,0,0,1}, so the dist listener binds 127.0.0.1.
  • Containerfile: ENV MCL_COOKIE=mcl_tube is gone. ENV ERL_EPMD_ADDRESS=127.0.0.1 is added, and the entry point is /app/start.sh (CMD foreground).
  • scripts/start.sh: takes MCL_COOKIE if the box sets it (the fleet passes each box's secret). Otherwise it reads /etc/mcl/secrets/erlang.cookie, the identity volume beside the node key, creating it on first start from 32 random bytes (hex, umask 077, so 0600). A remote shell: docker exec -it mcl-tube /app/start.sh remote_console.
  • deploy/docker-compose.yml: MCL_COOKIE=${MCL_COOKIE:-}, no default.
  • Tests (mcl_tube_service_tests): one pins the four lines and the missing cookie, and one runs start.sh. 33/33 pass in the pinned CI image. The test code is the same as mcl-mail PR 18's, where dropping the inet_dist line or the umask turns a test red.

On beam02 the box's shared epmd (0.0.0.0:4369, [::]:4369) belongs to this container. With this change it moves to 127.0.0.1 for every BEAM service on the box.

Not in this PR: the fleet's per-box cookie, and the 0.0.0.0:8493 listener measured on beam02 (not dist).

Refs #1 Distribution and epmd are bound to loopback, and no shipped file carries a cookie. This is the same change as macula-services/mcl-mail PR 18 (mcl-mail#17), so every mcl-* service can copy one pattern. - `config/vm.args.src`: `-kernel inet_dist_use_interface {127,0,0,1}`, so the dist listener binds 127.0.0.1. - `Containerfile`: `ENV MCL_COOKIE=mcl_tube` is gone. `ENV ERL_EPMD_ADDRESS=127.0.0.1` is added, and the entry point is `/app/start.sh` (CMD `foreground`). - `scripts/start.sh`: takes `MCL_COOKIE` if the box sets it (the fleet passes each box's secret). Otherwise it reads `/etc/mcl/secrets/erlang.cookie`, the identity volume beside the node key, creating it on first start from 32 random bytes (hex, umask 077, so 0600). A remote shell: `docker exec -it mcl-tube /app/start.sh remote_console`. - `deploy/docker-compose.yml`: `MCL_COOKIE=${MCL_COOKIE:-}`, no default. - Tests (`mcl_tube_service_tests`): one pins the four lines and the missing cookie, and one runs `start.sh`. 33/33 pass in the pinned CI image. The test code is the same as mcl-mail PR 18's, where dropping the inet_dist line or the umask turns a test red. On beam02 the box's shared epmd (`0.0.0.0:4369`, `[::]:4369`) belongs to this container. With this change it moves to 127.0.0.1 for every BEAM service on the box. Not in this PR: the fleet's per-box cookie, and the `0.0.0.0:8493` listener measured on beam02 (not dist).
The same change as mcl-mail#17. vm.args.src binds the dist listener to
127.0.0.1, and the image sets ERL_EPMD_ADDRESS=127.0.0.1; on a shared host
the epmd mcl-tube starts is the one every BEAM service uses. The
Containerfile and compose no longer carry MCL_COOKIE=mcl_tube.
scripts/start.sh uses MCL_COOKIE when the box gives one, or else makes a
random cookie on first start in /etc/mcl/secrets/erlang.cookie (0600).
Two service tests pin the files and run start.sh.
Member

VERDICT macula-services/mcl-tube#1 0c8b0806..fa28309c r=1 PASS (Mars, fable security review). The same change as mcl-mail PR 18: the diffs differ only in Containerfile context, the issue number and the README row.

  • No cookie literal remains in any shipped file. Only -setcookie ${MCL_COOKIE} (vm.args.src:10) and the compose pass-through are left.
  • The bind holds on both halves, measured on an OTP 28.5 scratch node with the same settings: beam.smp listens on 127.0.0.1 only, epmd on 127.0.0.1 and ::1 only. The dist bind sits in vm.args.src, so it holds even if start.sh is bypassed; a bypass then gets a random ~/.erlang.cookie, never a published one.
  • start.sh draws from /dev/urandom, writes under umask 077 (0600 from the first byte), treats an empty MCL_COOKIE as unset, never echoes the cookie, and exits rc=1 on an unwritable secrets dir.
  • No breakage: no net_kernel/rpc use, and fleet compose already supplies MCL_COOKIE.
    Notes (not required):
  • (a) The cookie is visible in ps argv, as it was before this PR.
  • (b) On beam02, ERL_EPMD_ADDRESS only takes effect in the process that starts epmd, so the shared 4369 is loopback only once every host-networked node carries it and epmd restarts.
  • (c) start.sh:15-16: a pre-existing EMPTY cookie file keeps its old mode, the write is not atomic, and if od fails the cookie comes out empty. Worth folding into the template before the 21-repo batch: chmod 600, refuse an empty result, and write via a temp file plus mv.
VERDICT macula-services/mcl-tube#1 0c8b0806..fa28309c r=1 PASS (Mars, fable security review). The same change as mcl-mail PR 18: the diffs differ only in Containerfile context, the issue number and the README row. - No cookie literal remains in any shipped file. Only `-setcookie ${MCL_COOKIE}` (vm.args.src:10) and the compose pass-through are left. - The bind holds on both halves, measured on an OTP 28.5 scratch node with the same settings: beam.smp listens on 127.0.0.1 only, epmd on 127.0.0.1 and ::1 only. The dist bind sits in vm.args.src, so it holds even if start.sh is bypassed; a bypass then gets a random ~/.erlang.cookie, never a published one. - start.sh draws from /dev/urandom, writes under umask 077 (0600 from the first byte), treats an empty MCL_COOKIE as unset, never echoes the cookie, and exits rc=1 on an unwritable secrets dir. - No breakage: no net_kernel/rpc use, and fleet compose already supplies MCL_COOKIE. Notes (not required): - (a) The cookie is visible in `ps` argv, as it was before this PR. - (b) On beam02, ERL_EPMD_ADDRESS only takes effect in the process that starts epmd, so the shared 4369 is loopback only once every host-networked node carries it and epmd restarts. - (c) start.sh:15-16: a pre-existing EMPTY cookie file keeps its old mode, the write is not atomic, and if `od` fails the cookie comes out empty. Worth folding into the template before the 21-repo batch: chmod 600, refuse an empty result, and write via a temp file plus mv.
The same fold as mcl-mail PR 18: temp file, chmod 600, mv; an empty
result stops the start. The service test covers both cases.
Member

Landed --no-ff at 1b3c77eb by Terra. --range private gate: no new private data (the new hits are only shorthand issue refs). Main already carries 46 tree hits of its own, worth a look before this repo goes public.

Landed --no-ff at 1b3c77eb by Terra. --range private gate: no new private data (the new hits are only shorthand issue refs). Main already carries 46 tree hits of its own, worth a look before this repo goes public.
terra closed this pull request 2026-11-23 15:18:35 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 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-tube!2
No description provided.