![github-actions[bot]](/assets/img/avatar_default.png)
* Create rule S6350 * Update description * Add code samples * Make stdin more verbose * Make stdin more verbose * Update recommended * Improve description * Extend ask yourself * Add compliant solutions and rename tainted variables * Add input var * Add link to blog post * Use find as example * Update csharp example * Add OWASP Top 10 2021 mapping * add missing message * fix metadata * Use type-safe in_array for PHP Co-authored-by: hendrik-buchwald-sonarsource <hendrik-buchwald-sonarsource@users.noreply.github.com> Co-authored-by: Hendrik Buchwald <hendrik.buchwald@sonarsource.com> Co-authored-by: Pierre-Loup Tristant <pierre-loup.tristant@sonarsource.com> Co-authored-by: eric-therond-sonarsource <eric.therond@sonarsource.com> Co-authored-by: Roberto Orlandi <71495874+roberto-orlandi-sonarsource@users.noreply.github.com>
38 lines
756 B
Plaintext
38 lines
756 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:
|
|
----
|
|
$input = $_GET['input'];
|
|
system('/usr/bin/find ' . escapeshellarg($input)); // Sensitive
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
Use an allow-list to restrict the arguments to trusted values:
|
|
----
|
|
$input = $_GET['input'];
|
|
if (in_array($input, $allowed, true)) {
|
|
system('/usr/bin/find ' . escapeshellarg($input));
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
'''
|
|
endif::env-github,rspecator-view[]
|