Bird
0
0

A developer tries to prevent XSS by writing:

medium📝 Debug Q7 of 15
Django - Security Best Practices
A developer tries to prevent XSS by writing:
{% autoescape off %}{{ user_input }}{% endautoescape %}

What is the issue here?
AThe syntax for autoescape is incorrect and causes error.
BAutoescaping off escapes the input twice.
CAutoescaping is turned off, so XSS risk increases.
DDjango ignores autoescape tags by default.
Step-by-Step Solution
Solution:
  1. Step 1: Understand autoescape tag effect

    Turning autoescape off disables automatic escaping inside the block.
  2. Step 2: Recognize security implications

    This allows raw HTML and scripts to be rendered, increasing XSS risk.
  3. Final Answer:

    Autoescaping off disables protection, raising XSS risk. -> Option C
  4. Quick Check:

    Autoescape off = B [OK]
Quick Trick: Turning off autoescape disables XSS protection [OK]
Common Mistakes:
MISTAKES
  • Thinking autoescape off escapes input
  • Believing syntax is invalid
  • Assuming Django ignores autoescape tags

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes