Skip to content

Commit 64ece5c

Browse files
committed
feat: protect Autocrypt header
1 parent b3c5787 commit 64ece5c

File tree

6 files changed

+7
-54
lines changed

6 files changed

+7
-54
lines changed

src/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,6 @@ pub enum Config {
396396
/// Make all outgoing messages with Autocrypt header "multipart/signed".
397397
SignUnencrypted,
398398

399-
/// Enable header protection for `Autocrypt` header.
400-
///
401-
/// This is an experimental setting not compatible to other MUAs
402-
/// and older Delta Chat versions (core version <= v1.149.0).
403-
ProtectAutocrypt,
404-
405399
/// Let the core save all events to the database.
406400
/// This value is used internally to remember the MsgId of the logging xdc
407401
#[strum(props(default = "0"))]

src/context.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,12 +1033,6 @@ impl Context {
10331033
.await?
10341034
.to_string(),
10351035
);
1036-
res.insert(
1037-
"protect_autocrypt",
1038-
self.get_config_int(Config::ProtectAutocrypt)
1039-
.await?
1040-
.to_string(),
1041-
);
10421036
res.insert(
10431037
"debug_logging",
10441038
self.get_config_int(Config::DebugLogging).await?.to_string(),

src/mimefactory.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,6 @@ impl MimeFactory {
967967
hidden_headers.push(header.clone());
968968
} else if is_hidden(&header_name) {
969969
hidden_headers.push(header.clone());
970-
} else if header_name == "autocrypt"
971-
&& !context.get_config_bool(Config::ProtectAutocrypt).await?
972-
{
973-
unprotected_headers.push(header.clone());
974970
} else if header_name == "from" {
975971
// Unencrypted securejoin messages should _not_ include the display name:
976972
if is_encrypted || !is_securejoin_message {

src/mimefactory/mimefactory_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ async fn test_selfavatar_unencrypted_signed() {
663663
assert_eq!(part.match_indices("From:").count(), 1);
664664
assert_eq!(part.match_indices("Message-ID:").count(), 0);
665665
assert_eq!(part.match_indices("Subject:").count(), 1);
666-
assert_eq!(part.match_indices("Autocrypt:").count(), 0);
666+
assert_eq!(part.match_indices("Autocrypt:").count(), 1);
667667
assert_eq!(part.match_indices("Chat-User-Avatar:").count(), 0);
668668

669669
let part = payload.next().unwrap();
@@ -714,7 +714,7 @@ async fn test_selfavatar_unencrypted_signed() {
714714
assert_eq!(part.match_indices("From:").count(), 1);
715715
assert_eq!(part.match_indices("Message-ID:").count(), 0);
716716
assert_eq!(part.match_indices("Subject:").count(), 1);
717-
assert_eq!(part.match_indices("Autocrypt:").count(), 0);
717+
assert_eq!(part.match_indices("Autocrypt:").count(), 1);
718718
assert_eq!(part.match_indices("Chat-User-Avatar:").count(), 0);
719719

720720
let part = payload.next().unwrap();

src/mimeparser/mimeparser_tests.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,39 +1819,6 @@ async fn test_take_last_header() {
18191819
);
18201820
}
18211821

1822-
async fn test_protect_autocrypt(enabled: bool) -> Result<()> {
1823-
let mut tcm = TestContextManager::new();
1824-
let alice = &tcm.alice().await;
1825-
let bob = &tcm.bob().await;
1826-
1827-
let chat = alice.create_chat(bob).await;
1828-
alice
1829-
.set_config_bool(Config::ProtectAutocrypt, enabled)
1830-
.await?;
1831-
let sent = alice.send_text(chat.id, "Hello!").await;
1832-
assert_eq!(sent.payload().contains("Autocrypt: "), !enabled);
1833-
let msg = bob.recv_msg(&sent).await;
1834-
assert_eq!(msg.get_showpadlock(), true);
1835-
1836-
Ok(())
1837-
}
1838-
1839-
/// Tests that if `protect_autocrypt` is enabled,
1840-
/// `Autocrypt` header does not appear in the outer headers
1841-
/// of encrypted messages.
1842-
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
1843-
async fn test_protect_autocrypt_enabled() -> Result<()> {
1844-
test_protect_autocrypt(true).await
1845-
}
1846-
1847-
/// Tests that if `protect_autocrypt` is disabled,
1848-
/// `Autocrypt` header appears in the outer headers
1849-
/// of encrypted messages.
1850-
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
1851-
async fn test_protect_autocrypt_false() -> Result<()> {
1852-
test_protect_autocrypt(false).await
1853-
}
1854-
18551822
/// Tests that CRLF before MIME boundary
18561823
/// is not treated as the part body.
18571824
///

src/tests/aeap.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ async fn test_aeap_replay_attack() -> Result<()> {
217217
// Fiona gets the message, replaces the From addr...
218218
let sent = sent
219219
.payload()
220-
.replace("From: <[email protected]>", "From: <[email protected]>")
221-
220+
.replace("From: <[email protected]>", "From: <[email protected]>");
222221
sent.find("From: <[email protected]>").unwrap(); // Assert that it worked
223-
sent.find("[email protected];").unwrap(); // Assert that it worked
222+
223+
// Autocrypt header is protected, nothing to replace outside.
224+
// In the signed part we cannot replace it without breaking the signature.
225+
assert!(!sent.contains("[email protected];"));
224226

225227
tcm.section("Fiona replaced the From addr and forwards the message to Bob");
226228
receive_imf(&bob, sent.as_bytes(), false).await?.unwrap();

0 commit comments

Comments
 (0)