The documentation of capurex, states that the function never invokes the shell.
My assumption:
Since no shell is invoked, characters like * or ; will not get interpreted and therefore can't do harm.
This is why calls to external programs are not (or less) susceptible to accidentally malformed input or intended injection attacks as shown in the example below (sorry for the German output messages):
use v5.26;
use IPC::System::Simple 'capturex';
# (very) vulnerable to shell injection
say `ls @ARGV`;
# just a visual line
say '----------';
# no shell injection "possible" (?)
say capturex('ls', @ARGV);
The output:
user@host:-$ perl shell-injection.pl -1 \*.pl \; hostname
shell-injection.pl
host
----------
ls: Zugriff auf '*.pl' nicht möglich: Datei oder Verzeichnis nicht gefunden
ls: Zugriff auf ';' nicht möglich: Datei oder Verzeichnis nicht gefunden
ls: Zugriff auf 'hostname' nicht möglich: Datei oder Verzeichnis nicht gefunden
"ls" unexpectedly returned exit value 2 at shell-injection.pl line 11.
user@host:-$
My Questions:
What terminologies can be used to describe, how the code is executed with
capturex? What are examples / techniques / terms used in other languages or environments? (e.g.system call?)Is it actually advisable to use this technique without input checking (I assume not) and if not, for what reason (attack vector)?