Posted on 2007-02-15 03:55:51-08 by tonyb48
Insecure dependency in unlink while running with -T switch
I am little more than a novice and convinced my host to install Authen::Captcha so I could prevent automated sign-ins on a site I am designing for high school alumni. When I add the following code to my script I got the error in the Subject line.
my $md5sum = $captcha->generate_code($number_of_characters);
Prior to this statement I have the following, and the script does not break (although it does not do anything yet)
use Authen::Captcha; my $captcha = Authen::Captcha->new(); $captcha->data_folder ('/home/httpd/vhosts/orhsfoundation.com/cgi-bin/alumni/captcha'); $captcha->output_folder ('/home/httpd/vhosts/orhsfoundation.com/httpdocs/alumni/images/captcha'); my $number_of_characters = 5;
I also found "codes.txt" in the data_folder and some .png files in the output_folder, so something is working. Any clues you can provide me? Thanks Tony Barre
Direct Responses: 9004 | Write a response
Posted on 2008-10-09 02:54:28-07 by chrisrd in response to 4350
Re: Insecure dependency in unlink while running with -T switch
The patch below fixes the problem. You'll need to be careful about whitespace mangling if cut-and-pasting this from the web page, but unfortunately you can't attach to this forum.

I've tried contacting the nominated author of this module (Josh Miller) about this, but no response (hey, I just realised that was a year minus 10 days ago!). Cheers, Chris
--- Authen-Captcha-1.023/Captcha.pm.orig 2003-12-18 15:44:34.000000000 +1100 +++ Authen-Captcha-1.023/Captcha.pm 2007-10-19 18:27:34.000000000 +1000 @@ -232,7 +232,11 @@ foreach my $line (@data) { $line =~ s/\n//; - my ($data_time,$data_code) = split(/::/,$line); + + # + # Extract untainted time and code + # + my ($data_time,$data_code) = $line =~ m/(^\d+)::([[:xdigit:]]{32})$/; my $png_file = File::Spec->catfile($self->output_folder(),$data_code . ".png"); if ($data_code eq $crypt) @@ -351,7 +355,12 @@ foreach my $line (@data) { $line =~ s/\n//; - my ($data_time,$data_code) = split(/::/,$line); + + # + # Extract untainted time and code + # + my ($data_time,$data_code) = $line =~ m/(^\d+)::([[:xdigit:]]{32})$/; + if ( (($current_time - $data_time) > ($self->expire())) || ($data_code eq $md5) ) { # remove expired captcha, or a dup
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.