mcl-kanban#7: a request under a rebound Host gets 400 (whiteboard AllowedHosts port) #8
Loading…
Reference in a new issue
No description provided.
Delete branch "uranus/7-allowed-hosts"
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?
Refs #7. Purpose (security): a web page the owner opens cannot read the crew board by rebinding its own name to 127.0.0.1.
Threat model: an outside page in the owner's browser at
evil.example:4010rebinds that name to 127.0.0.1. Itsfetch('/')is then same-origin, and the static render of/is the whole ladder. Writes were already refused bycheck_originon the socket. A local process is out of scope.Fix:
MclKanbanWeb.AllowedHostsis mcl-whiteboard's module ported, with the names changed and the moduledoc adjusted.@before_compileafteruse Phoenix.Endpoint, so it wraps the wholecall/2, socket dispatch included.Hostother thanlocalhost,127.0.0.1,::1and the hosts ofMCL_HTTP_ORIGINSgets 400.config/runtime.exsbuildsallowed_hostsfrom the same origin list ascheck_origin.MCL_HTTP_ORIGINSentry with no host now refuses the boot, naming the entry.Tests:
allowed_hosts_test.exshas 5 cases.GET /and/?card=xunderevil.exampleget 400, and the ladder is not in the body.[::1]still render the ladder.MCL_HTTP_ORIGINSset, yields the expected list.084b098alone fails 4 of the 5.owner_ladder_live_test.exsnow builds its conn with the hostlocalhost, as the tunnel sends. Without that,build_conn'swww.example.comwould be refused.Local run on
15b4c5e: format, compile with warnings as errors, credo,mix test(133, 0 failures) and dialyzer are all green. Done-when 3 holds: no new check or job.Landed by fast-forward: main is
15b4c5e848(fromd0c531cf), PASS r=1 Jupiter. Accepted reds (pre-existing, tracked in #4):gates (OTP 28.4.3 / Elixir 1.18.4)andci.yml(run 6316): the checkout step has no node in the image, as on main run 3205. mix test never ran in CI; Jupiter ran the full suite offline on15b4c5e8: 0 failures. Run 6315 c4-model green.