Skip to content

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.

🛠 with at Siemens

/cc @bufferoverflow @rpaik

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Diego Louzán

Merge request reports