WebRTC security for file transfer

How WebRTC secures data: DTLS encryption, certificate fingerprints, forward secrecy, TURN relays, IP exposure, and the man-in-the-middle risk at signaling.

WebRTC is secure by design: every connection is encrypted with DTLS using keys generated by the two browsers, and browsers refuse unencrypted connections. The part to think about is the signaling step, where a dishonest server could try to sit in the middle. Fingerprint verification solves that.

What WebRTC guarantees

  • Mandatory encryption. Data channels run over SCTP inside DTLS; audio and video use SRTP keyed from the same DTLS handshake. There is no unencrypted mode.
  • Fresh keys per connection. Browsers generate certificates per connection and use ephemeral (ECDHE) key exchange, giving forward secrecy: a later key leak doesn't expose past sessions.
  • Certificate pinning by fingerprint. Each side's certificate fingerprint is sent in the SDP during signaling, and the DTLS handshake fails if the certificate doesn't match.
  • Permission model. Websites can't open WebRTC data connections to arbitrary machines; both sides must run the page and complete the handshake.

The real weak point: signaling

The fingerprints travel through the signaling server. If that server were malicious, it could replace both fingerprints with its own and relay the traffic, decrypting it on the way. This is the classic man-in-the-middle problem, and it applies to any app where a server introduces strangers.

The fix is to compare fingerprints out of band. Relay turns both fingerprints into a short safety number shown on both screens. Matching numbers mean the DTLS connection really goes from your browser to theirs.

TURN relays don't break encryption

When devices can't connect directly, a TURN server forwards packets. It sees only DTLS-encrypted bytes and cannot decrypt them. See TURN vs STUN.

Privacy considerations

  • IP addresses: to connect directly, each device learns the other's IP address. Browsers hide local addresses behind random .local names until you connect, but the public address is visible to your peer.
  • Metadata: the signaling server knows which devices connected and when, but not what was sent.

How Relay adds to WebRTC's defaults

  • Safety number for out-of-band verification
  • Approval required for every device that joins
  • Accept or decline every file before any bytes arrive
  • Rate-limited, hard-to-guess room codes and optional passwords
  • Signaling that only works between devices in the same room
  • Short-lived TURN credentials and a strict Content-Security-Policy

Details in Relay's security model.

FAQ

Can WebRTC traffic be intercepted?

Packets can be captured, but they are DTLS-encrypted. Reading them would require a man-in-the-middle at signaling time, which a matching safety number rules out.

Does WebRTC leak my IP address?

Your peer sees your public IP address, which is needed for a direct connection. Websites can't see your local network address without your involvement.

Is WebRTC safe to use on public Wi-Fi?

Yes. The data is encrypted end to end, so other people on the Wi-Fi can't read it.