Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: untainting system calls correctly

by dws (Chancellor)
on Apr 10, 2002 at 16:37 UTC ( [id://158065]=note: print w/replies, xml ) Need Help??


in reply to Untainting system calls correctly

I'm curious. First, you identify that the single argument form of system() is a potential problem, but then you proceed on to use it. If you're going to use   system("/usr/sbin/useradd $cli"); then you need to prevent $cli from having as it's trailing substring something day-ruining like   "... ; /bin/rm -rf *" You don't have this problem with the multiple argument form, since you're bypassing the shell entirely. Here's a simple reworking:
my $username = ... untaint $formdata{'username'}; ... etc. for other form variables my @cli = ("-s", $shell, "-d", $home, "-G", $group $usrname); ... system("/usr/sbin/useradd", @cli);

Edit: s/training/trailing/

Replies are listed 'Best First'.
Re: Re: untainting system calls correctly
by Fletch (Bishop) on Apr 10, 2002 at 16:43 UTC

    Not to meniton preventing someone from slipping in a username of `-u 0 I0wNj00'.

    Update: As a clarification, I mean that by using the multiple arugment form rather than letting the shell split you prevent the user from submitting extra arguments (in the example I gave they could specify that their new account would get a uid of 0).

Re: Re: untainting system calls correctly
by c (Hermit) on Apr 10, 2002 at 17:24 UTC
    Sorry if I am just missing the nomenclature you're using, but what do you mean by "training substring"?

    thanks! -c

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://158065]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-25 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found