Skip to content

Serve haptics over plain HTTP on loopback, deprecate HTTPS - #6

Draft
Fallstop wants to merge 7 commits into
mainfrom
jmw/http-loopback-server
Draft

Fallstop wants to merge 7 commits into
mainfrom
jmw/http-loopback-server

Conversation

@Fallstop

Copy link
Copy Markdown
Owner

Response to the Logitech Marketplace security review (F1 and F2).

Why: Browsers now treat 127.0.0.1 as a secure context, so the shared local.jmw.nz certificate is only still needed for Safari. The plugin now serves on http://127.0.0.1:41080 and keeps https://local.jmw.nz:41443 as a deprecated Safari fallback, to be removed once Safari allows loopback requests or by November 2027. The web client tries HTTP first, and the docs and listing now say that any site can trigger haptics (Chrome prompts first).

Hardening: Oversized HTTP requests and WebSocket frames or messages now drop the connection before NetCoreServer buffers them. Previously one 200 MB frame grew Logi Plugin Service by about 790 MB. Upgrades are limited to /ws, GET / no longer reports version or endpoints, and 500s no longer echo exception text. Version bumped to 1.3.

Risk: The HTTP listener starts before the certificate download, so a certificate failure is now a warning rather than an error. Existing HTTPS integrations keep working unchanged.

Testing: Ran the new server code in a harness on spare ports against both listeners. Health checks, POST haptics and WebSocket haptics work, including a frame split into single bytes. Oversized frames, a 2 KB fragmented message and a 20 KB request each drop the connection, and memory stays flat (58 MB before and after). svelte-check and the web build pass. Not yet tested inside Logi Plugin Service or in Safari.

Browsers now treat 127.0.0.1 as a secure context, so the shared local.jmw.nz
certificate is no longer needed outside Safari. The plugin now serves the API on
http://127.0.0.1:41080 (started before the certificate download) and keeps
https://local.jmw.nz:41443 as a deprecated Safari fallback until Safari allows
loopback requests, or November 2027 at the latest. The web client tries HTTP
first and falls back to HTTPS, and the docs lead with HTTP.

Also from the Marketplace security review: oversized HTTP requests and
WebSocket frames or messages now drop the connection before NetCoreServer
buffers them (one 200 MB frame previously grew Logi Plugin Service by ~790 MB),
upgrades are limited to /ws, GET / no longer reports version or endpoint
details, 500s no longer echo exception text, and the listing discloses that
any website can trigger haptics. Version bumped to 1.3.
The site now presents plain HTTP on 127.0.0.1 as the only endpoint. The Safari HTTPS fallback is documented once, in a deprecated section at the end of the API page.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Deploying hapticwebplugin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2974e34
Status: ✅  Deploy successful!
Preview URL: https://4c08c836.hapticwebplugin.pages.dev
Branch Preview URL: https://jmw-http-loopback-server.hapticwebplugin.pages.dev

View logs

Sol review round 1. The guard now holds back frame headers split across reads (NetCoreServer restarts its header loops on a split and would misparse), counts control frames toward the message cap since NetCoreServer buffers them until FIN, and upgrade request bodies are no longer fed to the frame parser. The WebSocket client now falls back to the next endpoint when the socket itself fails, not only the health check, and ignores attempts superseded by disconnect(). The REST health probe times out after 3s, and the README port tip names the right port.
Sol review round 2. LocalServer refuses to start a listener once disposed, so a certificate download that finishes after unload no longer leaves port 41443 bound. The REST client re-probes after a non-OK response, a replaced WebSocket is closed and can no longer clear its successor, and the docs say Chrome and Firefox (not all browsers) allow HTTPS pages to call loopback directly.
Sol review round 3. A valid certificate in its 14-day renewal window now shows its own expiry warning, as before this branch, instead of 'HTTPS fallback is unavailable'.
Sol review round 4. Adopting a socket clears any retry scheduled meanwhile, and the README names the HTTPS fallback URL explicitly.
Sol review round 5. The REST probe uses AbortController instead of AbortSignal.timeout(), which Safari only has from 16, and the README's Safari troubleshooting step checks the HTTPS listener directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant