Page MenuHomePhabricator

Implement inbound notif session creation from the NSE with race condition handling
ClosedPublic

Authored by marcin on Jul 15 2024, 5:18 AM.
Tags
None
Referenced Files
F3342238: D12750.id42946.diff
Fri, Nov 22, 12:50 AM
F3342235: D12750.id42717.diff
Fri, Nov 22, 12:48 AM
F3339258: D12750.diff
Thu, Nov 21, 7:25 PM
F3337150: D12750.diff
Thu, Nov 21, 3:49 PM
Unknown Object (File)
Wed, Nov 20, 3:41 AM
Unknown Object (File)
Wed, Nov 20, 3:17 AM
Unknown Object (File)
Wed, Nov 20, 2:44 AM
Unknown Object (File)
Fri, Nov 15, 5:18 PM
Subscribers

Details

Summary

This differential implements inbound notification session creation with race condition handling. The NSE code is modified to use this mechanism when receiving E2EE notification from peer. Android part in CommNotificationsHandler.java will be added shortly after Tunnelbroker <-> FCM diff is out.

Test Plan
  1. Apply this patch: https://gist.github.com/marcinwasowicz/8bdc755abad8ecf81f3bd01c6ca34376
  2. Send notification from web to iOS device.
  3. Ensure that each notification results in two identical notification being displayed. One is from the keyserver. The other is from tunnelbroker and is E2EE encrypted.
  4. I also added some logs in NotificationsCryptoModule so that it is logged whether we create new session or use existing one. I only saw the first type of log once.

Diff Detail

Repository
rCOMM Comm
Branch
marcin/eng-8237
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.h
114

When we create inbound session from notification we need to return updated notif account state as well since one time key is removed from the account.

147

When we win race condition we create an emphemeral one time session to decrypt single message but we don't persist anything. The StatefulPeerConflictDecryptResult implementation of flushState is a np-op.

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 15 2024, 5:42 AM
Harbormaster failed remote builds in B30328: Diff 42290!
native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
613
native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
709

Decryption with immediate state persistence is used on Android.

Use common C++ implementation on Android. It was tested the same way as iOS using latest staging Tunnelbroker release

kamil added inline comments.
native/cpp/CommonCpp/CryptoTools/Session.cpp
86–91 ↗(On Diff #42717)

this is huge change, I would create a separate diff to test it separately but I think it's okay

This revision is now accepted and ready to land.Jul 25 2024, 7:46 AM