the server binds every interface, has no auth, and its WebSocket answers any Origin #1527
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge#1527
Loading…
Add table
Add a link
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?
Verified today, and recorded as a precondition rather than a surprise:
server/index.js:765callsserver.listen(PORT)with no host, so Node binds all interfaces.authoriz|authenticat|api_key|passw|secret|tokenacrossserver/andengine/returns no security-related hits.server.on('upgrade')atserver/index.js:715, callswss.handleUpgrade, and immediately pushes full topology state - with no Origin check, no Host check and no token. So any LAN host, and any web page Jay visits, can open it and read the whole object graph.This is a deliberate, documented posture for a simulator of fictional devices, and
README.md/ARCHITECTURE.md/PUBLIC-ACCESS.mdsay so. It stops being acceptable the moment the process holds real device credentials, which is next.Requested: before any credential is stored, (1) default the bind to loopback with an explicit
--hostopt-out, (2) validateOriginon the WebSocket upgrade, and (3) put the credential-handling surface behind a bearer token. The public demo can keep its own posture via configuration.Filed because the credential store design (w9) names this as its precondition, not because the current behaviour was unintended.
jaylouisw referenced this issue2026-11-16 07:56:06 +00:00
jaylouisw referenced this issue2026-11-16 07:56:07 +00:00
jaylouisw referenced this issue2026-11-16 08:57:51 +00:00
Item 1 of this issue - the bind - is up as PR #1639, branch
fix/1116-0835@64e2fa86.What landed:
PF_HOST, default127.0.0.1; the banner prints whatserver.address()reports and whether the socket is on this machine only or reachable from other hosts (it used to printlocalhostwhatever had been bound);DockerfilesetsPF_HOST=0.0.0.0sodocker run -p 8000:8000keeps working. APF_HOSTthis machine does not own now exits 1 naming that value and the variable - the oldEADDRNOTAVAILtext blamedPORTand advised leaving it "unset to listen on all interfaces", which was false on both counts.Evidence:
test/server-bind.test.js(23 assertions) spawns the real server four ways - default answers on 127.0.0.1 and nothing accepts on the machine's first non-loopback IPv4;0.0.0.0does accept there;192.0.2.123(TEST-NET-1) exits 1 with a message naming it and no stack trace;127.0.0.1:<port>is named as the copied-from-a-URL mistake.npm testat the committed tree: 276 suites, 9873 assertions, 0 failed. Syntax check 346 files.Still open, deliberately: item 2 (WebSocket
Origin) landed in #1629. Item 3 - the bearer token - is not in this PR and not in the plan: there is no credential store to guard yet (grep -ri credential engine/ server/finds nothing), so a token today would protect nothing and would have to be redone once the store exists. It needs its own plan and a decision from Jay on how the UI authenticates. Steps 3-5 ofdocs/plans/server-exposure.md(narrow CORS, drop the unsolicited board push, docs) are also still a plan.Item 2 of this issue is up as PR #1644, branch
fix/1116-0905@12f25252- and it closes the door item 2 alone did not.What was still open. The upgrade check landed and every JSON answer still carried
Access-Control-Allow-Origin: *. So a page the socket had just refused could calland read every device, cable and CLI transcript over HTTP. The Origin check was true of the socket and false of the server.
SECURITY.mdsaid so in a sentence, which is the right thing to say and the wrong thing to leave standing - this run reproduced it as 13 failing assertions before touching the code.What landed.
allowedOriginHeader()asks the sameallowOrigin()the upgrade uses;sendJSONechoes the caller's ownOriginonly when that check accepts it and sends noAccess-Control-Allow-Originat all otherwise, so the browser withholds the body; both answer paths now sayVary: Origin, Accept-Encoding; theOPTIONSpreflight follows the same rule./api/catalogand/api/mediakeep the wildcard -sendImmutableJSON, fixed catalogues, no board, read from other origins on purpose.test/server-cors.test.js(23 assertions, real server): 10 passed / 13 failed before, 23 / 0 after. Fullnpm test: 277 suites, 9902 assertions, 0 failed.syntax-check347 files OK, control bytes clean, doc citations unchanged.The token item stays open exactly as planned:
grep -ri credential engine/ server/still finds nothing to guard, so a bearer token today would protect an empty set. That waits for the credential store (w9) and Jay's approval, perdocs/plans/server-exposure.md.