Controlling stdin and stdouts of other executables

Controlling stdin and stdouts of other executables

Post by Chip Salzenbe » Sat, 05 May 1990 01:02:30



[Unix-specific; followups to comp.unix.questions]


Quote:>system ("command > /dev/null 2>&1");

Beware system().  It calls /bin/sh to do its dirty work, which is one
reason it's so attractive to novice Unix programmers.  However, if
anything in the command line is non-constant, then system() usally is
a security hole.  Ignoring buffer size issues for the moment,
consider:

        sprintf(buf, "/usr/lib/sendmail -oem '%s' <%s", address, tempfile);
        system(buf);

Looks great, right?  But what if the address is "'; rm -rf $HOME; '"?
Bzzt!  You lose the security sweepstakes.  I hope you have backups...
--

 
 
 

Controlling stdin and stdouts of other executables

Post by Leslie Mikese » Sat, 12 May 1990 03:50:38



>Beware system().  It calls /bin/sh to do its dirty work, which is one
>reason it's so attractive to novice Unix programmers.  However, if
>anything in the command line is non-constant, then system() usally is
>a security hole.  Ignoring buffer size issues for the moment,
>consider:
>    sprintf(buf, "/usr/lib/sendmail -oem '%s' <%s", address, tempfile);
>    system(buf);
>Looks great, right?  But what if the address is "'; rm -rf $HOME; '"?
>Bzzt!  You lose the security sweepstakes.  I hope you have backups...

This brings up an interesting question:  How many unix mailers will consider
the ";`|<>" characters (and spaces) to be valid address characters and
thus present them to rmail or uux on a shell command line?

Les Mikesell


 
 
 

1. Controlling forked processes stdin/stdout

Is popen() the only way to interface with a forked processes stdin and stdout?
I'd like to be able for fork/exec a process, feed its stdin and capture its
stdout.  It looks to me like popen() will only let you do one or the other.
Thanks for the advice.

Mike Warren
HRB Systems
State College, PA

2. Slip/PPP login into host through terminal server

3. Remote shell(rsh): stdin and stdout control

4. Can't find sys/fault.h --- HEEEEELP !!!

5. Controlling stdin and reading stdout of an Xterm

6. TCPWrapper problem

7. sockets dup()ed to stdin and stdout of a process

8. Can't Burn CDR's On 2.4.19pre8

9. Using separate window child process for stdin/stdout

10. Set stdin/stdout in binary on UNIX

11. Redirecting stdout/stdin to socket

12. redirect terminal stdin/stdout

13. Temporary stdin/stdout redirection