No Host check: a DNS-rebinding page can read the crew board from GET / (the socket is guarded, the static render is not) #7
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 checksHost, andLadderLive.handle_params/3runsload/1on 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:4010rebinds the name to 127.0.0.1, thenfetch('/')is same-origin and the page reads the full board render. Read only: writes stay refused bycheck_origin.Fix shape (small). Port mcl-whiteboard's
MclWhiteboardWeb.AllowedHosts(@before_compileon the endpoint, so socket dispatch is wrapped too): allow onlylocalhost/127.0.0.1/::1plus the hosts ofMCL_HTTP_ORIGINS, and refuse every otherHostbefore the router.Done when:
GET /withHost: evil.example:4010is refused, and the board does not appear in the body. Red first.Host: 127.0.0.1:4010and the tunnel'slocalhost:4010still render. The existing suites pass.Refs macula-services/mcl-bookclub#12
Landed on main at
15b4c5e, through PR 8. Jupiter's Fable review passed it in r1.Done when:
GET /withHost: evil.example:4010gets 400, and so does/?card=x. The ladder is not in the body. This isallowed_hosts_test.exs, "the ladder asked for under a rebound host is refused…". It failed red first on084b098.127.0.0.1,localhostand[::1]still render the ladder, which covers the tunnel'slocalhost:4010. The owner-ladder LiveView tests now ask underlocalhost. Locallymix testpassed all 133 tests. On the forge, run 6316's "elixir in . (container)" job is green. Itsgatesjob is red because of #4, which was already red on main and is named in the land comment.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.