arbitrary input from stdin to shell
        Posted  
        
            by 
                python_noob
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by python_noob
        
        
        
        Published on 2012-07-04T21:14:13Z
        Indexed on 
            2012/07/04
            21:15 UTC
        
        
        Read the original article
        Hit count: 256
        
So I have this existing command that accepts a single argument, but I need something that accepts the argument over stdin instead.
A shell script wrapper like the following works, but as I will be allowing untrusted users to pass arbitrary strings on stdin, I'm wondering if there's potential for someone to execute arbitary commands on the shell.
#!/bin/sh
$CMD "`cat`"
Obviously if $CMD has a vulnerability in the way it processes the argument there's nothing I can do, so I'm concerned stuff like this:
- Somehow allow the user to escape the double quotes and pass input into argument #2 of $CMD
- Somehow cause another arbitary command to run
© Stack Overflow or respective owner