The service on 127.0.0.1:3477 answered Origin: null (any site's sandboxed
iframe or a data: page) with ACAO null, and had no Host check, so a
hostile page could POST /api/chat on the user's magpie gateway key, read
and rewrite conversations and settings, and drive MCP tools; a DNS-rebound
page could read conversations with a plain GET.
- Every /api/ route except ping, fonts.css and icon/* now needs a
per-process token (x-magpie-chat-token, timing-safe compare). The token
is put in index.html as a meta tag, and index.html goes out without
CORS, so only a page that navigated to the service can read it. app.js
sends it on every call and reloads once when the service restarted.
- The Host must be 127.0.0.1:<port> or localhost:<port>, checked first.
- index.mjs starts the service when the host calls server(), not on
import, and passes the plugin option's port, which page/boot.js already
read; before, a port set in the options moved the page and not the
service.
- Port 0 binds a free port (tests); the actual port is used for the Host
and Origin lists.
- /api/icon's remote icon answered 302 without a Location; it has one.
- /api/bootstrap reports the package version instead of "0.1.0".
- package.json: 0.1.0 in magpie-community/plugins, author credit, start
runs serve.mjs.
Co-authored-by: Magiczerowxy <magiczerowxy@users.noreply.github.com>