No problem, here's the code generating $shellstring:

$shellstring = '-v -in src_alignment.fasta '; foreach my $key (keys(%{$param})) { CASE: { if ($key eq 'groups') { $shellstring .= '-groups "'.$param- +>{'groups'}.'" '; last CASE; } if ($key eq 'ngra') { $shellstring .= '-ngra '; + last CASE; } if ($key eq 'gh') { $shellstring .= '-gh '.$param->{'gh +'}.' '; last CASE; } if ($key eq 'sa') { unless ($param->{'ca'}) { $shellstring .= '-sa '; } # '-ca' o +verrides '-sa' last CASE; } if ($key eq 'ca') { $shellstring .= '-ca '; + last CASE; } if ($key eq 'cg') { $shellstring .= '-cg '; + last CASE; } } }

'src_alignment.fasta' is a file from upload or FORM data from a user, which will be mangled by the external script. '$param->{'groups'}' and '$param->{'gh'}' is tested in another subroutine for validity:

if ($key eq 'groups') { if ($param->{$key} =~ m/[^0-9\,\-\|]/) { # check for illegal charac +ters in group-definition print "\n>>> Illegal characters in groups-definition '".$param-> +{$key}."'! Only 0-9 and , and - and | are allowed!\n"; $error = 1; } last CASE; } if ($key eq 'gh') { if ($param->{$key} =~ m/[^0-9]/) { print "\n>>> Illegal characters in graph-height '".$param->{$key +}."'! Only 0-9 are allowed!\n"; $error = 1; } last CASE; }

If '$error' is found to be 1, the CGI-script exits and prints error messages. As I can see now from the anwers I got here my variables ('groups' and 'gh' especially) are not untainted "enough" or at all...just checking for validity is not enough here as far as I can see.

Thanks a lot for your help!


In reply to Re: Re: How to call external scripts from a CGI-script in taint mode? by professa
in thread How to call external scripts from a CGI-script in taint mode? by professa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.