2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-06-08 14:23:48 +02:00
|
|
|
Included variables may have been set by user input could contain unexpected, and potentially dangerous values.
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-06-08 14:23:48 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,php]
|
2021-06-08 14:23:48 +02:00
|
|
|
----
|
|
|
|
include $foo;
|
|
|
|
require $foo;
|
|
|
|
include $foo . '/config.php';
|
|
|
|
require $foo . '/config.php';
|
|
|
|
include "$foo/config.php";
|
|
|
|
require "$foo/config.php";
|
|
|
|
include($foo);
|
|
|
|
require($foo);
|
|
|
|
include($foo . '/config.php');
|
|
|
|
require($foo . '/config.php');
|
|
|
|
include("$foo/config.php");
|
|
|
|
require("$foo/config.php");
|
|
|
|
|
|
|
|
include "./$page.php";
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-06-08 14:23:48 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,php]
|
2021-06-08 14:23:48 +02:00
|
|
|
----
|
|
|
|
include "./$page.php";
|
|
|
|
----
|
|
|
|
|