RE: Can System() of Perl be bypassed?

From: NESTING, DAVID M (SBCSI) (dn3723@sbc.com)
Date: 01/22/03

  • Next message: Ilya Martynov: "Re: Can System() of Perl be bypassed?"
    From: "NESTING, DAVID M (SBCSI)" <dn3723@sbc.com>
    To: "'Sandeep Giri'" <sandeepgiri@indiatimes.com>, secprog@securityfocus.com
    Date: Wed, 22 Jan 2003 15:30:17 -0600
    
    

    Use the multiple-argument version of the system call, and ensure that the
    program you're calling won't misbehave if weird input is provided:

    system("/path/some-command", $user_data);

    Passing $user_data and the command name in a single string (the
    single-argument form of system()) causes the shell to parse and interpret
    the data, which means shell metacharacters in the user's data will be
    interpreted.

    Read through perlsec for this and other gotchas. Taint mode in Perl will
    help you avoid them, but don't rely exclusively on it. It will catch some
    stupid mistakes, but it isn't a cure for not knowing what you're doing.

    Good luck,

    David

    -----Original Message-----
    From: Sandeep Giri [mailto:sandeepgiri@indiatimes.com]
    Sent: Wednesday, 22 January, 2003 01:03
    To: secprog@securityfocus.com
    Subject: Can System() of Perl be bypassed?

    Hi All,
    In my PERL code,I am using user's input as command line argument for the
    program being executed by System().
    Can user run command of his choice by giving malicious input?
    Is PERL's -T (Taint mode) the solution for this?

    Thanks.

    Sandeep Giri



    Relevant Pages

    • Re: Wait for background processes to complete
      ... To be able to execute commands in the background and wait for their ... The documentation I am referring to is http://perldoc.perl.org/. ... You can run a command in the background with: ... There is a general problem with perl documentation: ...
      (comp.lang.perl.misc)
    • Re: Perl For Amateur Computer Programmers
      ... >professional computer programmers could use with the same ease as Basic. ... >Perl For Amateur Computer Programmers ... Also, taking into account that you're appealing to "scientists", it ... Also, as a side note, you seem to use the noun "command" in a naive ...
      (comp.lang.perl.misc)
    • Obtaining complete Unix command line that evoked script as string
      ... If there is a more appropriate list for this, let me know; the other perl lists I've seen seem to specialised for this. ... Note this is not just the arguments of the call to the script, but everything including pipes and redirects, etc., e.g. ... Ideally the perl interpreter would grab the complete command line as its evoked and I'd access this via a variable. ...
      (perl.beginners)
    • Re: CLOSING Re: Obtaining complete Unix command line that evoked script as string
      ... > To: Grant Jacobs; beginners perl ... > perl and less, much less passing that information along to either ... Only shell that launched them is keeping track of the I/O ... > command is executed. ...
      (perl.beginners)
    • Thanks for the comments Jan. 25, 2006
      ... "shadow" operating system which is running behind Windows. ... Perl can then collect data from that program and do ... that by sending longer strings etc. to the Windows clipboard and then having ... SendKeysuse a Ctrl V command to paste the information to the text editor ...
      (comp.lang.perl.misc)