note 56852 deleted from ref.mail by mazzanet
| From: | mazzanet@php.net | Date: | Fri, 16 Sep 2005 21:31:45 +0000 |
| Subject: | note 56852 deleted from ref.mail by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-95308@lists.php.net to get a copy of this message | ||
Note Submitter: Raymond Davey
----
We had a problem with Email Injection Hijacks and came up with the following solution.
We had TEXTAREA fields that we needed to keep the cr/lf combinations and could not use the
"\r" and "\n" checking.
So instead, we removed the colon from every field that was going to be used in the mail function.
$from=str_replace(":" , "", $_POST["sender"] );
$message=str_replace(":" ,"", $_POST["message"] );
I know that the recipient of the form would still receive the email - but the hacker would not be
able to include any other headers. The added benefit is that you can keep the formatting of the
TEXTAREA fields (with the removal of the colons)
An interesting side effect is that you will also know if someone is trying to hack your form.