]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/taint_issue_with_regular_expressions.mdwn
po: Fixed to run rcs_add ralative to srcdir.
[ikiwiki.git] / doc / bugs / taint_issue_with_regular_expressions.mdwn
1 Built from 2.1.17 source, works fine on commandline, but not working from CGI wrapper.  Traced problem to regular expressions failing to match, specifically in contexts like the following in Render.pm:
2
3     my ($f)=/$config{wiki_file_regexp}/; # untaint
4
5 It works if I replace it with:
6
7     my ($f)=/(^[-[:alnum:]_.:\/+]+$)/; # untaint
8
9 which is exactly the same regular expression drawn out as a constant.  It appears that %config gets some tainted data and is itself being marked entirely tainted, which may prevent using regular expressions contained in it for untainting other data.  I'm using Perl 5.8.8.
10
11 > How could `%config` possible get tainted? That would be a major security
12 > hole. It seems more likely that perl containes to have taint flag bugs
13 > even in 5.8. See also: [[prune_causing_taint_mode_failures]],
14 > [[Insecure_dependency_in_mkdir]],
15 > [[Insecure_dependency_in_eval_while_running_with_-T_switch]],
16 > and especially [[!debbug 411786]]
17 >
18 > The last of those was the last straw for me, and I disabled taint
19 > checking in the debian package. You can do the same by building ikiwiki
20 > with NOTAINT=1. :-( --[[Joey]]
21
22 ----------------
23 Continuing to dig into the problem I reported, it may not be taint after all.  Running strings on the ikiwiki.cgi wrapper, I see stuff like:
24
25     'wiki_file_regexp' => bless( do{\(my $o = undef)}, 'Regexp' )
26
27 without any payload of the actual regexp, and that would also certainly also have the observed effect of the regexps being completely broken while running in CGI mode.  This seems to implicate Data::Dumper (2.101).  After upgrading Data::Dumper to 2.121 I get:
28
29     'wiki_file_regexp' => qr/(?-xism:(^[-[:alnum:]_.:\/+]+$))/
30
31 This would call for at most an installation prerequisite of Data::Dumper >= 1.121.  A look at the module's changelog shows that no intervening versions were actually released, so 1.121 would be the minimal good one.
32
33 > You must have a very old version of perl there. This seems to be a bug in
34 > data dumper before 2.11, which didn't properly dump q// objects. Prereq
35 > added, [[done]] --[[Joey]]