What are the potential security risks of using exec, passthru, and system functions in PHP?

The potential security risks of using exec, passthru, and system functions in PHP include allowing for arbitrary command execution, which can lead to code injection attacks. To mitigate these risks, it is important to properly sanitize and validate user input before passing it to these functions.

$user_input = $_POST['input'];

// Sanitize and validate user input before using exec function
$validated_input = escapeshellarg($user_input);
exec("command " . $validated_input);