Zum Inhalt springen

OS command injection (ARCH316)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key dotnet.security.os-command-injection · Severity error · Category security · CWE CWE-78

Concatenating user input into a shell command line lets an attacker inject extra commands. Pass arguments separately without a shell.

Process.Start("cmd.exe", "/c ping " + userHost);
var psi = new ProcessStartInfo("ping") { UseShellExecute = false };
psi.ArgumentList.Add(userHost);
Process.Start(psi);

Pass arguments via ArgumentList, set UseShellExecute = false, and never concatenate input into a shell command string.