Skip to content
Advertisement

Using $_GET in system() function – security question

So let’s say we have a following code:

JavaScript

Is it secure? Can I escape from double quotes somehow? The operating system in linux.

Purely theoretical consideration. I don’t use it in my code 😉

Advertisement

Answer

It’s not secure. You can still pass some arguments that will be malicious, i.e. execute other files in system.

JavaScript

You should use escapeshellarg method for escaping shell arguments.

JavaScript

Note that you have to use the argument $str as it is and that it will be a single argument. You must not surround it with quotes ' or double quotes "

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement