rspec/rules/S1523/php/rule.adoc

39 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2020-06-30 12:47:33 +02:00
Executing code dynamically is security-sensitive. It has led in the past to the following vulnerabilities:
2020-06-30 12:47:33 +02:00
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-9807[CVE-2017-9807]
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-9802[CVE-2017-9802]
Some APIs enable the execution of dynamic code by providing it as strings at runtime. These APIs might be useful in some very specific meta-programming use-cases. However most of the time their use is frowned upon as they also increase the risk of https://owasp.org/www-community/attacks/Code_Injection[Injected Code]. Such attacks can either run on the server or in the client (exemple: XSS attack) and have a huge impact on an application's security.
2020-06-30 12:47:33 +02:00
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
This rule marks for review each occurrence of the https://www.php.net/manual/en/function.eval.php[``++eval++`` function]. This rule does not detect code injections. It only highlights the use of APIs which should be used sparingly and very carefully. The goal is to guide security code reviews.
2020-06-30 12:47:33 +02:00
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,php]
2020-06-30 12:47:33 +02:00
----
eval($code_to_be_dynamically_executed)
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]