rspec/rules/S6350/csharp/rule.adoc
2022-02-04 16:28:24 +00:00

43 lines
871 B
Plaintext

include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
Arguments like `-delete` or `-exec` for the `find` command can alter the expected behavior and result in vulnerabilities:
----
using System.Diagnostics;
Process p = new Process();
p.StartInfo.FileName = "/usr/bin/find";
p.StartInfo.ArgumentList.Add(input); // Sensitive
----
== Compliant Solution
Use an allow-list to restrict the arguments to trusted values:
[source,csharp]
----
using System.Diagnostics;
Process p = new Process();
p.StartInfo.FileName = "/usr/bin/find";
if (allowed.Contains(input)) {
p.StartInfo.ArgumentList.Add(input);
}
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
endif::env-github,rspecator-view[]