fix: harden WebRTC transfers for v0.0.1
Require mutual fingerprint confirmation before sharing metadata or files. Validate incoming messages, bound buffering, and confirm receipt before reporting success. Add direct-to-disk saving and explicit TURN opt-in. Fix reset and retry handling, clean up cancelled connections, and preserve completed Firefox downloads when the sender disconnects. Update dependencies, clarify security assumptions, and add protocol and cross-browser regression tests. Set version 0.0.1 and document the release in CHANGELOG.md, linked from the README. BREAKING CHANGE: both peers must use signaling and transfer protocol v2; older connection codes are no longer accepted.
This commit is contained in:
1 parent
d198332c92
commit
752d0cf3af
16 files changed
+1352
-603
No files matched your search
@@ -1,57 +1,148 @@
|
||||
# HellCon
|
||||
|
||||
Peer-to-peer file sharing between two browsers. No server, no account, no
|
||||
upload. The page you host is only a delivery mechanism for the JavaScript —
|
||||
the files themselves travel directly from one browser to the other over
|
||||
WebRTC, end-to-end encrypted (DTLS-SRTP) by the browsers themselves.
|
||||
Current version: **0.0.1**. See the [changelog](CHANGELOG.md) for release notes
|
||||
and compatibility changes.
|
||||
|
||||
Built with Vite + Vue 3, toolchain is `bun`.
|
||||
Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling
|
||||
backend, or server-side file storage. You exchange connection codes manually.
|
||||
Direct connections are the default. TURN relaying is optional and requires
|
||||
explicit opt-in by both people; no relay is configured automatically.
|
||||
|
||||
## How it works
|
||||
|
||||
1. **Sender** picks a file, chooses a STUN provider, and clicks
|
||||
*Create code*. Their browser generates a WebRTC offer and the app presents
|
||||
it as one copyable string.
|
||||
2. The sender pastes that code to the receiver through **any channel they
|
||||
already trust** — a chat app, email, a piece of paper read over the phone.
|
||||
3. **Receiver** pastes the code; their browser answers and the app shows the
|
||||
answer string. They send it back the same way.
|
||||
4. The sender pastes the answer. Both browsers exchange the SDP fingerprints
|
||||
as a two-line security check — if both sides see the same codes, no one
|
||||
can have interposed on the exchange.
|
||||
5. The connection opens and the file is transferred in chunks with
|
||||
backpressure, reassembled on the receiver side and handed to the user as
|
||||
a download.
|
||||
1. The sender picks one file and configures STUN (Google by default, Cloudflare,
|
||||
a custom provider, or None). They create a code and send it privately to the
|
||||
intended receiver through an authenticated channel.
|
||||
2. The receiver pastes the code, creates an answer, and sends it back. The sender
|
||||
pastes the answer. Gathering waits for completion, up to 30 seconds; a timeout
|
||||
fails rather than quietly exporting incomplete connection information.
|
||||
3. **Both people compare both full SHA-256 certificate fingerprints** over a
|
||||
channel whose authenticity and integrity they trust, such as in person.
|
||||
Your fingerprint must equal their “Their fingerprint”, and vice versa.
|
||||
Compare every byte. Cancel on any mismatch. Both people must explicitly
|
||||
confirm before the app sends the filename, size, MIME metadata, or contents.
|
||||
4. The receiver sees the filename and size and explicitly accepts the file.
|
||||
Supported browsers can stream directly to a chosen disk destination, up to
|
||||
64 GiB. Other browsers can receive files up to 64 MiB in memory and then offer
|
||||
a download. Larger files require direct-to-disk support. Even capped memory
|
||||
downloads may be too large on a memory-constrained device.
|
||||
5. The sender waits for a receipt acknowledgment. For disk transfers, the receiver
|
||||
sends this only after its writable stream closes successfully; for memory
|
||||
transfers, after constructing the complete download. This does not prove a
|
||||
human saved the memory download, nor that a malicious receiver told the truth.
|
||||
|
||||
**STUN**: if both peers are on the same network nothing external is needed
|
||||
(pick "None"). For peers on different networks the browsers need one
|
||||
stateless UDP lookup against a public STUN server (Google or Cloudflare, or
|
||||
your own) to discover their public IP. That's the only third-party contact,
|
||||
and it never sees connection or file data. Remove the `iceServers` entry in
|
||||
`src/lib/webrtc.js` if you want to talk to nobody but your peers.
|
||||
Cancel, reset, changing the selected file, or switching Send/Receive closes the
|
||||
connection and aborts unfinished disk writes. Keep the tab open until receipt is
|
||||
confirmed. A completed memory download is discarded when you reset or switch.
|
||||
Pending verification/acceptance expires after five minutes; stalled transfers
|
||||
expire after one minute. The two peers must use this protocol version (v2);
|
||||
legacy connection codes are rejected.
|
||||
|
||||
**MITM model**: the file data is end-to-end encrypted by the browsers and
|
||||
cannot be MITM'd by a passive attacker. The only theoretical attack is
|
||||
interposing on the *code exchange* itself; the built-in fingerprint
|
||||
comparison ("Security check" after signaling) closes it — compare the codes
|
||||
over a channel you trust.
|
||||
If an answer is rejected as invalid, correct the pasted answer and click Connect
|
||||
again; the sender keeps its existing offer while it is still awaiting an answer.
|
||||
After a connection actually closes or fails, use Reset and exchange a **new offer
|
||||
and new answer**. Old codes refer to the closed connection and cannot reopen it.
|
||||
Reset returns the page to its initial ready state. For a local test, open two
|
||||
separate browser tabs or windows; switching Send/Receive inside one page cancels
|
||||
that page's previous connection. Use the specific error shown in red to diagnose
|
||||
failures; if a configured STUN server is unreachable, try None for a local test.
|
||||
|
||||
## Commands
|
||||
## Network privacy and optional TURN
|
||||
|
||||
STUN discovers externally reachable addresses. Its operator can see your public
|
||||
IP address and request metadata, but STUN does not relay file contents. Lookups,
|
||||
retries and connectivity checks may involve multiple packets. Choosing None
|
||||
avoids contacting a configured STUN provider; direct connectivity depends on
|
||||
addresses, routing, browser policy and firewalls, not simply whether peers share
|
||||
one network. A VPN is not automatically a guarantee against address disclosure.
|
||||
|
||||
Connection codes are **Base64-encoded, not encrypted**. They contain SDP,
|
||||
including candidate addresses, temporary ICE credentials and certificate
|
||||
fingerprints. Peers and anyone who sees these codes (including the messaging
|
||||
service used to exchange them) may learn connection details. Local addresses may
|
||||
be obscured by the browser, but this app does not provide anonymity. Treat codes
|
||||
as private session information; do not publish them.
|
||||
|
||||
Restrictive NATs or firewalls can prevent direct connections. There is no silent
|
||||
TURN retry. To permit a relay, both people must explicitly check **Allow a TURN
|
||||
relay**, supply their authorized TURN URL, username and password, and generate
|
||||
new codes. Otherwise TURN URLs are rejected in the STUN field and codes with
|
||||
relay candidates are rejected. Enabling TURN allows the browser to contact that
|
||||
relay during gathering and select a relay route when needed. This does not force
|
||||
relay-only routing or hide your IP from the peer. A remote peer can independently
|
||||
proxy their own traffic; the opt-in controls this app's configuration and the
|
||||
relay candidates it accepts, not arbitrary software run by the other person.
|
||||
|
||||
TURN credentials stay in the current component's memory; the app does not persist
|
||||
them or include them in codes. The relay receives its authentication exchange and
|
||||
can observe addresses, timing and traffic volume, and may charge for bandwidth.
|
||||
Resetting, cancelling, completing or failing a connection clears TURN consent;
|
||||
check the option again before creating another relayed connection.
|
||||
File traffic remains DTLS encrypted through the relay. The web host, DNS resolver,
|
||||
and code-exchange service are also relevant third parties.
|
||||
|
||||
## Security model and limits
|
||||
|
||||
Data channels use **SCTP over DTLS**, which provides transport confidentiality and
|
||||
integrity. This is not DTLS-SRTP (the media transport). DTLS authenticates the
|
||||
certificate in the connection description; an independently authenticated full
|
||||
fingerprint comparison binds that certificate to the intended peer. Comparing
|
||||
fingerprints through a channel an attacker can rewrite provides no such assurance.
|
||||
|
||||
You must trust your browser, device, and **the JavaScript you load**. A compromised
|
||||
host or build can steal plaintext or falsify the verification display. Serve the
|
||||
production build over HTTPS, or run a verified build you control on localhost.
|
||||
HTTPS protects delivery against network tampering, not against a malicious host.
|
||||
The app does not upload files to its web host in this implementation; that is a
|
||||
property of this code, not a guarantee against a host serving different code.
|
||||
|
||||
The protocol accepts one ordered, reliable data channel, bounded metadata and
|
||||
messages, an exact declared byte count, and a single file. It rejects unexpected
|
||||
states, excess data and duplicate metadata. An acknowledged 1 MiB send window
|
||||
and a bounded receive queue limit buffering during disk writes. Files are treated
|
||||
as opaque downloads; metadata is not rendered as HTML. Encryption does not make
|
||||
a file safe to open. These limits reduce denial-of-service exposure but do not
|
||||
eliminate browser, device, network, or malicious-peer risks.
|
||||
|
||||
For deployment, serve `dist/` as static files over HTTPS. Do not expose the Vite
|
||||
dev or preview server as the production service. Configure hosting headers such
|
||||
as `Content-Security-Policy` (including `frame-ancestors 'none'`),
|
||||
`X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`. A baseline
|
||||
CSP for this build is `default-src 'self'; script-src 'self'; style-src 'self'
|
||||
'unsafe-inline'; img-src 'self'; connect-src 'self'; object-src 'none'; base-uri
|
||||
'none'; frame-ancestors 'none'`. Inline styles are currently used for progress and
|
||||
Vue visibility. Test headers on the actual host; CSP is defense in depth and is
|
||||
not a substitute for trusting the host or a portable WebRTC egress filter.
|
||||
`robots.txt` and indexing metadata are crawler requests, not access control.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
bun install
|
||||
bun run dev # dev server
|
||||
bun run build # static build -> dist/ (3 static files + favicon + robots.txt)
|
||||
bun run preview # serve the production build
|
||||
bun install --frozen-lockfile
|
||||
bun run dev
|
||||
bun run test
|
||||
bun run build
|
||||
bun run test:browser # local Chromium integration checks against dist/
|
||||
bun run test:cross-browser # Brave sender → Firefox receiver
|
||||
bun run preview # local build inspection only
|
||||
bun audit
|
||||
```
|
||||
|
||||
## Honest disclaimer
|
||||
The lockfile pins dependencies. Review dependency updates and advisories before
|
||||
publishing a build. Protocol regression tests cover verification gating, malformed
|
||||
messages, size limits, cancellation, receipt acknowledgment, and relay opt-in.
|
||||
The browser check requires Chromium at `/usr/bin/chromium` (override with
|
||||
`CHROMIUM_PATH`); it uses an isolated temporary profile and a loopback server.
|
||||
The cross-browser check uses Brave and Firefox at `/usr/bin/brave` and
|
||||
`/usr/bin/firefox` (override with `BRAVE_PATH` and `FIREFOX_PATH`). It checks
|
||||
that the received file remains downloadable after the sender disconnects.
|
||||
Pass `--reverse` to test Firefox → Brave, or `--default-network` to use Google
|
||||
STUN instead of the local test's default None. These checks use temporary
|
||||
browser profiles and do not modify your normal browser settings.
|
||||
|
||||
This is **vibe-coded throw-away software**. It was generated for fun, it
|
||||
worked on the machines it was tried on, and it is roughly audited rather
|
||||
than battle-tested. It may break on your browser, your NAT, or your use
|
||||
case. If it works for you, great. If not, fixing it is now your hobby.
|
||||
This is experimental software, not independently audited or battle-tested.
|
||||
Browser compatibility, network connectivity and storage availability vary.
|
||||
|
||||
## License
|
||||
|
||||
MIT — do whatever you want with this. No warranty, see `LICENSE`.
|
||||
MIT — see `LICENSE`.
|
||||
Reference in new issue
Block a user