Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
SQL
Hi,
My project is running on a apache server on CentOs.My project is one-page site that contains a form that send mail when submitted.I write that form mail script in perl cgi.It is able to send mail when submitted but I want to restrict the direct url access to that mail script.How should I do,please?
Posted
Comments
Sergey Alexandrovich Kryukov 23-Oct-15 16:16pm    
You can check up the HTTP referral.
—SA
Member 12081297 23-Oct-15 23:52pm    
Sir Sergey Alexandrovich Kryukov,Thank you very much.
Sergey Alexandrovich Kryukov 24-Oct-15 2:03am    
You are welcome. I also added more useful information and considerations in Solution 1, please see.
Will you now accept the answer formally?
—SA
Member 12081297 26-Oct-15 1:14am    
Of course,sir.

1 solution

As a first line of defense, you can check up the HTTP referral, which is one of the HTTP header fields of an HTTP request:
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields[^],
https://en.wikipedia.org/wiki/HTTP_referer[^].

All scripting modules for all non-nonsense HTTP servers allows you to check up this fields. If the referrer is not what's expected for your mail script, you script should not handle this HTTP request with normal processing including sending the mail.

On Perl, see also: http://www.perlmonks.org/?node_id=747530[^].

Note that this is not 100% reliable defense, because the HTTP request can be spoofed. That's why I called it "first line of defense".

Now, this is, by far, not the only security concern of the mail script, which is potentially quite a dangerous part of Web sites. I discovered amazingly simple let efficient exploit (from real-life experience) which could turn your Web host into a zombie spreading spam in no time. I described it, as well as the protection, in my past answer:
unable to send mail , it showing the error in below code .[^];
see also: In what way $('#myelement').valid(); works[^].

Good luck. Be safe.

—SA
 
Share this answer
 
Comments
Member 12081297 26-Oct-15 1:15am    
Sir Sergey Alexandrovich Kryukov,thanks a lot.
Sergey Alexandrovich Kryukov 26-Oct-15 1:52am    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900