Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poc e2ee #296

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Poc e2ee #296

wants to merge 9 commits into from

Conversation

lebaudantoine
Copy link
Collaborator

@lebaudantoine lebaudantoine commented Jan 6, 2025

Purpose

This PR implements end-to-end encryption (E2EE) capabilities for LiveKit rooms using WebRTC's Frame Encryption API. The implementation ensures that media streams are encrypted on the sender's side and can only be decrypted by authorized participants, maintaining confidentiality even from the LiveKit server.

It's a proof of concept, not intended to be merged.

According to LiveKit documentation :

Connections are established using 256-bit TLS encryption and media streams are encrypted with AES-128. All data at rest is encrypted with AES-256

E2EE adds an extra layer of security features, when you cannot trust the LiveKit server.

Proposal

During room access token generation, the first participant triggers the creation of a room passphrase, which is encrypted using Fernet symmetric encryption and stored in Redis. Subsequent participants retrieve this encrypted passphrase from the cache. When the room ends, LiveKit's webhook notifies the backend to invalidate the cached passphrase.

Using Fernet symmetric encryption is fine for short-term storage.

It's a naive approach, but yet simple.

All participants share an encryption key that remains constant throughout the meeting session, without rotation.

Technical Limitations

Current E2EE feature isn't perfect yet, for a few reasons:

Codec Compatibility

Limited to VP8 video and Opus audio
VP9/AV1 incompatible due to lack of encrypted backup codec support
Required for backwards compatibility with non-VP9 clients

→ doesn't support most recent and optimized Media codec.

Audio Processing

RED (Redundant Encoding) unsupported
Server cannot strip RED packets when E2EE enabled

→ Cannot enable this optimization.

Browser Support

Requires Firefox 117+ for compatibility
Chrome/Edge: 86+
Safari: 15.4+

→ Not available for our FF 115 users

Performance Considerations

Increased CPU usage on resource-constrained devices
Web Worker implementation mitigates main thread impact

AI or recording

E2EE disables Egress functionality, preventing AI features that require room audio recording and processing.

→ Disable a differentiating feature

Documentation

I haven't found any documentation on LiveKit website.

Algorithm

Yet supports only AES-GCM 128, no 256.

Source code

FrameCryptor is responsible for en-/decrypting media frames.

KeyProvider is responsible for key lifecycle.

Future Enhancements

Dynamic Encryption

  • Investigation needed: Enable/disable encryption mid-session
  • Requires careful key distribution and participant synchronization

Passphrase Requirements

  • Define secure passphrase format
  • verify the passphrase generation is totally secure

Room Configuration

  • Make encryption opt-in rather than default
  • Provide admin controls for encryption settings

My 2cts

E2EE should be disabled by default for several reasons:

  • Not all meetings require the additional security layer and computational overhead
  • Enables broader codec support (VP9, AV1) for standard meetings
  • Maintains compatibility with features like audio RED and egress
  • Not supported on our targeted FF version

End-to-end encryption becomes critical in scenarios where:

  • The LiveKit infrastructure might be compromised
  • Meeting content is highly sensitive (e.g., "Diffusion Restreinte" discussions, medical data)
  • Zero-trust security model is mandated

Comment on lines +20 to +23
webhook:
api_key: devkey
urls:
- https://meet.127.0.0.1.nip.io/api/v1.0/rooms/livekit-webhook/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually added the misssing authority certificate inside livekit alpine pod. I need to find a better solution !

@lebaudantoine
Copy link
Collaborator Author

Capture d’écran 2025-01-07 à 11 10 25

Zoom offers two options, enhanced encryption and e2e encryption by default, enhanced encryption is selected.
What is enhanced encryption in Zoom?

AES 256-bit GCM encryption, protecting message and room content. Encryption keys are generated and managed by Zoom's server.

@lebaudantoine
Copy link
Collaborator Author

/!\ default expiration of the cache, corner case, when a participant join right before, and right after.

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