Runtime.getRuntime (). Exec (String []) security

I am using Runtime.getRuntime (). exec (String []) to start processes in which some elements of the String array are user-defined.

Is it safe? Or will it allow you to enter the code into the terminal?

If this is unsafe, what can I do to avoid code injection? (it must be platform independent)

+3
source share
5 answers

As I mentioned in a comment on another answer (may also add my own answer), this should be safe if you control the first argument.

+3
source

This is generally unsafe, as shell scripts should be possible (which could be malicious).

, , ( , - ), .

+2

, . unix script , . , script , . ( ​​.)

+1

, -, . - exec. . , .

An example of a dangerous team is to find. The user can add the -exec parameter as an argument for arbitrary execution of the command.

+1
source

All Articles