Skip to content

Commit c1ccfcc

Browse files
iequidoolink2xt
authored andcommitted
fix: Don't log SecureJoin QRs
Delta Chat mustn't write sensitive information to unencrypted log files in local storage.
1 parent 5b0e334 commit c1ccfcc

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

src/qr.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ fn starts_with_ignore_case(string: &str, pattern: &str) -> bool {
249249
/// The function should be called after a QR code is scanned.
250250
/// The function takes the raw text scanned and checks what can be done with it.
251251
pub async fn check_qr(context: &Context, qr: &str) -> Result<Qr> {
252-
info!(context, "Scanned QR code: {}", qr);
253-
254252
let qrcode = if starts_with_ignore_case(qr, OPENPGP4FPR_SCHEME) {
255253
decode_openpgp(context, qr)
256254
.await
@@ -474,8 +472,7 @@ fn decode_account(qr: &str) -> Result<Qr> {
474472
let payload = qr
475473
.get(DCACCOUNT_SCHEME.len()..)
476474
.context("invalid DCACCOUNT payload")?;
477-
let url =
478-
url::Url::parse(payload).with_context(|| format!("Invalid account URL: {payload:?}"))?;
475+
let url = url::Url::parse(payload).context("Invalid account URL")?;
479476
if url.scheme() == "http" || url.scheme() == "https" {
480477
Ok(Qr::Account {
481478
domain: url
@@ -484,7 +481,7 @@ fn decode_account(qr: &str) -> Result<Qr> {
484481
.to_string(),
485482
})
486483
} else {
487-
bail!("Bad scheme for account URL: {:?}.", payload);
484+
bail!("Bad scheme for account URL: {:?}.", url.scheme());
488485
}
489486
}
490487

@@ -495,8 +492,7 @@ fn decode_webrtc_instance(_context: &Context, qr: &str) -> Result<Qr> {
495492
.context("invalid DCWEBRTC payload")?;
496493

497494
let (_type, url) = Message::parse_webrtc_instance(payload);
498-
let url =
499-
url::Url::parse(&url).with_context(|| format!("Invalid WebRTC instance: {payload:?}"))?;
495+
let url = url::Url::parse(&url).context("Invalid WebRTC instance")?;
500496

501497
if url.scheme() == "http" || url.scheme() == "https" {
502498
Ok(Qr::WebrtcInstance {
@@ -507,7 +503,7 @@ fn decode_webrtc_instance(_context: &Context, qr: &str) -> Result<Qr> {
507503
instance_pattern: payload.to_string(),
508504
})
509505
} else {
510-
bail!("Bad URL scheme for WebRTC instance: {:?}", payload);
506+
bail!("Bad URL scheme for WebRTC instance: {:?}", url.scheme());
511507
}
512508
}
513509

@@ -549,16 +545,15 @@ async fn set_account_from_qr(context: &Context, qr: &str) -> Result<()> {
549545
.send()
550546
.await?;
551547
let response_status = response.status();
552-
let response_text = response.text().await.with_context(|| {
553-
format!("Cannot create account, request to {url_str:?} failed: empty response")
554-
})?;
548+
let response_text = response
549+
.text()
550+
.await
551+
.context("Cannot create account, request failed: empty response")?;
555552

556553
if response_status.is_success() {
557554
let CreateAccountSuccessResponse { password, email } = serde_json::from_str(&response_text)
558555
.with_context(|| {
559-
format!(
560-
"Cannot create account, response from {url_str:?} is malformed:\n{response_text:?}"
561-
)
556+
format!("Cannot create account, response is malformed:\n{response_text:?}")
562557
})?;
563558
context
564559
.set_config_internal(Config::Addr, Some(&email))
@@ -653,7 +648,7 @@ pub async fn set_config_from_qr(context: &Context, qr: &str) -> Result<()> {
653648
Qr::Login { address, options } => {
654649
configure_from_login_qr(context, &address, options).await?
655650
}
656-
_ => bail!("qr code {:?} does not contain config", qr),
651+
_ => bail!("QR code does not contain config"),
657652
}
658653

659654
Ok(())

src/securejoin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ pub async fn get_securejoin_qr(context: &Context, group: Option<ChatId>) -> Resu
124124
)
125125
};
126126

127-
info!(context, "Generated QR code: {}", qr);
128-
127+
info!(context, "Generated QR code.");
129128
Ok(qr)
130129
}
131130

src/securejoin/qrinvite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl TryFrom<Qr> for QrInvite {
9797
invitenumber,
9898
authcode,
9999
}),
100-
_ => bail!("Unsupported QR type {:?}", qr),
100+
_ => bail!("Unsupported QR type"),
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)