Re: Can System() of Perl be bypassed?

From: Brian Hatch (secprog@ifokr.org)
Date: 01/23/03

  • Next message: Gustaf Bjorksten: "RE: Standards for developing secure software"
    Date: Thu, 23 Jan 2003 14:15:43 -0800
    From: Brian Hatch <secprog@ifokr.org>
    To: Sandeep Giri <sandeepgiri@indiatimes.com>
    
    
    

    > Taking chapter from replies,now I've changed my code to:
    >
    > #!/usr/bin/perl -T -W
    > my $key_words;
    > my $help;
    > GetOptions('kw=s' => \$key_words,
    > 'help' => \$help) || usage();
    > my @args = ($Keywords,....);
    > my @cmd = ("$JAVA",
    > "-search.home=$SEARCH_HOME",
    > "Searcher",
    > @args);
    > system(@cmd) == 0) ||error();
    >
    > Need I be more paranoid than this and use my own regex to filter out
    > keywords my self?

    Well, since that's pseudo code and not complete, I can't
    be sure what you're saying. "...." is not valid perl.

    What you have above would safely make sure that the user
    input is not processed by the shell.

    However I have no idea if those values could be used to
    break the program itself ($JAVA). If this program were
    running with greater privs (suid, CGI, etc) then they can
    supply a new $SEARCH_HOME path then they could cause their
    own code to run. If there are bad keywords then you aren't
    doing anything to get rid of them. (Or, preferably, only
    allowing good keywords.)

    Without knowing what you're actually running, I can't
    say it's secure. But you do successfully keep the
    shell from interpreting the user input, and that's a
    good step.

    --
    Brian Hatch                  "Ugly and old, yes? Then
       Systems and                their families must be
       Security Engineer          both rich and powerful."
    http://www.ifokr.org/bri/
    Every message PGP signed
    
    




    Relevant Pages

    • Re: one simple criteria input box - google style
      ... Whichever way I wind up going I> will have a seperate function to parse the user input in a way similar to> google/yahoo. ... User will type in multiple keywords seperated with spaces. ... > MainID ... > parsedKW1 and parsedKW2 being obtained from the users input from the one> input box. ...
      (microsoft.public.access.queries)
    • Re: Readability of Delphi
      ... Nick Hodges (Borland/DevCo) wrote: ... similar to the other keywords and the source code. ... Example in pseudo code: ...
      (borland.public.delphi.non-technical)

  • Quantcast