What are the potential security risks associated with using exec() or passthru() functions in PHP?

Using exec() or passthru() functions in PHP can pose security risks such as command injection attacks if user input is not properly sanitized. To mitigate this risk, always validate and sanitize user input before passing it to these functions to prevent malicious commands from being executed.

// Sanitize user input before passing it to exec() or passthru()
$user_input = $_POST['user_input'];
$sanitized_input = escapeshellarg($user_input);

// Execute the command safely
exec("your_command_here " . $sanitized_input);