41 lines
857 B
Plaintext
41 lines
857 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:
|
|
----
|
|
const { spawn } = require("child_process");
|
|
const input = req.query.input;
|
|
const proc = spawn("/usr/bin/find", [input]); // Sensitive
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
Use an allow-list to restrict the arguments to trusted values:
|
|
[source,javascript]
|
|
----
|
|
const { spawn } = require("child_process");
|
|
const input = req.query.input;
|
|
if (allowed.includes(input)) {
|
|
const proc = spawn("/usr/bin/find", [input]);
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
'''
|
|
endif::env-github,rspecator-view[]
|