Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

security.authentication

Avoid CSRF exemptions on state-changing Django views

Browser-facing Django views that change state should remain CSRF-protected unless they are explicitly token-authenticated APIs.

#Metadata

Rule ID
py.security.django-csrf-exempt-state-changing
Severity
high
Confidence
0.82
Languages
python
Presets
security, strict
Stability
stable
Applies to
block
Tags
csrf, django, python, rules-catalog, security

#Why it matters

Using django.decorators.csrf.csrf_exempt removes CSRF defenses for session-backed browsers, enabling cross-site request forgery against unsafe methods.

#Remediation

Remove `@csrf_exempt`, enforce CSRF tokens for browser views, or constrain the endpoint to non-session authentication with explicit CSRF policy.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/python/py.security.django-csrf-exempt-state-changing.rule.yaml.