35 lines
772 B
Plaintext
35 lines
772 B
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
$binary = $_GET["binary"];
|
|
|
|
// If the value "/sbin/shutdown" is passed as binary and the web server is running as root,
|
|
// then the machine running the web server will be shut down and become unavailable for future requests
|
|
|
|
exec( $binary ); // Noncompliant
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
$binary = $_GET["binary"];
|
|
|
|
// Restrict to binaries within the current working directory whose name only contains letters
|
|
$pattern = "[a-zA-Z]++";
|
|
if ( preg_match($pattern, $binary) ) {
|
|
exec( $binary ); // Compliant
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|