system('openssl req -config /prod/prod-config.cnf -subj "/CN={$DOMAIN}" ....'
And whoever wrote that function assumed someone else had sanitized DOMAIN.It looks like a lot more understandable of a mistake when framed like that.
system('openssl req -config /prod/prod-config.cnf -subj "/CN={$DOMAIN}" ....'
And whoever wrote that function assumed someone else had sanitized DOMAIN.It looks like a lot more understandable of a mistake when framed like that.
PHP's system() manpage: http://php.net/manual/en/function.system.php
[red box]
Warning
When allowing user-supplied data to be passed to this function, use escapeshellarg() or escapeshellcmd() to ensure that users cannot trick the system into executing arbitrary commands.
system(3): http://man7.org/linux/man-pages/man3/system.3.html Any user input that is employed as part of command should be carefully sanitized, to ensure that unexpected shell commands or command options are not executed. Such risks are especially grave when using system() from a privileged program.
This is a canonical mistake that's used as a mistake example in textbooks.system() style functionality -> should be the hard thing to do execv() style functionality() -> should be the easy thing to do
Shower thought: Allow me to globally disable system() in for language x. Aside from the obvious case of just banning these insane system calls, you're protected against surprise vectors in parsers.
Edit: You would presumably mitigate pipe open vulnerabilities too
It's just sad that there is no really good tutorial how to write your own SELinux modules for your own applications. It's easier than it seems and allows some really powerful security measures.