
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
110 lines
2.0 KiB
Plaintext
110 lines
2.0 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
== Sensitive Code Example
|
|
|
|
PHP built-in header function:
|
|
|
|
----
|
|
header("Access-Control-Allow-Origin: *"); // Sensitive
|
|
----
|
|
|
|
Laravel:
|
|
|
|
----
|
|
response()->header('Access-Control-Allow-Origin', "*"); // Sensitive
|
|
----
|
|
|
|
Symfony:
|
|
|
|
----
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
$response = new Response(
|
|
'Content',
|
|
Response::HTTP_OK,
|
|
['Access-Control-Allow-Origin' => '*'] // Sensitive
|
|
);
|
|
$response->headers->set('Access-Control-Allow-Origin', '*'); // Sensitive
|
|
----
|
|
|
|
User-controlled origin:
|
|
|
|
[source,php]
|
|
----
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
$origin = $request->headers->get('Origin');
|
|
|
|
$response->headers->set('Access-Control-Allow-Origin', $origin); // Sensitive
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
PHP built-in header function:
|
|
|
|
[source,php]
|
|
----
|
|
header("Access-Control-Allow-Origin: $trusteddomain");
|
|
----
|
|
|
|
Laravel:
|
|
|
|
[source,php]
|
|
----
|
|
response()->header('Access-Control-Allow-Origin', $trusteddomain);
|
|
----
|
|
|
|
Symfony:
|
|
|
|
[source,php]
|
|
----
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
$response = new Response(
|
|
'Content',
|
|
Response::HTTP_OK,
|
|
['Access-Control-Allow-Origin' => $trusteddomain]
|
|
);
|
|
|
|
$response->headers->set('Access-Control-Allow-Origin', $trusteddomain);
|
|
----
|
|
|
|
User-controlled origin validated with an allow-list:
|
|
|
|
[source,php]
|
|
----
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
$origin = $request->headers->get('Origin');
|
|
|
|
if (in_array($origin, $trustedOrigins)) {
|
|
$response->headers->set('Access-Control-Allow-Origin', $origin);
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|