# TODO ## Hardening From a security review, none of them urgent. - Sanitize file names for display: `MAX_NAME` only limits the length. Control and bidi characters (e.g. U+202E) can fake log lines or disguise an extension, `invoice‮fdp.exe` shows as `invoiceexe.pdf`. Strip C0/C1 and bidi controls where the name is shown and logged, maybe for `Content-Disposition` in `sw.js` too, though browsers sanitize download names themselves. - Limit what a tracker can make the page do: no size or rate limit on its messages, `parse` and `unseal` take whatever arrives, failure reasons after acceptance are logged, and the log in `App.vue` grows without bound. A malicious tracker can freeze the tab. Only availability, and only of a tracker the user chose, but cheap: cap `event.data.length` before parsing, cap the log, drop failure reasons after acceptance or log one. - The tracker relays anything: `isSdp` only checks for a string, so it passes any payload up to `MAX_FORWARDED` between two peers of a swarm, usable as a small message relay. The SDP is sealed, the tracker can't check it's SDP. Checking for base64 of a plausible length only shapes what it relays, any data can be base64. What limits the relay is a quota: bytes forwarded per IP over time, and a per-IP connection rate, not only `MAX_PER_IP` concurrent ones, so reconnecting doesn't reset it. Or decide this is accepted and say so in `tracker.mjs`. - The tracker's plain HTTP path isn't counted: `MAX_CONNECTIONS` and `MAX_PER_IP` only apply to upgrades, a non-upgrade request gets a 404 with Node's default timeouts. Don't count on Caddy for it, its defaults may not cut slow clients short either. Setting `headersTimeout`, `requestTimeout`, `keepAliveTimeout` and `maxHeadersCount`, and closing the socket after the 404, costs little. Queues can reach `MAX_QUEUED` × `MAX_CONNECTIONS` = 32 MiB against `mem_limit: 96m`, maybe a global byte budget. - Framing: no `frame-ancestors`, so another page can frame HellCon and overlay the security check's buttons. Gains little: a framed HellCon starts empty like any other, nothing is kept, so it has no file or offer the user didn't pick or paste inside it, and the address bar shows the framing site. That site could as well serve a modified copy that fakes the codes. `frame-ancestors` and `X-Frame-Options` only work as headers, not in a ``. Recommend them, `X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer` in Host your own. ## Ideas - Resume interrupted transfers: the receiver already reports how much the download manager has read (`{ read }`), which is where a new connection could continue. The browser can't append to a finished or failed download though, so a resume would have to start a new one. - Keep user settings again: for now every reload starts from the defaults, the server lists and the own salt too. Open which ones to keep, and how a kept one that differs from the other side's would show, instead of silently breaking a share. - Version the protocol for 1.0: put a version into the key derivation, e.g. `hellcon/1 ` as the PBKDF2 salt in `secrets`. Until then any change to it silently breaks sharing between deployments on different versions, the receiver only sees "No sender with this code". Open how a mismatch would be reported, e.g. by trying the previous version's swarm too. ## Open observations - Firefox ignores an errored service worker response stream: when the sender vanishes, the receiver logs "download failed: connection lost", but the download stays "in progress" until the user cancels it. Closing the stream instead is worse, Firefox then reports the truncated file as complete despite `Content-Length`. Chromium fails the download, but only once the connection counts as failed (~16 s), because its data channel never fires `close` for a vanished peer. - Firefox also saves a truncated file as complete when it stops the service worker in the middle of a download (after 30 s without events). The receiver's pings (`KEEPALIVE`) prevent that, covered by `large: firefox survives a 40 s stall`. A browser that stops it anyway would still never show "download complete" or "delivered", only its download manager would be wrong. - `large: firefox sends 2.5 GiB` hit the 5 minute timeout once (first run after the normal suite), not reproduced in 3 runs since. The report was lost; the attached logs will show the cause if it happens again. - Small downloads (empty, one byte) were sometimes never saved, though the worker reported them finished and both sides logged success: the browser can read the whole response before it hands the navigation to its download manager, and removing the frame before that cancels it. Without a delay `boundary: … sends an empty file` failed 8 of 10 runs, the one byte file 4 of 10. The workaround `DOWNLOAD_GRACE` keeps the download's frame 1 s after finished. No event tells when the browser took the download, so the 1 s is empirical: `boundary: … keeps a finished download's frame for DOWNLOAD_GRACE` covers the retention, not the browser's timing. A small download that goes missing again means it's too short.