Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > rmtree and untaint

Reply
Thread Tools

rmtree and untaint

 
 
Flagstaff
Guest
Posts: n/a
 
      01-03-2004
I untaint input from a cgi form in the standard way:

if ($variable =~ /^([-_\w\s]+)$/) { $variable = $1 }
else { error_handling ("bad_data", $variable) }

but when I try to use the rmtree function in File:ath I get an error
that the variable is untainted. Can anyone give me insight here?

Thanks
 
Reply With Quote
 
 
 
 
Flagstaff
Guest
Posts: n/a
 
      01-04-2004
On Fri, 02 Jan 2004 22:01:07 -0500, Flagstaff <(E-Mail Removed)> wrote:

>I untaint input from a cgi form in the standard way:
>
> if ($variable =~ /^([-_\w\s]+)$/) { $variable = $1 }
> else { error_handling ("bad_data", $variable) }
>
>but when I try to use the rmtree function in File:ath I get an error
>that the variable is untainted. Can anyone give me insight here?
>
>Thanks


I also get the same error if I try to delete all files in a directory
.....something like:

unlink (./*);

so I think this is related.
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-04-2004
Flagstaff wrote:
> I untaint input from a cgi form in the standard way:
>
> if ($variable =~ /^([-_\w\s]+)$/) { $variable = $1 }
> else { error_handling ("bad_data", $variable) }
>
> but when I try to use the rmtree function in File:ath I get an
> error that the variable is untainted. Can anyone give me insight
> here?


rmtree() uses the readdir() function, whose output is tainted, and
since File:ath seems to not have any option to be run in taint mode,
you should probably try some other approach.

File::Find, that includes an 'untaint' option, might be useful.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
Martien Verbruggen
Guest
Posts: n/a
 
      01-04-2004
On Sun, 04 Jan 2004 00:09:47 -0500,
Flagstaff <(E-Mail Removed)> wrote:
> On Fri, 02 Jan 2004 22:01:07 -0500, Flagstaff <(E-Mail Removed)> wrote:
>
>>I untaint input from a cgi form in the standard way:
>>
>> if ($variable =~ /^([-_\w\s]+)$/) { $variable = $1 }
>> else { error_handling ("bad_data", $variable) }
>>
>>but when I try to use the rmtree function in File:ath I get an error
>>that the variable is untainted. Can anyone give me insight here?


You mean that the variable is tainted, as in an "Insecure dependency"
error? What is the exact error message, and what exactly is the code
that triggers it?

> I also get the same error if I try to delete all files in a directory


What is that error though?

> ....something like:
>
> unlink (./*);
>
> so I think this is related.


This is a syntax error.

unlink takes a list of file names to remove. Perl is not shell, so it
won't automatically replace glob patterns with file names. Even if you
quoted the above, so it wasn't a syntax error, and wrote:

unlink ("./*");

perl would try to unlink the file with the literal name ./*. You
probably need the glob operation or <>, but you should realise that
those operations return tainted data, and therefore need to be
untainted.

So, if you wrote

unlink <./*>;

you would get a message stating that there is an insecure dependency.

Have you checked whether the variable is tainted, as is suggested in the
perlsec documentation, and in perl FAQ 7?

You need to be much more precise and clear next time you report a
problem.

Martien
--
|
Martien Verbruggen | Blessed are the Fundamentalists, for they
| shall inhibit the earth.
|
 
Reply With Quote
 
Flagstaff
Guest
Posts: n/a
 
      01-05-2004
On Sun, 04 Jan 2004 07:58:37 +0100, Gunnar Hjalmarsson
<(E-Mail Removed)> wrote:

>Flagstaff wrote:
>> I untaint input from a cgi form in the standard way:
>>
>> if ($variable =~ /^([-_\w\s]+)$/) { $variable = $1 }
>> else { error_handling ("bad_data", $variable) }
>>
>> but when I try to use the rmtree function in File:ath I get an
>> error that the variable is untainted. Can anyone give me insight
>> here?

>
>rmtree() uses the readdir() function, whose output is tainted, and
>since File:ath seems to not have any option to be run in taint mode,
>you should probably try some other approach.
>
>File::Find, that includes an 'untaint' option, might be useful.


Hey thanks. Is good to know that it is not just some buggy thing in my
code!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: shutil.rmtree raises "OSError: [Errno 39] Directory not empty"exception Tim Chase Python 1 07-13-2009 12:03 AM
A faster shutil.rmtree or maybe a command. martijn@gamecreators.nl Python 2 10-11-2005 10:01 AM
using wildcards in rmtree or blog on windows Chuck Bradley Perl Misc 2 07-16-2004 04:23 AM
Full-featured untaint() method for Ruby? Randy Lawrence Ruby 8 06-22-2004 01:50 PM
1.8,frozen, and untaint Ara.T.Howard Ruby 1 09-25-2003 05:10 PM



Advertisments