in reply to Re: cgi redirect
in thread cgi redirect

I'm the only one to use this web page, that is not accessible from the internet. But yeah you're right otherwise, I'd have protected it.

Replies are listed 'Best First'.
Re^3: cgi redirect
by Anonymous Monk on Oct 01, 2014 at 01:34 UTC

    This is how security holes get born... maybe someday you'll open the script up for others to use, or you'll be working on something for a client and remember that time you wrote this script, and just copy it over since that's the easiest solution, or ...

    Better to protect it from the start. And it's not hard to do, at least throwing this in as the first line of the foreach already helps against some of the bad stuff: tr{a-zA-Z0-9_/-}{}cd (still doesn't protect against symlinks into other directories, and if you add the dot to that list, it won't protect against "..", etc.)

Re^3: cgi redirect
by Anonymous Monk on Oct 01, 2014 at 21:08 UTC
    Capture::Tiny
    use Capture::Tiny qw/ capture /; my($stdout, $stderr, $exit) = capture { system( 'rm', '-rf', @paths ); };