Matthew Dalton wrote:

> > system("graph -L 'Mono-molecular Reaction' -X Time -Y
> > 'Concentration' /tmp/data >| /tmp/temp.meta");
> > system("plot -T gif /tmp/temp.meta >| /tmp/order1.gif");
> 
> Is there a security risk with a call such as this?
> You're not supposed to put system calls in cgi for security reasons, but
> does that rule include situations such as this where the command is
> constant?

You are not supposed to call a script or program
with parameters that originate from an external source
such as form variables from an HTML form on the web.

Why?

Because this:
   system("cat $parameter")
becomes this:
   system("cat /etc/passwd; rm -rf /tmp/*")
when a savvy user types "/etc/passwd; rm -rf /tmp/*"
into the text box that winds up in your $parameter variable.

Perl has a TAINT (-T) option to disallow such calls unless you
inspect and 'fix' $parameter to be safe from such exploits.


...................................


Michael Lake wrote:

> I am doing this:

i.e. you have writtten:

(1) script that displays a form to return a GIF image
    from a temp directory, generated on the fly

re-write this as follows:

(1) script that displays a page that contains an image
    tag direct to the CGI:

    <h1>Kinetics Image</h1>
    <img src="http://whatever/cgi-bin/genimage?a=123456789">

     Note: try to keep make "123456789" a different number
     each time you generate this page -- should stop caching effects

(2) script that generates a kinetics image on the fly,
    returning a GIF header, called genimage

    system("graph -L 'Mono-molecular Reaction' -X Time -Y
     'Concentration' /tmp/data >| /tmp/temp.meta");
    system("plot -T gif /tmp/temp.meta >| /tmp/order1.gif");

    :
    :
    # generate header and content

    my $size = -s "/tmp/order1.gif";

    print $q->header(-type=>'image/gif',
                  -content-length=>$size,
                  -expires=>'+30s',
                  -pragma=>'no-cache',
                  -cache-control=>'no-cache');

    open(GIF,"/tmp/order1.gif") || die;
    print join "",<GIF>;
    close GIF;



I haven't tested this code. You may have to make modifications
to get it to work properly and, as always, YMMV.


--
Rick Welykochy || Praxis Services Pty Limited

--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to