Skip to content
Myr

Expanded the security docs to mention unquoted attributes as dangerous

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent cb660cd · Browse files · 2 files+26 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−1 removed

  • other:+26 added−1 removed

2 files+26 added−1 removed

modified:docs/foreword.rst+1 added-1 removed
101 unmodified lines
102Werkzeug and Flask will be ported to Python 3 as soon as a solution for103WSGI is found, and we will provide helpful tips how to upgrade existing104applications to Python 3. Until then, we strongly recommend using Python1052.6 and 2.7 with activated Python 3 warnings during development, as well106 as the unicode literals `__future__` feature.106as the unicode literals `__future__` feature.
modified:docs/security.rst+25 added
28 unmodified lines
29- sending out textfiles from uploaded files. Some browsers are using30 content-type guessing based on the first few bytes so users could31 trick a browser to execute HTML.3233Another thing that is very important are unquoted attributes. While34Jinja2 can protect you from XSS issues by escaping HTML, there is one35thing it cannot protect you from: XSS by attribute injection. To counter36this possible attack vector, be sure to always quote your attributes with37either double or single quotes when using Jinja expressions in them:3839.. sourcecode:: html+jinja4041 <a href="{{ href }}">the text</a>4243Why is this necessary? Because if you would not be doing that, an44attacker could easily inject custom JavaScript handlers. For example an45attacker could inject this piece of HTML+JavaScript:4647.. sourcecode:: html4849 onmouseover=alert(document.cookie)5051When the user would then move with the mouse over the link, the cookie52would be presented to the user in an alert window. But instead of showing53the cookie to the user, a good attacker might also execute any other54JavaScript code. In combination with CSS injections the attacker might55even make the element fill out the entire page so that the user would56just have to have the mouse anywhere on the page to trigger the attack.5758Cross-Site Request Forgery (CSRF)59---------------------------------6061Another big problem is CSRF. This is a very complex topic and I won't
107 unmodified lines