Skip to content

Commit f9f0c68

Browse files
committed
[#2555] Tweaking JSON Hijacking note to add a bit more information that Fabpot added
1 parent 10f3926 commit f9f0c68

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

components/http_foundation/introduction.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,11 @@ to ``application/json``.
450450

451451
.. caution::
452452

453-
To avoid `JSON Hijacking`_, you should pass an associative array as the
454-
outer-most array to ``JsonResponse`` and not an indexed array so that
455-
the final result is an object (e.g. ``{"object": "not inside an array"}``)
456-
instead of an array (e.g. ``[{"object": "inside an array"}]``).
453+
To avoid XSSI `JSON Hijacking`_, you should pass an associative array
454+
as the outer-most array to ``JsonResponse`` and not an indexed array so
455+
that the final result is an object (e.g. ``{"object": "not inside an array"}``)
456+
instead of an array (e.g. ``[{"object": "inside an array"}]``). Read
457+
the `OWASP guidelines`_ for more information.
457458

458459
JSONP Callback
459460
~~~~~~~~~~~~~~
@@ -476,4 +477,5 @@ Session
476477
The session information is in its own document: :doc:`/components/http_foundation/sessions`.
477478

478479
.. _Packagist: https://packagist.org/packages/symfony/http-foundation
479-
.. _`JSON Hijacking`: http://haacked.com/archive/2009/06/25/json-hijacking.aspx
480+
.. _`JSON Hijacking`: http://haacked.com/archive/2009/06/25/json-hijacking.aspx
481+
.. _OWASP guidelines: https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines#Always_return_JSON_with_an_Object_on_the_outside

0 commit comments

Comments
 (0)