-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #80710: imap_mail_compose() header injection
Like `mail()` and `mb_send_mail()`, `imap_mail_compose()` must prevent header injection. For maximum backward compatibility, we still allow header folding for general headers, and still accept trailing line breaks for address lists.
- Loading branch information
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--TEST-- | ||
Bug #80710 (imap_mail_compose() header injection) - MIME Splitting Attack | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("imap")) die("skip imap extension not available"); | ||
?> | ||
--FILE-- | ||
<?php | ||
$envelope["from"]= "joe@example.com\n From : X-INJECTED"; | ||
$envelope["to"] = "foo@example.com\nFrom: X-INJECTED"; | ||
$envelope["cc"] = "bar@example.com\nFrom: X-INJECTED"; | ||
$envelope["subject"] = "bar@example.com\n\n From : X-INJECTED"; | ||
$envelope["x-remail"] = "bar@example.com\nFrom: X-INJECTED"; | ||
$envelope["something"] = "bar@example.com\nFrom: X-INJECTED"; | ||
|
||
$part1["type"] = TYPEMULTIPART; | ||
$part1["subtype"] = "mixed"; | ||
|
||
$part2["type"] = TYPEAPPLICATION; | ||
$part2["encoding"] = ENCBINARY; | ||
$part2["subtype"] = "octet-stream\nContent-Type: X-INJECTED"; | ||
$part2["description"] = "some file\nContent-Type: X-INJECTED"; | ||
$part2["contents.data"] = "ABC\nContent-Type: X-INJECTED"; | ||
|
||
$part3["type"] = TYPETEXT; | ||
$part3["subtype"] = "plain"; | ||
$part3["description"] = "description3"; | ||
$part3["contents.data"] = "contents.data3\n\n\n\t"; | ||
|
||
$body[1] = $part1; | ||
$body[2] = $part2; | ||
$body[3] = $part3; | ||
|
||
echo imap_mail_compose($envelope, $body); | ||
?> | ||
--EXPECTF-- | ||
Warning: imap_mail_compose(): header injection attempt in from in %s on line %d |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--TEST-- | ||
Bug #80710 (imap_mail_compose() header injection) - Remail | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("imap")) die("skip imap extension not available"); | ||
?> | ||
--FILE-- | ||
<?php | ||
$envelope["from"]= "joe@example.com\n From : X-INJECTED"; | ||
$envelope["to"] = "foo@example.com\nFrom: X-INJECTED"; | ||
$envelope["cc"] = "bar@example.com\nFrom: X-INJECTED"; | ||
$envelope["subject"] = "bar@example.com\n\n From : X-INJECTED"; | ||
$envelope["remail"] = "X-INJECTED-REMAIL: X-INJECTED\nFrom: X-INJECTED-REMAIL-FROM"; //<--- Injected as first hdr | ||
$envelope["something"] = "bar@example.com\nFrom: X-INJECTED"; | ||
|
||
$part1["type"] = TYPEMULTIPART; | ||
$part1["subtype"] = "mixed"; | ||
|
||
$part2["type"] = TYPEAPPLICATION; | ||
$part2["encoding"] = ENCBINARY; | ||
$part2["subtype"] = "octet-stream\nContent-Type: X-INJECTED"; | ||
$part2["description"] = "some file\nContent-Type: X-INJECTED"; | ||
$part2["contents.data"] = "ABC\nContent-Type: X-INJECTED"; | ||
|
||
$part3["type"] = TYPETEXT; | ||
$part3["subtype"] = "plain"; | ||
$part3["description"] = "description3"; | ||
$part3["contents.data"] = "contents.data3\n\n\n\t"; | ||
|
||
$body[1] = $part1; | ||
$body[2] = $part2; | ||
$body[3] = $part3; | ||
|
||
echo imap_mail_compose($envelope, $body); | ||
?> | ||
--EXPECTF-- | ||
Warning: imap_mail_compose(): header injection attempt in remail in %s on line %d |