30, August 2008

Email header injections - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Email header injections
« previous next »
Pages: [1] Print

Author Topic: Email header injections  (Read 816 times)
What's HTML?
****
Gender: Male
Posts: 402
2430 credits
Members referred : 2



« on: Jun 07, 2007, 01:22:04 PM »

I have implemented a check for email header injection in my contact forms I create for clients
but I am not 100% sure I am actually doing it right,

I check to see if there is a "cc:" and "bcc:" string injected in any of my form fields
and if there is I don't send the email (and I actually put a deny rule in the htaccess so they can't try anything else)

I was reading http://www.securephpwiki.com/index.php/Email_Injection Visit through proxy
and realized that subject: can also be injected
but since I am checking for cc and bcc I  think I am safe ?
since a spammer will specify one of the two (most probably bcc)

Is there any other way that the could use my email to send spam ?

Thanks


Last blog : SeoDigger: Free Keyword Research tool
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8029
41131 credits
Members referred : 3



« Reply #1 on: Jun 07, 2007, 01:34:28 PM »

I think those are enough.

The only extra thing that someone could do is use the body (I think) to attach a virus file, but I guess this is not something too common Smiley

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jun 07, 2007, 05:11:26 PM »

You need to check all formfields which belong into the mail header (check the mail message you send via the form.

1. validate email addresses (if available and used as from:)
2. check all the (header) fields with:

$email preg_replace("/\r\n/"""$_REQUEST['email']);



Last blog : Is your website is down? Know before your visitors do!
What's HTML?
****
Gender: Male
Posts: 402
2430 credits
Members referred : 2



« Reply #3 on: Jun 08, 2007, 06:13:20 PM »

I am not sure exactly what you are saying Olaf,

I am checking all form fields,
if I see a bcc or cc in them it means someone is trying to attack my mail form
then I don't send email, and I also put a "deny ip" in my htaccess so the attacker does not try anything else

wouldn't that be enough ? you say


Last blog : SeoDigger: Free Keyword Research tool
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jun 09, 2007, 08:58:45 AM »

as your forum subject says only the headers must be protected.
the email address need to because multiple entries need to be validated too

all other form fields which are placed the mail header need that check above.


Last blog : Is your website is down? Know before your visitors do!
What's HTML?
****
Gender: Male
Posts: 402
2430 credits
Members referred : 2



« Reply #5 on: Jun 09, 2007, 06:21:22 PM »

I guess what confuses me is the reasoning behind this:

$email = preg_replace("/\r\n/", "", $_REQUEST['email']);

what does it do ?

It strips away carriage returns/line feeds right ?

what does that accomplish ?

You destroy all the line feeds and the mail() can't function properly ?
(since ALL the headers MUST be seperated with with line feeds)


Last blog : SeoDigger: Free Keyword Research tool
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jun 09, 2007, 07:29:11 PM »

I guess what confuses me is the reasoning behind this:

$email = preg_replace("/\r\n/", "", $_REQUEST['email']);

what does it do ?

It strips away carriage returns/line feeds right ?

what does that accomplish ?

You destroy all the line feeds and the mail() can't function properly ?
(since ALL the headers MUST be seperated with with line feeds)


you remove only the line feeds submitted via the form


Last blog : Is your website is down? Know before your visitors do!
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6763
Tags : email header injection Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Email header injections
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Aug 30, 2008, 01:30:06 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.176
Total Topics: 7.461
Total Members: 3.861
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: matsolof

33 Guests, 3 Users online :

17 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.