Why this matters
If user input is used in OS command arguments, it can be manipulated to expand access or execute unintended commands. Ensure proper sanitization to prevent injection.
If user input is used in OS command arguments, it can be manipulated to expand access or execute unintended commands. Ensure proper sanitization to prevent injection.
If user input is used in OS command arguments, it can be manipulated to expand access or execute unintended commands. Ensure proper sanitization to prevent injection.
Side-by-side examples engineers can pattern-match during review.
public class ExampleController : Controller
{
public void Run(string args)
{
Process p = new Process();
p.StartInfo.FileName = "/usr/bin/find";
p.StartInfo.Arguments = "/some/folder -ititle " + args;
p.Start();
}
}public class ExampleController : Controller
{
public void Run(string args)
{
Process p = new Process();
p.StartInfo.FileName = "/usr/bin/find";
p.StartInfo.ArgumentList.Add("/some/folder");
p.StartInfo.ArgumentList.Add("-ititle");
p.StartInfo.ArgumentList.Add(args);
p.Start();
}
}public class ExampleController : Controller
{
public void Run(string args)
{
Process p = new Process();
p.StartInfo.FileName = "/usr/bin/find";
p.StartInfo.Arguments = "/some/folder -ititle " + args;
p.Start();
}
}public class ExampleController : Controller
{
public void Run(string args)
{
Process p = new Process();
p.StartInfo.FileName = "/usr/bin/find";
p.StartInfo.ArgumentList.Add("/some/folder");
p.StartInfo.ArgumentList.Add("-ititle");
p.StartInfo.ArgumentList.Add(args);
p.Start();
}
}From the same buckets as this rule.