What are the potential issues with using exec() in PHP to start external programs?

One potential issue with using exec() in PHP to start external programs is the risk of command injection vulnerabilities if user input is not properly sanitized. To mitigate this risk, it is important to validate and sanitize any user input before passing it to the exec() function.

// Sanitize user input before passing it to exec()
$user_input = filter_var($_POST['input'], FILTER_SANITIZE_STRING);

// Execute the external program with sanitized input
exec("your_command_here $user_input");