mime: reject CR and LF in mail part name and filename - #22247
Closed
alhudz wants to merge 2 commits into
Closed
Conversation
|
Analysis of PR #22247 at a90b6182: Test 3227 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 6 different CI jobs (the link just goes to one of them). Generated by Testclutch |
The test allocated the easy and mime handles then ran its assertions with cleanup at the end, so any abort_unless jumped past the cleanup. Under torture testing an early allocation failure leaked those handles. Move the handles ahead of UNITTEST_BEGIN and free them from the UNITTEST_END stop function so all abort paths tear down cleanly. Signed-off-by: Alhuda Khan <al.hudz.k@gmail.com>
Contributor
Author
|
The torture failure was in the test, not the fix. Verified locally with |
Contributor
Author
|
any update? |
bagder
approved these changes
Jul 13, 2026
Member
|
Thanks! |
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.
Repro: send mail over SMTP (or
IMAPAPPEND) with a mime part whosefilename(orname) contains aCRorLF, e.g.curl_mime_filename(part, "a\r\nX-Injected: 1").Cause:
add_content_disposition()builds theContent-Dispositionheader and, for the mail strategy (and the legacymime_formescapemode),escape_string()only backslash-quotes the value. ACRorLFin the partname/filenameis written raw into the quoted-string and splits the generated MIME header, so a crafted filename smuggles extra header lines into the message. The HTTP form strategy already percent-encodesCR/LF(%0D/%0A), so only the mail/backslash path was affected.Fix: reject a
CRorLFin the part name or filename inadd_content_disposition()when the backslash strategy is in effect, before the header is built.unit3227covers the mail rejection, a clean mail part, and that the form path stays accepted (encoded).