mcl-bookclub#12: Host allow-list and Origin on POST for the admin listener (DNS rebinding) #13

Manually merged
terra merged 4 commits from mercurius/12-host-allow-list into main 2026-12-01 14:36:16 +00:00
Member

Purpose (fix): a web page outside the LAN cannot send a command to the admin API, or read from it, by rebinding its own name to the box's LAN address. Erlang half; the Phoenix twin follows.

Threat model and Done-when: #12 (comment)

  • a991717 red first: a rebound Host (POST, GET read, static UI) and a foreign Origin are served on main (4 failing, the IP/localhost/own-Origin cases passing).
  • 6e85920 a cowboy middleware (mcl_bookclub_admin:execute/2, before the router) refuses with 403 host_not_allowed any Host that is not an IP literal (v4/v6), localhost, or a name in the one new setting MCL_ADMIN_HOSTS (comma-separated, empty by default). A POST whose Origin is not http://<its Host>:<port> (or is null) gets 403 origin_not_allowed. Docs: the module comment, guides/admin_ui.md (the overclaim is gone), architecture table, sys.config.src, Containerfile, compose, CHANGELOG.

Behaviour change for the operator: reaching the UI by a DNS name now needs that name in MCL_ADMIN_HOSTS. An IP or localhost needs nothing.

Local (OTP 28.4.3): rebar3 lint, eunit 136/136, dialyzer clean. Mutant: with the Origin port compare dropped, the foreign-Origin test fails (1 of 17).

Refs #12

Purpose (fix): a web page outside the LAN cannot send a command to the admin API, or read from it, by rebinding its own name to the box's LAN address. Erlang half; the Phoenix twin follows. Threat model and Done-when: https://git.macula.io/macula-services/mcl-bookclub/issues/12#issuecomment-7400 - a991717 red first: a rebound Host (POST, GET read, static UI) and a foreign Origin are served on main (4 failing, the IP/localhost/own-Origin cases passing). - 6e85920 a cowboy middleware (`mcl_bookclub_admin:execute/2`, before the router) refuses with 403 `host_not_allowed` any Host that is not an IP literal (v4/v6), `localhost`, or a name in the one new setting `MCL_ADMIN_HOSTS` (comma-separated, empty by default). A POST whose `Origin` is not `http://<its Host>:<port>` (or is `null`) gets 403 `origin_not_allowed`. Docs: the module comment, guides/admin_ui.md (the overclaim is gone), architecture table, sys.config.src, Containerfile, compose, CHANGELOG. Behaviour change for the operator: reaching the UI by a DNS name now needs that name in `MCL_ADMIN_HOSTS`. An IP or localhost needs nothing. Local (OTP 28.4.3): rebar3 lint, eunit 136/136, dialyzer clean. Mutant: with the Origin port compare dropped, the foreign-Origin test fails (1 of 17). Refs #12
mcl-bookclub#12: the admin listener serves only an IP, localhost or a listed MCL_ADMIN_HOSTS name, and a POST only from its own Origin
Some checks failed
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
lint-and-test / check (pull_request) Has been cancelled
wall tree / wall-tree (pull_request) Has been cancelled
wall tree / wall-tree-1 (pull_request) Has been cancelled
6e85920c33
mcl-bookclub#12 review: a listed admin host opens no other name
Some checks failed
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
lint-and-test / check (pull_request) Has been cancelled
wall tree / wall-tree (pull_request) Has been cancelled
wall tree / wall-tree-1 (pull_request) Has been cancelled
a9c547da57
Two guard mutants survived the suite: serving any Host once admin_hosts is
set, and a substring match instead of lists:member. With the list set, an
unlisted name and a name containing a listed one must still get 403. Both
mutants now fail a_listed_admin_host_is_served; the tip passes 17/17.
mcl-bookclub#12 review fold: Host 127.1 is refused (only a strict IP literal skips the list); MCL_ADMIN_HOSTS takes bare names
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 5s
c4 model / c4-model (pull_request) Successful in 0s
wall tree / wall-tree-1 (pull_request) Successful in 5s
wall tree / wall-tree (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 4m4s
c4 model / c4-model-1 (push) Successful in 3s
c4 model / c4-model (push) Successful in 0s
wall tree / wall-tree-1 (push) Successful in 6s
wall tree / wall-tree (push) Successful in 0s
lint-and-test / check (push) Successful in 4m45s
df643d8bba
terra manually merged commit df643d8bba into main 2026-12-01 14:36:16 +00:00
Sign in to join this conversation.
No reviewers
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-bookclub!13
No description provided.