Security review and fix issues

This commit is contained in:
2026-11-03 23:57:48 +02:00
parent 5f456e64d0
commit 78989f7b56
14 changed files with 95 additions and 18 deletions
@@ -76,6 +76,10 @@ internal object AndroidPgpPolicy {
"The message body and attachments will be readable by the mail provider and anyone who receives it. Send plaintext anyway?"
}
fun unverifiedRawMimeWarning(): String =
"Android cannot verify that this raw MIME message is actually encrypted. It may contain readable message content, including inside a deceptive OpenPGP wrapper. " +
"Signing alone does not encrypt a message. Continue only if you independently verified the MIME contents and intend to send them."
private fun safeLabel(values: List<String>): String =
values.joinToString(", ").replace(Regex("[\\r\\n\\u0000]"), " ").take(300).ifBlank { "this contact" }
@@ -638,10 +638,11 @@ class EpMailPlugin : Plugin() {
sendPrepared(call, input)
return
}
val rawMime = input.optString("rawBase64").isNotBlank()
showPgpConfirmation(
title = "Send without OpenPGP encryption?",
title = if (rawMime) "Send unverified MIME?" else "Send without OpenPGP encryption?",
message = warning,
confirmLabel = "Send plaintext",
confirmLabel = if (rawMime) "Send anyway" else "Send plaintext",
onConfirmed = { sendPrepared(call, input) },
onCancelled = {
call.resolve(JSObject().put("failed", true).put("code", "PLAINTEXT_CANCELLED").put("message", "Plaintext send cancelled."))
@@ -667,7 +668,7 @@ class EpMailPlugin : Plugin() {
}
private fun plaintextSendWarning(input: JSONObject): String? {
if (input.optString("rawBase64").isNotBlank()) return null
if (input.optString("rawBase64").isNotBlank()) return AndroidPgpPolicy.unverifiedRawMimeWarning()
val recipients = (listOf(input.optString("to"), input.optString("cc"))
.filter(String::isNotBlank)
.flatMap { InternetAddress.parse(it, true).mapNotNull { address -> (address as? InternetAddress)?.address?.lowercase(Locale.ROOT) } })