Normalize signature mime types when filtering attachments in emails
What does this MR do?
Fixes signatures filtering in emails when a MUA mixes x-
prefixed and non prefixed mime types. We normalize the content-types using the MIME
library, already included in the project.
We have found that when replying to issues via email, some comments didn't get their S/MIME signature dropped by gitlab, when they should have after !25389 (merged) in 12.8.
We pinpointed this to the raw emails having a mix of declared mime types with and without x-
prefix in the same message. In the sample below, notice how the declared protocol and attachment content-type do not match:
...
Content-Type: multipart/signed;
protocol="application/x-pkcs7-signature";
micalg=SHA1;
boundary="----=_NextPart_000_03BB_01D609D9.B3D67D60"
...
Content-Type: application/pkcs7-signature;
name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="smime.p7s"
...
RFC5751 Compatibility with Prior Practice of S/MIME covering S/MIME v3 links to RFC2311 for S/MIME v2, which states that x-pkcs7-signature
should be covered for compatibility.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team