28, May 2012

Email header injections - webmaster forum

 
Webdigity webmaster forums
[ 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
Instabuck - The easy way to sell digital products online

Author Topic: Email header injections  (Read 1652 times)
What's HTML?
****
Gender: Male
Posts: 408
2466 credits
Members referred : 2



« on: Jun 07, 2007, 12: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
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 : Offline Promotion Of Your Website
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Jun 07, 2007, 12: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 or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jun 07, 2007, 04: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']);
?>


What's HTML?
****
Gender: Male
Posts: 408
2466 credits
Members referred : 2



« Reply #3 on: Jun 08, 2007, 05: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 : Offline Promotion Of Your Website
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jun 09, 2007, 07: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.

What's HTML?
****
Gender: Male
Posts: 408
2466 credits
Members referred : 2



« Reply #5 on: Jun 09, 2007, 05: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 : Offline Promotion Of Your Website
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jun 09, 2007, 06: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

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....

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?
May 28, 2012, 07:49:20 pm





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!






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