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

Ensure Mime-Version is set on the right header #15

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emersion
Copy link
Owner

  • The nested encrypted part may still contain a Mime-Version header field

Closes: #14

@rjarry
Copy link

rjarry commented Mar 4, 2024

Hi @emersion, I tested this. It works. I will apply the same workaround on aerc's gpg implementation. Thanks!

rjarry added a commit to rjarry/aerc that referenced this pull request Mar 10, 2024
Some MTAs try to normalize the case of all headers (including signed
text parts headers). Unfortunately, Mime-Version can be normalized to
different casing depending on the implementation (MIME- vs Mime-).

Since the signature is computed on the whole part, including its header,
changing the case can cause the signature to become invalid.

Due to how multipart/signed messages are constructed, we need to hack
around go-message writers to intercept the writing of a text part,
compute its signature and write the actual message with the proper
headers.

Unfortunately, go-message does not allow creating a message writer that
does not insert a Mime-Version header. This causes the Mime-Version
header to be inserted in the wrong place: it is put inside the signed
text part header instead on the top level header. Thus, included in the
signed content.

Make sure to remove any Mime-Version header from the signed part header.
Finally, ensure that Mime-Version is set on the top-level header so that
messages are compliant with RFC 2045.

Fixes: https://todo.sr.ht/~rjarry/aerc/143
Link: emersion/go-message#165
Link: emersion/go-pgpmail#15
Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CCQRPF5EA0TF8.PEJ4AKCEGMFM%40fembook%3E
Changelog-fixed: `Mime-Version` is no longer inserted in signed
 text parts headers. MTAs normalizing header case will not corrupt
 signatures anymore.
Reported-by: Coco Liliace <chloe@liliace.dev>
Reported-by: Kirill Chibisov <contact@kchibisov.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
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

Successfully merging this pull request may close these issues.

writer creates multipart MIME messages without the MIME-Version header
2 participants