Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: PerlTaintCheck and configuration for secure paths

by shmem (Chancellor)
on Jun 22, 2006 at 17:37 UTC ( [id://556959]=note: print w/replies, xml ) Need Help??


in reply to PerlTaintCheck and configuration for secure paths

It's not $PATH, but the variable. $PATH is only relevant for executables (used with system, backticks or piped open).

Did you sanitize $thumbName? see perlsec, section Laundering and Detecting Tainted Data.

Try something like

$thumbName = ($thumbName =~ /^([-\@\w.\/]+)$/) ? $1 : undef; if($thumbName) { open( NEWIMG, "+>$thumbName" ) or croak "Can't open new imagefile: + ($thumbName) $! \n"; }
That should do.
_($_=" "x(1<<5)."?\n".q/)Oo.  G\        /
                              /\_/(q    /
----------------------------  \__(m.====.(_("always off the crowd"))."
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: PerlTaintCheck and configuration for secure paths
by geektron (Curate) on Jun 22, 2006 at 17:44 UTC
    $thumbName is constructed in the code. because of that, i thought it didn't need extra sanitizing.

    I'll test it w/ Scalar::Util to ensure that's the tainted part ...

      If $thumbName was constructed with whatsoever variable that is tainted and not sanitized, it becomes tainted as well.

      In perlsec is a snippet of code:

      sub is_tainted { return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 }; }
      --shmem
      _($_=" "x(1<<5)."?\n".q/)Oo.  G\        /
                                    /\_/(q    /
      ----------------------------  \__(m.====.(_("always off the crowd"))."
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        the operative phrasing i missed: *not sanitized* ... after re-reading perlsec for the 3231244^34 time today, the "not sanitized" part kicked in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://556959]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found