Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Time and time again, we hear Monks admonish others that they should use strict;. Well, here's a great example why.

Routinely, I see in people's code use strict; with no strict 'refs'; later in the code. Typically, when I see this, my mind screams "Danger, Will Robinson, Danger!" (which is rather odd as my given name is actually "Curtis"). Consider the following code that I ran across today:

if ($main::stateIn{'sibling'}) { no strict 'refs'; &{$main::stateIn{'sibling'}}(); }
First, the $main::stateIn{} hash is fully qualified because the developer apparently didn't know the difference between package and lexical variables. Second, $main::stateIn{} is how he gets the CGI parameters. Yup, you guessed it! He wrote a broken alternative to CGI.pm. See this link for an explanation why most alternatives to CGI.pm are flawed. In this case, the developer's alternative had all of the classic errors detailed in the aforementioned link. However, what we're really interested in is the following line:
&{$main::stateIn{'sibling'}}();
Since the developer had no strict 'refs'; before this, and since the developer also didn't bother to employ taint checking, that snippet above will allow a cracker to execute any frickin' subroutine they want so long as the main program can call it. The program in question uses many different modules which, in turn, use other modules. There are literally hundreds of different subs that could be called, with unknown consequences. Admittedly, you can't pass any params to those subs, but that's one HECK of a security hole.

Just use strict; folks.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.


In reply to Why We Use Strict! by Ovid

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (5)
    As of 2014-11-22 21:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (125 votes), past polls