fix(pgp): require real PGP/MIME structure for encryption gate - #128
Draft
KamyarAT wants to merge 1 commit into
Draft
fix(pgp): require real PGP/MIME structure for encryption gate#128KamyarAT wants to merge 1 commit into
KamyarAT wants to merge 1 commit into
Conversation
Stop accepting mail when application/pgp-encrypted appears only as a raw substring. Accept only multipart/encrypted messages that include an application/pgp-encrypted control part, plus Secure-Join and bounce exceptions. Restore marker-bypass regression tests (unit + SMTP 523) and fix the SMTP test DATA harness so blank MIME lines are preserved.
Contributor
|
I think this must be a feature that we can activate it on the dashboard panel as an service option to enforce it hardy + know the cost of it |
KamyarAT
marked this pull request as draft
August 14, 2026 09:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The PGP-only gate accepted any message containing the raw substring
application/pgp-encrypted, including when that token only appeared in Subject, body text, MIME parameters, or other non-structural places. Attackers could therefore submit cleartext (or weakly structured) mail that still passed the encryption check.This PR requires a real PGP/MIME structure: root
Content-Type: multipart/encryptedand a part withContent-Type: application/pgp-encrypted(RFC 3156 control part). Secure-Joinmultipart/mixedhandshakes andmailer-daemon+multipart/reportbounces remain allowed.Regression coverage from the earlier marker suite is restored and expected to pass with the production fix.
Type of change
Area
external/madmail-admin-web)docs/project/,docs/TDD/, user guide)chatmail-pgpencryption gateTesting
cargo fmt --all -- --checkcargo clippy -p chatmail-pgp -p chatmail-smtp --all-targets -- -D warningscargo test -p chatmail-pgp --lib(30/30)cargo test -p chatmail-smtp --lib(37/37, includes marker → 523 and real PGP/MIME → 250)Manual verification (if any):
Documentation
docs/project/user-guide/, install guides)docs/project/)docs/TDD/)Security & privacy
Failures still surface as
523 Encryption Needed/EncryptionNeededwithout leaking internal structure details.Commits
fix:bug fixChecklist
data/,target/, ornode_modules/committedexternal/madmail-admin-webchangedAligns with TDD/security policy: properly formed
multipart/encryptedPGP/MIME, Secure-Join, and bounce exceptions only.