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

IMAPCrypt doesn't encrypt some mails containing attachments #4

Open
ghost opened this issue Mar 29, 2018 · 15 comments
Open

IMAPCrypt doesn't encrypt some mails containing attachments #4

ghost opened this issue Mar 29, 2018 · 15 comments

Comments

@ghost
Copy link

ghost commented Mar 29, 2018

Hi,

Thanks for this great tool, I managed to encrypt years of clear text emails. I got into trouble for some emails, they were not encrypted by IMAPCrypt. They were not corrupted, IMAPCrypt just skipped them. I got the following output:

2018-03-29 13:43:47 INFO  IMAPCrypt:316 - Message #31 on REDACTED REDACTED
2018-03-29 13:43:47 DEBUG IMAPCrypt:341 - Encrypting the MultiPartMime message
2018-03-29 13:43:47 ERROR IMAPCrypt:363 - The message failed to encrypt because of a IllegalWriteException: javax.mail.IllegalWriteException: IMAPBodyPart is read-only

It mainly affected messages with inline attachments, mails with .pdf or images attachments.

@ghost ghost changed the title IMAPCrypt do not encrypt some mails containing attachments IMAPCrypt does encrypt some mails containing attachments Mar 29, 2018
@ghost ghost changed the title IMAPCrypt does encrypt some mails containing attachments IMAPCrypt doesn't encrypt some mails containing attachments Mar 29, 2018
@chrislee35
Copy link
Owner

chrislee35 commented Mar 29, 2018 via email

@ghost
Copy link
Author

ghost commented Mar 29, 2018

I ran a dovecot server on my computer and duplicated some email there to avoid data loss!

@chrislee35
Copy link
Owner

Looks like I need to fix a few things before I fix this issue. I need to parse the new format of gpg --list-secret-keys output.

@chrislee35
Copy link
Owner

I was able to reproduce it. Now for the fun part.

@ghost
Copy link
Author

ghost commented Mar 30, 2018

I just noticed that signed only emails are not encrypted.

@chrislee35
Copy link
Owner

chrislee35 commented Mar 30, 2018 via email

@ghost
Copy link
Author

ghost commented Mar 30, 2018 via email

@chrislee35
Copy link
Owner

Ok, I've studied the problem enough to know that this will take me a good while to fix. I've got to brush up on multipart mime and my pgp encoding options again... fun times reading RFCs... or I could try a bunch of random changes and see if something works for all my test cases... I think I'll try that and then see if I can get help with the first option.

@chrislee35
Copy link
Owner

I got it passing the first round of tests. I had one error masking another. I'll look at the signed issue as well for my second round of tests.

@chrislee35
Copy link
Owner

I received mixed results on my signed test. Out of 4 messages, 3 signed messages encrypted fine with 1 throwing an error:
2018-03-30 23:16:03 ERROR IMAPCrypt:364 - The message failed to encrypt because of a IllegalWriteException: javax.mail.IllegalWriteException: IMAPBodyPart is read-only
I'm still researching

@chrislee35
Copy link
Owner

I still have a few signed messages that won't encrypt. They begin with:
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
For your messages that are signed, but won't encrypt, were they OpenPGP/MIME signed.

@ghost
Copy link
Author

ghost commented Mar 31, 2018

Yes most of them have the same line in the raw file! Some doesn't have anything standing out outside of the message boundaries I think?

@chrislee35
Copy link
Owner

It's been a one-step-forward, two-steps-back kinda week. I'm still working this, just haven't had a lot of luck yet.

@chrislee35
Copy link
Owner

AFAICT, the problem is in how PGPMime for Java is adding the header to IMAP. I asked for help.

javax.mail.IllegalWriteException: IMAPBodyPart is read-only
at com.sun.mail.imap.IMAPBodyPart.setHeader(IMAPBodyPart.java:325)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.updateHeaders(GnuPGExecuter.java:201)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.updateHeaders(GnuPGExecuter.java:153)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.updateHeaders(GnuPGExecuter.java:170)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.writeBodyPart(GnuPGExecuter.java:123)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGBodyPartEncrypter.encrypt(GnuPGBodyPartEncrypter.java:89)
at de.buelowssiege.mail.pgp_mime.MimeMultipartEncrypted.createInstance(MimeMultipartEncrypted.java:92)
at de.buelowssiege.mail.pgp_mime.MimeMultipartEncrypted.createInstance(MimeMultipartEncrypted.java:67)
at [org.dhs.chrislee.IMAPCrypt.encrypt(IMAPCrypt.java:344)](https://github.com/chrislee35/IMAPCrypt/blob/master/src/org/dhs/chrislee/IMAPCrypt.java#L344)

@intika
Copy link

intika commented Dec 20, 2019

Hi,
thanks for this nice tool :) ...
what's the status here ?

Do you thing encrypting the subject line would be possible ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants