<?xml version="1.0" encoding="windows-1252"?>
<node id="499286" title="securing a remailer" created="2005-10-11 17:17:11" updated="2005-10-11 13:17:11">
<type id="115">
perlquestion</type>
<author id="9463">
geektron</author>
<data>
<field name="doctext">
One of our ancient remailer scripts has finally been compromised.  Someone discovered that it uses an ancient method to pass infomation to sendmail: a pipe directly to sendmail - the worst way to send email from a script.
&lt;p&gt;
I'm rewriting the thing with an extra eye for security and configurability (so that I can reuse it across our sites, if/when needed), and I want to make sure I've covered all the bases since the PHB keeps throwing "what if ...." scenarios at me.
&lt;p&gt;
I've already come up with the following to secure this thing:
&lt;ul&gt;
&lt;li&gt; using the -T switch (which isn't in the original) &lt;/li&gt;
&lt;li&gt; using [cpan://MIME::Lite] to create the message rather than just &lt;code&gt; print&lt;/code&gt;ing to sendmail&lt;/li&gt;
&lt;li&gt; using [cpan://Mail::Address] or something similar to validate the "To:" field in the messages.  i'll probably also make sure that only *one* value is in the "To:" field&lt;/li&gt;
&lt;li&gt; (not security related) using [cpan://Config::General] to allow for config file creation with an eye for deploying the remailer across sites.
&lt;/ul&gt;
I know that checking for &lt;code&gt; $ENV{HTTP_REFERER} &lt;/code&gt; isn't a great option, because that can be spoofed.  (the person(s) exploiting this hole in the existing remailer have already spoofed IPs to allow for more hits to the script.
&lt;p&gt;
Does adding some form of key/ session_id buy any security? I think not, because it would be just another thing that needs to be passed in the form, and enough brute-force attacks would crack that too ... 
&lt;p&gt;
Any other suggestions for making this thing as locked down as possible?</field>
</data>
</node>
