Auto-escaping disabled (ARCH2134)
Ce contenu n’est pas encore disponible dans votre langue.
Key python.security.disabled-auto-escape · Severity warning · Category security · CWE CWE-79
Turning off auto-escaping in a template engine removes the default XSS protection for every rendered value. User data is emitted as raw HTML, opening the door to cross-site scripting.
Incorrect
Section titled “Incorrect”from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader("templates"), autoescape=False)Correct
Section titled “Correct”from jinja2 import Environment, FileSystemLoader, select_autoescape
env = Environment(loader=FileSystemLoader("templates"), autoescape=select_autoescape(["html", "xml"]))Keep auto-escaping on; use select_autoescape for HTML/XML templates.