HTTP guard follow-ups from the #23 review: exact-match and method tests, malformed MCL_RAG_HTTP_HOSTS entries, cross-site GET search #26
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 (hardening): close the three gaps Jupiter's Fable review of #23 (PR 24, r1 PASS) left open in the HTTP API guard. None of them was required for that PASS.
Read from main
c191c6b,apps/mcl_rag/src/serve_http_api/mcl_rag_http_guard.erl.lists:member/2), but no case would fail if that became a suffix or prefix match. The missing cases areHost: 127.0.0.1.evil.exampleandOrigin: http://localhost.evil.example. Every write case also uses POST; none sends PUT, PATCH or DELETE, which the guard treats as writes too.MCL_RAG_HTTP_HOSTSentry with a port or scheme never matches. An entry such asrag.box:8451orhttp://rag.boxis compared against a bare host, so every request under that name gets a silent 400. A warning at startup that names the entry would make the mistake visible.GET /api/rag/chunks/searchstill runs a search. GET is not a write, so it passes the Content-Type and Origin checks. The reply is opaque to the page and nothing is written; the only cost is the work the search does.Done when:
MCL_RAG_HTTP_HOSTSentry is named in a log line at start. Whether it should refuse the boot is decided here.Refs #23
Threat model and plan (Saturnus, 2026-12-01), before any code. Branch from main
15752f4.Attacker. A web page the owner opens in a browser on the box. It is not on the box and holds no credentials. The API binds loopback and has no authentication.
Note 3, what a cross-site GET gets (probed on a CT listener with the real guard and handlers, browser-shaped headers).
GET /api/rag/chunks/searchcarries noAccess-Control-*header, and a preflight gets 415. The page only ever holds an opaque reply.callback=is ignored and the body is a JSON object, so nothing in it runs as a script.GET /api/rag/chunks/by-source?source_path=<guess>returns 5550 bytes when the guessed path exists and 12 when it does not. A page timing many opaque fetches can learn whether a path it guesses exists, never what the store holds. Each search also costs CPU.Plan.
Sec-Fetch-Siteiscross-siteis refused with 403, on every method. Every current browser sends that header on a no-cors fetch. curl, measure.py and the operator's own tools send none.same-origin,same-site(another page on localhost) andnone(a typed URL) pass.Host: 127.0.0.1.evil.exampleandOrigin: http://localhost.evil.exampleare refused, and PUT, PATCH and DELETE are writes. Each case is red on a guard mutated to match by suffix, or to treat only POST as a write.MCL_RAG_HTTP_HOSTSentry (one carrying a scheme, a port or a path) is named in a warning at start. It does not refuse the boot: the API still answers under localhost, and one typo should not stop the service. The entry still never matches, as now.Out of scope, filed as #27: most handlers return a bare
Reqfrominit/2.Done-when, checked (Saturnus, 2026-12-01). Landed on main
0397a80(PR 28; Jupiter r1 FAIL, small, fixed inline; r2 PASS).a_host_that_only_ends_like_a_local_one_is_refused,an_origin_that_only_starts_like_a_local_one_cannot_writeandevery_write_method_is_held_to_json_and_origin(PUT, PATCH, DELETE). Each is red on its mutant: host by prefix and by suffix, origin by prefix and by suffix, POST-only writes.MCL_RAG_HTTP_HOSTSentry is named in a log line at start: yes.warn_malformed_hosts/0runs at the listener's start, anda_malformed_configured_host_is_named_at_startchecks it. Decided: it warns and does not refuse the boot, since the API still answers under localhost.Sec-Fetch-Site: cross-siteis refused with 403 on every method, reads included (c7454 has the probe). The limits are in the CHANGELOG: the header is sent only to localhost, loopback or https.Follow-up: #27 (handlers return a bare
Req). It ships with this as 0.11.2.Closing.