Submit Your Article Forum Rules

Results 1 to 10 of 10

Thread: Potential http referrer issue

  1. #1

    Question Potential http referrer issue

    Hi All,

    I have a question for you programming/server gurus.

    My company's webhosting provider is blaming my php form script for knocking down their servers. They're saying our bandwidth increase overloaded the servers; which i find hard to believe or if it did I'm angry and surprised.

    I used the following script to block form spammers from using our form to send emails:

    <?php if ($_POST && $_SERVER['HTTP_REFERER'] == "http://www.domain.ca/thankyou.php") {



    Not the best preventative measure but it was a quick fix until we finish redesigning our new website.

    let me know what you think.

    Thanks,
    SR
    Digital Marketer / Ecommerce Lead / Entrepreneur

  2. #2
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    3,138

    Re: Potential http referrer issue

    Crude, but it should be somewhat effective. It is also important to make sure that the data submitted via the form is thoroughly validated before you execute the logic of the form. Otherwise an attacker could insert unexpected commands into the form that can cause issues with the server.
    The best way to learn anything, is to question everything.
    WigeDev - Freelance web and software development

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Posts
    327

    Re: Potential http referrer issue

    Your overall question is a bit vague. I'm not sure whether you added the script you mentioned after the bandwidth problems or before. In either case it is unlikely that the snippet you've shown had anything to do with a bandwidth problem.

    As for my thoughts:

    $_SERVER['HTTP_REFERER'] is a completely unreliable variable. IT is set by the user agent and can be modified. The specs suggest (and I strongly concur) that the variable cannot be trusted. There are better solutions to prevent your forms from being used for email spam.

    If you are properly validating your variables you can eliminate the fear of having your forms hijacked to send email.

    Use regular expressions to check for acceptable input including the type and number of characters you will allow.

    Watch for the insertion of newlines into your email variables. These can be used to add additional headers, cc: and bcc:. Use the nl2br() to eliminate newlines from being inserted into your email variables.

    If your regular expressions are sound you can pretty much eliminate additional issues. And, of course, add a script that cuts down on the possiblity of a remote automated process. Some use CAPTCHA, I prefer using randomly generated questions with sessions variables.

    If you've got additional details I would be happy to help.
    I use Country IP Blocks as added security for my networks and servers.

  4. #4

    Re: Potential http referrer issue

    Thanks for the quick response Wige.

    I know the [http Referer] technique is bit crude but it was a patch job. Currently we validate our forms using javascript and alerts, typically only properly validating phone numbers and emails. For all other columns we just check if at least one charatcer is present.

    I remember a discussion you had with Tech_Manager regarding proper hijack preventation techniques but the whole process discussed seemed so cumbersome.

    Anyways, I saved those post and will re-read them…




    …….. And speak of the devil, I just saw tech_manager flash a post on the screen!
    Digital Marketer / Ecommerce Lead / Entrepreneur

  5. #5
    Senior Member
    Join Date
    Jan 2008
    Posts
    327

    Re: Potential http referrer issue

    WARNING: Throw away your javascript validation. I repeat: WARNING: Throw away your javascript validation.

    Never trust javascript validation unless you are using it with an SSI on the backend. Feel free to run the form variables through javascript initially, but when it comes to processing the actual form you need to rely on a server side language such as PHP, ASP, etc.

    Client-side javascript can be turned off and is easily manipulated in other ways.
    I use Country IP Blocks as added security for my networks and servers.

  6. #6

    Re: Potential http referrer issue

    Hi Tech Manager,

    Thanks for the quick response, your guru guidence is always appreciated. I'm glad you agree that it is highly unlikely that the HTTP_Referer snippet is the cause of the server chaos. It was most likely an untalented tech guy looking for someone to blame.

    I do understand your strong suggestion of properly validating form data. I admit I took the lazy approach. I don't like captchas so i will implement proper validation and also include your new-line prevention variable(good idea, thanks!).

    Thanks again guys for your excellent responses and i'll let you know how it goes.

    -Scott
    Digital Marketer / Ecommerce Lead / Entrepreneur

  7. #7

    Re: Potential http referrer issue

    "WARNING: Throw away your javascript validation. I repeat: WARNING: Throw away your javascript validation."

    No way man!!! Javascript forever!

    lol...
    Digital Marketer / Ecommerce Lead / Entrepreneur

  8. #8

    Re: Potential http referrer issue

    javascript just pops right up on the screen for you!
    Digital Marketer / Ecommerce Lead / Entrepreneur

  9. #9
    Senior Member
    Join Date
    Jan 2008
    Posts
    327

    Re: Potential http referrer issue

    Quote Originally Posted by imsickofwebpro View Post
    javascript just pops right up on the screen for you!
    Yes it does. And that's what makes it so convenient to hack.
    I use Country IP Blocks as added security for my networks and servers.

  10. #10
    Senior Member
    Join Date
    Jan 2008
    Posts
    327

    Re: Potential http referrer issue

    Incidentally, if you were relying solely on javascript to validate your form data it is entirely possible that your site contributed to a major increase in bandwidth. An improperly protected for makes it very easy to hijack your webform and use it to send extremely high volumes of email.
    I use Country IP Blocks as added security for my networks and servers.

Similar Threads

  1. Stumped about an issue with http://www.servprokzoo.com vs http://servprokzoo.com
    By AuctionHugh in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 11-03-2009, 08:49 AM
  2. http and https issue
    By vinay11111 in forum Search Engine Optimization Forum
    Replies: 5
    Last Post: 10-27-2007, 02:39 PM
  3. Help with potential duplicate content issue...
    By stretch dog in forum Google Discussion Forum
    Replies: 5
    Last Post: 05-29-2006, 03:25 PM
  4. Referrer Spam What is it?
    By node-net in forum Internet Security Discussion Forum
    Replies: 1
    Last Post: 05-18-2005, 12:59 AM
  5. hidden referrer
    By shilmy in forum Affiliate Marketing Discussion Forum
    Replies: 1
    Last Post: 01-10-2005, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •