Skip to content

Data tracks E2EE support - #994

Open
ladvoc wants to merge 4 commits into
ladvoc/generalize-data-cryptorfrom
ladvoc/data-track-e2ee
Open

ladvoc wants to merge 4 commits into
ladvoc/generalize-data-cryptorfrom
ladvoc/data-track-e2ee

Conversation

@ladvoc

@ladvoc ladvoc commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Encrypts published frames and decrypts subscribed ones with the room's DataCryptor when WithDataEncryption is set.

Closes BOT-541

@ladvoc
ladvoc force-pushed the ladvoc/data-track-e2ee branch from 817a3ba to 3f5de40 Compare September 4, 2026 16:04
@ladvoc
ladvoc force-pushed the ladvoc/data-track-e2ee branch 2 times, most recently from 1e53667 to 6813ce7 Compare September 8, 2026 21:55
@ladvoc ladvoc mentioned this pull request Sep 8, 2026
@ladvoc
ladvoc force-pushed the ladvoc/data-track-e2ee branch from 6813ce7 to 4b376c1 Compare September 14, 2026 21:40
@ladvoc
ladvoc force-pushed the ladvoc/data-track-e2ee branch from 4b376c1 to 2817cf6 Compare September 14, 2026 22:27
@ladvoc
ladvoc requested a review from cnderrauber September 14, 2026 23:39
@ladvoc
ladvoc marked this pull request as ready for review September 14, 2026 23:39
@ladvoc
ladvoc requested a review from a team as a code owner September 14, 2026 23:39

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread datatrackcryptor.go
Comment on lines +58 to +62
func (r *Room) dataTrackEncryptor() datatrack.Encryptor {
if r.engine.dataCryptor == nil {
return nil
}
return dataTrackCryptor{cryptor: r.engine.dataCryptor}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Encryption persists across join retries

After an encrypted Join fails, retrying without WithDataEncryption leaves dataTrackEncryptor enabled. The retry publishes GCM tracks, so peers without the old key cannot subscribe.

Learn more

A failed join leaves the connection manager in its initial state, allowing the same room to retry. JoinWithContextAndToken replaces engine.dataCryptor only when the new options contain a key provider. An earlier provider therefore survives a later retry that omits WithDataEncryption. The added getter exposes that stale cryptor to every data-track publication in the retry.

Example: A room first joins with key A, but signaling fails. The caller retries the same room without WithDataEncryption. PublishDataTrack still advertises GCM and encrypts with key A, while unconfigured peers reject the track.

Recommended fix: Assign engine.dataCryptor on every join configuration. Set it to a new cryptor when DataEncryptionKeyProvider is non-nil and explicitly set it to nil otherwise, before any publication can query the getters.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants