No Host check: a DNS-rebinding page can read the crew board from GET / (the socket is guarded, the static render is not) #7

Closed
opened 2026-12-01 12:07:55 +00:00 by jupiter · 1 comment
Member

Purpose (security): a web page the owner opens cannot read the crew board by rebinding its name to 127.0.0.1.

Same class as macula-services/mcl-bookclub#12. Read from main d0c531c.

What is there. The endpoint binds 127.0.0.1:4010. The LiveView socket is guarded by check_origin (config/runtime.exs:138), so a rebound page cannot act. But no plug checks Host, and LadderLive.handle_params/3 runs load/1 on the disconnected (static) render: GET / returns the whole ladder (packages, cards, crew, goal, boards) as HTML.

Route. GET / (and /?card=<id>, which opens a card).

Attacker. An outside page in the owner's browser at evil.example:4010 rebinds the name to 127.0.0.1, then fetch('/') is same-origin and the page reads the full board render. Read only: writes stay refused by check_origin.

Fix shape (small). Port mcl-whiteboard's MclWhiteboardWeb.AllowedHosts (@before_compile on the endpoint, so socket dispatch is wrapped too): allow only localhost/127.0.0.1/::1 plus the hosts of MCL_HTTP_ORIGINS, and refuse every other Host before the router.

Done when:

  1. GET / with Host: evil.example:4010 is refused, and the board does not appear in the body. Red first.
  2. Host: 127.0.0.1:4010 and the tunnel's localhost:4010 still render. The existing suites pass.
  3. No new check or job.

Refs macula-services/mcl-bookclub#12

Purpose (security): a web page the owner opens cannot read the crew board by rebinding its name to 127.0.0.1. Same class as macula-services/mcl-bookclub#12. Read from main d0c531c. **What is there.** The endpoint binds 127.0.0.1:4010. The LiveView socket is guarded by `check_origin` (config/runtime.exs:138), so a rebound page cannot *act*. But no plug checks `Host`, and `LadderLive.handle_params/3` runs `load/1` on the disconnected (static) render: `GET /` returns the whole ladder (packages, cards, crew, goal, boards) as HTML. **Route.** `GET /` (and `/?card=<id>`, which opens a card). **Attacker.** An outside page in the owner's browser at `evil.example:4010` rebinds the name to 127.0.0.1, then `fetch('/')` is same-origin and the page reads the full board render. Read only: writes stay refused by `check_origin`. **Fix shape (small).** Port mcl-whiteboard's `MclWhiteboardWeb.AllowedHosts` (`@before_compile` on the endpoint, so socket dispatch is wrapped too): allow only `localhost`/`127.0.0.1`/`::1` plus the hosts of `MCL_HTTP_ORIGINS`, and refuse every other `Host` before the router. Done when: 1. `GET /` with `Host: evil.example:4010` is refused, and the board does not appear in the body. Red first. 2. `Host: 127.0.0.1:4010` and the tunnel's `localhost:4010` still render. The existing suites pass. 3. No new check or job. Refs macula-services/mcl-bookclub#12
Member

Landed on main at 15b4c5e, through PR 8. Jupiter's Fable review passed it in r1.

Done when:

  1. Met. GET / with Host: evil.example:4010 gets 400, and so does /?card=x. The ladder is not in the body. This is allowed_hosts_test.exs, "the ladder asked for under a rebound host is refused…". It failed red first on 084b098.
  2. Met. 127.0.0.1, localhost and [::1] still render the ladder, which covers the tunnel's localhost:4010. The owner-ladder LiveView tests now ask under localhost. Locally mix test passed all 133 tests. On the forge, run 6316's "elixir in . (container)" job is green. Its gates job is red because of #4, which was already red on main and is named in the land comment.
  3. Met. No new check or job.

Purpose met: a page that rebinds its own name to 127.0.0.1 can no longer read the board. Jupiter's four review notes are filed as #9.

Landed on main at 15b4c5e, through PR 8. Jupiter's Fable review passed it in r1. Done when: 1. **Met.** `GET /` with `Host: evil.example:4010` gets 400, and so does `/?card=x`. The ladder is not in the body. This is `allowed_hosts_test.exs`, "the ladder asked for under a rebound host is refused…". It failed red first on 084b098. 2. **Met.** `127.0.0.1`, `localhost` and `[::1]` still render the ladder, which covers the tunnel's `localhost:4010`. The owner-ladder LiveView tests now ask under `localhost`. Locally `mix test` passed all 133 tests. On the forge, run 6316's "elixir in . (container)" job is green. Its `gates` job is red because of #4, which was already red on main and is named in the land comment. 3. **Met.** No new check or job. Purpose met: a page that rebinds its own name to 127.0.0.1 can no longer read the board. Jupiter's four review notes are filed as #9.
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-kanban#7
No description provided.