Skip to content

Commit 429e87c

Browse files
committed
Sketch (just TODO comments) for prevent-online-leak
1 parent 3748794 commit 429e87c

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/chat.rs

+3
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ impl ChatId {
431431
context.emit_event(EventType::ChatModified(self));
432432
}
433433

434+
// TODO Check in the sql table `alicestate` whether we need to resume the securejoin protocol.
435+
// If so, remember to also update the `alicestate` table.
436+
434437
Ok(())
435438
}
436439

src/securejoin.rs

+19
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ pub(crate) async fn handle_securejoin_handshake(
326326
ChatId::create_for_contact(context, contact_id).await?;
327327
}
328328

329+
// TODO Here we need to check that the token isn't too old (no more than 2 days)
330+
// and if it is too old, then we need to put the chat into "Request" state.
331+
// Except if `get_config(Config::IsBot)` is true, in this case we just continue normally.
332+
333+
// When the "Request" state is accepted (`ChatId::accept()`), we need to continue here. Also, we need to
334+
// remember in the database that the user accepted a securejoin and the current timestamp.
335+
// This probably needs to go into a new table `alicestate` or similar
336+
329337
// Alice -> Bob
330338
send_alice_handshake_msg(
331339
context,
@@ -432,6 +440,17 @@ pub(crate) async fn handle_securejoin_handshake(
432440
info!(context, "Auth verified.",);
433441
context.emit_event(EventType::ContactsChanged(Some(contact_id)));
434442
inviter_progress!(context, contact_id, 600);
443+
444+
// TODO Here we need to check that the token isn't too old
445+
// and if it is too old, then we need to put the chat into "Request" state.
446+
447+
// Except if `get_config(Config::IsBot)` is true, in this case we just continue normally.
448+
449+
// Except if the user already accepted the securejoin above in the last 2 days,
450+
// in this case we just continue normally.
451+
452+
// When the "Request" state is accepted (in `ChatId::accept()`), we need to continue here.
453+
435454
if join_vg {
436455
// the vg-member-added message is special:
437456
// this is a normal Chat-Group-Member-Added message

src/sql/migrations.rs

+7
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,13 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid);
749749
)
750750
.await?;
751751
}
752+
// TODO we need a new table called `alicestate` or similar for alice's state, which can be (for each chat):
753+
// - Paused at step 3 because the invite code was too old.
754+
// - Resumed by the user clicking "accept" after step 3. We need to save the timestamp when the user clicked "accept".
755+
// - Paused at step 6 because the auth code was too old.
756+
// I think that if it's none of these 3 states, there is no need to save it.
757+
758+
// See https://countermitm.readthedocs.io/en/latest/new.html#setup-contact-protocol
752759

753760
let new_version = sql
754761
.get_raw_config_int(VERSION_CFG)

0 commit comments

Comments
 (0)