Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement better detection of "multipart/encrypted" email with PGP encrypted message #2580

Closed
martgil opened this issue May 25, 2024 · 14 comments · Fixed by #2643
Closed

Implement better detection of "multipart/encrypted" email with PGP encrypted message #2580

martgil opened this issue May 25, 2024 · 14 comments · Fixed by #2643
Assignees
Milestone

Comments

@martgil
Copy link
Collaborator

martgil commented May 25, 2024

Description: The FlowCrypt iOS didn't recognize "multipart/encrypted" email with PGP encrypted message. Emails at https://mail.google.com/mail/u/[email protected]/#inbox/FMfcgzGxTFXMFnDNbgknpqvXKtSmMgSK isn't recognized by the FlowCrypt app and shows not encrypted + no signed blank email thread.

Reference:

@ioanmo226
Copy link
Collaborator

@sosnovsky I think better to finish this task first and then release current 1.3.1 version?

@sosnovsky
Copy link
Collaborator

Yes, after fixing this one we can publish a new release to App Store and switch back to flowcrypt-browser tasks.

@ioanmo226
Copy link
Collaborator

ioanmo226 commented Nov 12, 2024

@sosnovsky I don't have task assigned for iOS at the moment as you plan to migrate to Swift6 in the future. Do I have to move on browser extension?

@sosnovsky sosnovsky assigned ioanmo226 and unassigned martgil Nov 12, 2024
@sosnovsky
Copy link
Collaborator

Oh, I've missed that this one was assigned to Mart, re-assigned it to you

@ioanmo226
Copy link
Collaborator

Okay, I see
I thought Mart was already working on it.

@ioanmo226
Copy link
Collaborator

@martgil I can reproduce this issue in iOS app with email flowcrypt.compatibility account.
However could you guide me how to reproduce such email for UI testing?
Thank you

@martgil
Copy link
Collaborator Author

martgil commented Nov 12, 2024

Hi @ioanmo226, I'll try if I can craft one for you. Reason is that, the particular test email we have was just sent by the user and haven't had the chance to know to generate one for ourselves that time.

@martgil
Copy link
Collaborator Author

martgil commented Nov 12, 2024

Hello @ioanmo226 - I can't seemed to craft a test email for this one easily, may I ask for a little more time.

Upon reviewing, it possibly be able to craft such email by using Enigmail in Thunderbird but upon testing, the Enigmail extension is no longer available and supported by Thunderbird Client.

My plan is to craft and send a mime email that contains the following format in the test email from: FlowCrypt/flowcrypt-browser#5726, in which, it has "multipart/encrypted" part that has 2 attachment of the following:

1.) noname file with content: Version: 1.
2.) noname file with content:

Version: 1
----BEGIN PGP MESSAGE-----

Encrypted message goes here...
-----END PGP MESSAGE-----

@ioanmo226
Copy link
Collaborator

I see. Thank you
No problem
I haven't even implemented a fix yet.

@martgil
Copy link
Collaborator Author

martgil commented Nov 13, 2024

Hello @ioanmo226, there's some bad news here. I'm unable to generate such email even after making such similar mime email.

I'm using the python (3.11.9) code below, while it sends similar mime email and being recognizable by FlowCrypt, the decryption fails:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders

# Email account credentials
sender_email = "[email protected]"
recipient_email = "[email protected]"
password = "app specific password" # this canbe obtained in https://myaccount.google.com/apppasswords

boundary = "----=_Part_7_39145192.1715228097793"
msg = MIMEMultipart("encrypted", boundary=boundary)
msg["From"] = sender_email
msg["To"] = recipient_email
msg["Subject"] = "test multipart/encrypted"
msg["MIME-Version"] = "1.0"  

pgp_encrypted_part = MIMEBase("application", "pgp-encrypted")
pgp_encrypted_part.add_header("Content-Transfer-Encoding", "7bit")
pgp_encrypted_part.set_payload("Version: 1")

# The email.txt contains ascii armored pgp encrypted email similar to the sample email in flowcrypt.compatibility
with open("email.txt", "r") as file:
    encrypted_message = file.read()

pgp_data_part = MIMEBase("application", "octet-stream")
pgp_data_part.add_header("Content-Transfer-Encoding", "7bit")
pgp_data_part.set_payload(encrypted_message)

msg.attach(pgp_encrypted_part) 
msg.attach(pgp_data_part)       

# Send the email via Gmail's SMTP server
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
    server.login(sender_email, password)
    server.sendmail(sender_email, recipient_email, msg.as_string())

print("Email sent successfully.")

@FlowCrypt FlowCrypt deleted a comment from github-actions bot Nov 13, 2024
@ioanmo226
Copy link
Collaborator

You mean that test email was recognized by Flowcrypt which means Flowcrypt knows it is PGP but can't decrypt that email?

@martgil
Copy link
Collaborator Author

martgil commented Nov 13, 2024

Yes, that's what is happening in the test email generated using the python script when opened through the FlowCrypt browser extension.

@ioanmo226
Copy link
Collaborator

I see.
Seems like I have to replace sensitive infos from test email from flowcrypt compatibility email.(Like you did in FlowCrypt/flowcrypt-browser#5727)

@martgil
Copy link
Collaborator Author

martgil commented Nov 13, 2024

If I remember it correctly, what I did there was just to replace the sensitive infos like exact email subject and sender while retaining the format for a "multipart/encrypted" mime email.

sosnovsky pushed a commit that referenced this issue Nov 15, 2024
…PGP encrypted message (#2643)

* fix: better detection of multipart encrypted email

* feat: added ui test

* fix: pr reviews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants