Skip to content

Commit 3948573

Browse files
committed
Do not treat a PGP message with a missing or bad MDC like a non-clear-signed PGP message
- If a bad or missing MDC is detected, don’t display the decrypted content. - Display a proper error message for MDC errors. [#980 state:fixed] [fix]
1 parent f00fc4c commit 3948573

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

Diff for: Resources/de.lproj/GPGMail.strings

+2-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ NO_DEFAULTS_MESSAGE = "GPGMail funktioniert nicht wie erwartet.\n\nLade und inst
244244
"UNENCRYPTED_FORWARD_OF_ENCRYPTED_MESSAGE_BUTTON_SEND_ANYWAY" = "Trotzdem weiterleiten";
245245
"UNENCRYPTED_FORWARD_OF_ENCRYPTED_MESSAGE_BUTTON_CANCEL" = "Abbrechen";
246246

247-
247+
"MESSAGE_BANNER_PGP_DECRYPT_MDC_ERROR_TITLE" = "Es ist schädlich diese Nachricht zu entschlüsseln.";
248+
"MESSAGE_BANNER_PGP_DECRYPT_MDC_ERROR_MESSAGE" = "Der Code zum Erkennen von Änderungen (MDC) dieser verschlüsselten Nachricht ist nicht vorhanden oder wurde abgeändert.\n\nDas könnte ein Zeichen dafür sein, dass der Inhalt der verschlüsselten Nachricht von einem Angreifer verändert wurde.\n\nBitte lassen Sie sich die Nachricht erneut zusenden und lassen Sie den Absender wissen, dass deren Nachricht keinen Code zum Erkennen von Änderungen enthielt.";
248249

249250
/* Accessibility */
250251
ACCESSIBILITY_SECURITY_METHOD_POPUP_LABEL = "Sicherheitstechnik: %@";

Diff for: Resources/en.lproj/GPGMail.strings

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ NO_DEFAULTS_MESSAGE = "GPGMail is not working as expected.\n\nPlease download an
235235
"UNENCRYPTED_REPLY_TO_ENCRYPTED_MESSAGE_BUTTON_SEND_ANYWAY" = "Send Anyway";
236236
"UNENCRYPTED_REPLY_TO_ENCRYPTED_MESSAGE_BUTTON_CANCEL" = "Cancel";
237237

238+
"MESSAGE_BANNER_PGP_DECRYPT_MDC_ERROR_TITLE" = "It is not safe to decrypt this message.";
239+
"MESSAGE_BANNER_PGP_DECRYPT_MDC_ERROR_MESSAGE" = "The modification detection code (MDC) for this encrypted message is missing or has been modified.\n\nThis could mean that an attacker has been trying to modify the contents within the encrypted message.\n\nPlease have the message re-sent to you and tell the sender, that their encrypted message didn't include a modification detection code.";
238240

239241
/* Accessibility */
240242
ACCESSIBILITY_SECURITY_METHOD_POPUP_LABEL = "Security method: %@";

Diff for: Source/MimePart+GPGMail.m

+20-5
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,18 @@ - (id)decryptData:(NSData *)encryptedData {
838838
// Sometimes decryption okay is issued even though a NODATA error occured.
839839
BOOL success = gpgc.decryptionOkay && !error;
840840

841-
// Check if this is a non-clear-signed message.
842-
// Conditions: decryptionOkay == false and encrypted data has signature packets.
843-
// If decryptedData length != 0 && !decryptionOkay signature packets are expected.
844-
BOOL nonClearSigned = !gpgc.decryptionOkay && [decryptedData hasSignaturePacketsWithSignaturePacketsExpected:[decryptedData length] != 0 && !gpgc.decryptionOkay];
845-
841+
// Bug #980: If the message doesn't contain a MDC or contains a modified MDC,
842+
// GPGMail currently believes that the message is non-clear-signed and
843+
// ignores the failed decryption.
844+
//
845+
// Libmacgpg has since been patched to no longer return the decrypted content
846+
// if no MDC or a modified MDC is detected, so if data is returned and no DECRYPTION_OKAY
847+
// status line is issued, there's a high chance, that the message was non-clear-signed instead of
848+
// encrypted. In addition a check is added, to see if BEGIN_DECRYPTION wasn't issued either.
849+
BOOL nonClearSigned = ![gpgc.statusDict objectForKey:@"BEGIN_DECRYPTION"] &&
850+
![gpgc.statusDict objectForKey:@"DECRYPTION_OKAY"] &&
851+
[decryptedData length] != 0;
852+
846853
// Let's reset the error if the message is not clear-signed,
847854
// since error will be general error.
848855
if (nonClearSigned)
@@ -973,6 +980,14 @@ - (MFError *)errorForDecryptionError:(NSException *)operationError status:(NSDic
973980
titleKey = [NSString stringWithFormat:@"%@_DECRYPT_ERROR_XPC_DAMAGED_TITLE", prefix];
974981
messageKey = [NSString stringWithFormat:@"%@_DECRYPT_ERROR_XPC_DAMAGED_MESSAGE", prefix];
975982

983+
title = GMLocalizedString(titleKey);
984+
message = GMLocalizedString(messageKey);
985+
}
986+
else if(((GPGException *)operationError).errorCode == GPGErrorNoMDC ||
987+
((GPGException *)operationError).errorCode == GPGErrorBadMDC) {
988+
titleKey = [NSString stringWithFormat:@"%@_DECRYPT_MDC_ERROR_TITLE", prefix];
989+
messageKey = [NSString stringWithFormat:@"%@_DECRYPT_MDC_ERROR_MESSAGE", prefix];
990+
976991
title = GMLocalizedString(titleKey);
977992
message = GMLocalizedString(messageKey);
978993
}

0 commit comments

Comments
 (0)