[advanced search]
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 05-11-2008, 11:32 AM   · #1
pchip
NamePros Member
 
pchip's Avatar
 
Trader Rating: (3)
Join Date: Feb 2007
Posts: 100
NP$: 0.00 (Donate)
pchip is an unknown quantity at this point
PHP mail function - Header security?

Hey everyone,

I'm messing around with the php mail function and I noticed that when you look at the properties of the message that was sent there are headers with a ton of information. Some of this information shows my cpanel login and server info. I use Hostgator hosting.

Should I be concerned with this or is this pretty normal? I've been doing some research on using something else to send e-mails but I don't yet understand these of if they are neccessary.

As always, thanks for the help!

pc


Please register or log-in into NamePros to hide ads
pchip is offline   Reply With Quote
Old 05-11-2008, 01:24 PM   · #2
mholt
DNOA Member
 
Name: Matthew Holt
Location: 127.0.0.1
Trader Rating: (75)
Join Date: May 2004
Posts: 4,850
NP$: 17.21 (Donate)
mholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud ofmholt has much to be proud of
Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
__________________
FREE: Help With Code

Includes other technical topics:
programming, development, Windows, domain names, and Internet
mholt is offline   Reply With Quote
Old 05-11-2008, 05:01 PM   · #3
pchip
NamePros Member
 
pchip's Avatar
 
Trader Rating: (3)
Join Date: Feb 2007
Posts: 100
NP$: 0.00 (Donate)
pchip is an unknown quantity at this point
I've tried messing around with changing the headers previously but the information is still there - mostly in the 'Received' portions of the message. Maybe i'm missing something but here's what i've been playing with so far...

$to = 'whoever@xyznet';
$subject = 'the subject';
$message = 'test';
$headers = 'From: contact@xyznet' .
'Received: contact@xyznet' .
'Reply-To: contact@xyznet' . "\r\n";

mail($to, $subject, $message, $headers, "-fcontact@xyznet");

What do you think?

Thanks!

pc
pchip is offline   Reply With Quote
Old 05-11-2008, 05:52 PM   · #4
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 


Name: Eric
Location: Kentucky
Trader Rating: (137)
Join Date: Mar 2005
Posts: 4,118
NP$: 261.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
No matter what you use - depending on the server - different kinds of information are added by default, and you can't change those values. "Received by...", ip address, etc. Most hosts will also add a patch to PHP to where it includes the script that sends the email.
__________________
SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.1 now available!!
MetaCreator.com - Free Meta Tag Creator
SecondVersion is offline   Reply With Quote
Old 05-11-2008, 07:20 PM   · #5
pchip
NamePros Member
 
pchip's Avatar
 
Trader Rating: (3)
Join Date: Feb 2007
Posts: 100
NP$: 0.00 (Donate)
pchip is an unknown quantity at this point
Originally Posted by SecondVersion
No matter what you use - depending on the server - different kinds of information are added by default, and you can't change those values. "Received by...", ip address, etc. Most hosts will also add a patch to PHP to where it includes the script that sends the email.



I'm not following the last part of this. A host can add a patch to PHP to where it will include the script that sent the e-mail. Does this mean that the script code is somewhere that people can see? I must be overlooking something as this doesn't make sense.

Thanks again for the help!

pc
pchip is offline   Reply With Quote
Old 05-11-2008, 08:50 PM   · #6
maximum
NamePros Regular
 
maximum's Avatar
 
Name: -Unknown-
Location: Inside your head...
Trader Rating: (11)
Join Date: Oct 2005
Posts: 755
NP$: 3316.20 (Donate)
maximum has much to be proud ofmaximum has much to be proud ofmaximum has much to be proud ofmaximum has much to be proud ofmaximum has much to be proud ofmaximum has much to be proud ofmaximum has much to be proud ofmaximum has much to be proud of
Originally Posted by pchip
I'm not following the last part of this. A host can add a patch to PHP to where it will include the script that sent the e-mail. Does this mean that the script code is somewhere that people can see? I must be overlooking something as this doesn't make sense.
pc

I assume you mean you don't get this >>
Originally Posted by SecondVersion
Most hosts will also add a patch to PHP to where it includes the script that sends the email.

What SV is saying is that to help host know where your PHP file is if you are sending out spam (ie: by reading this line, if someone forwards email to host reporting it as spam), they set it to include the following header for example:

X-PHP-Script: www.yourdomain.com/yourfolder/emailer.php for 209.255.255.255

*** Above is domain...some server admins set it up to show path instead:

/home/username/yourfolder/emailer.php

That would tell them that the script that sent the email was at www.yourdomain.com/yourfolder/emailer.php and that it was sent using a browser with IP# 209.255.255.255 , for example. That way host knows what script to go investigate. THIS is good on the server-end, as helps catch spammers. The BAD part is that it tells anyone who gets the email what URL they can go to abuse the script themselves - SO, password protect scripts or directories that send email, or make them part of coding whereby just visiting the URL itself with known variables attached doesn't just send-out emails!
__________________
The smartest and best among men say very little, make sure that what they say is important, then they sit down and shut up.

Last edited by maximum : 05-12-2008 at 02:23 AM.
maximum is online now  
  Reply With Quote
Old 05-11-2008, 09:16 PM   · #7
pchip
NamePros Member
 
pchip's Avatar
 
Trader Rating: (3)
Join Date: Feb 2007
Posts: 100
NP$: 0.00 (Donate)
pchip is an unknown quantity at this point
Thanks for the explanation Maximum, I figured that's what SecondVision was saying but just wanted to make sure!

Thanks again for the help, both of you repd!

pc
pchip is offline   Reply With Quote
Old 05-14-2008, 02:22 AM   · #8
labrocca
The Spoon
 
labrocca's Avatar
 
Name: Jesse Labrocca
Location: Las Vegas
Trader Rating: (93)
Join Date: Aug 2004
Posts: 4,534
NP$: 1824.04 (Donate)
labrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond reputelabrocca has a reputation beyond repute
Child Abuse Child Abuse
Your above script is open to mail header injection which can be used for spamming.

Make sure to sanitize the variables BEFORE they hit the mail() function.
labrocca is offline   Reply With Quote
Old 05-15-2008, 02:08 AM   · #9
qbert220
NamePros Member
 
Location: UK
Trader Rating: (19)
Join Date: Jul 2007
Posts: 106
NP$: 205.00 (Donate)
qbert220 is a jewel in the roughqbert220 is a jewel in the roughqbert220 is a jewel in the rough
Originally Posted by pchip
$headers = 'From: contact@xyznet' .
'Received: contact@xyznet' .
'Reply-To: contact@xyznet' . "\r\n";



You need "\r\n" after each header line, so it should look like:

Code:
$headers = 'From: contact@xyznet' . "\r\n" . 'Received: contact@xyznet' . "\r\n" . 'Reply-To: contact@xyznet' . "\r\n";


Be very very careful if you are allowing any user input (GET, POST, COOKIE etc) to affect the arguments to your mail function call. Obviously allow a user to set the "to:" field would be bad. A common spammer trick is to put "\r\n" into a "subject:" or "from:" field. The mailer then takes the part after the "\r\n" as a new header (which could be a "to:" , "cc:" or "bcc:" header) and can be used to abuse the form. Many (most?) hosts will protect against this type of attack now, but there is a chance that yours (or someone elses if you give the script to them) will not.
qbert220 is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Build your NameBrand http://www.mobisitetrader.com/ Build your NameBrand
Advertise your business at NamePros
All times are GMT -7. The time now is 04:53 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0