Hello

I would like to mention 2 potential security risks:

  1. The substitution in the following segment is dangerous. It causes malformed Subject headers (feed it "Subject: .*"). While I did not manage to get it to take "Subject: (?{print "Hello"})", there may be a way around it to cause potential security hole.
    if( /^Subject: (.+)$/ ) { $original_subject = $1; if( $modify_subject ) { print LOG "Subject modified\n" if( $log ); s/$1/[friends]: $original_subject/; } }

    Consider using:

    s/Subject: /Subject: [friends]: /;
  2. The pipes you open at the end of the script. You're feeding $sender to the shell.
    open( MAIL, "|$sendmail -f $myaddress $sender" );
    While I know sender is matched at the beginning with
    /^From ([-a-zA-Z0-9_.@]+) .+$/
    there are better ways to do this. One of them is using the sender in the From header before printing the message.

Hope this helps...

Aziz,,,

P.S. I suggest removing all the s/f.../f***/ stuff and replacing it with a hash of words=>substitues.


In reply to Re: securing code by abstracts
in thread securing code by marcs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.