exec per se does not pose a security risk than you enter a secure terminal.
Think of it this way if you were to specify the contents of a directory like this
exec( 'ls /foo/bar' );
no matter what your user sent to your php script, he would only list the specified directory.
While you carefully clean any input from the user and refrain from displaying confidential information, you should be in order.
Use the following methods to sanitize input before running it on the command line: