Protection against cross-site request forgery is turned off for a view or an application
What it finds
Without a CSRF token, any site a logged-in user visits can make the browser send requests to this one with the user's cookies, and the server cannot tell them from real ones. Reported are views marked @csrf_exempt, and the settings WTF_CSRF_ENABLED = False and WTF_CSRF_CHECK_DEFAULT = False, also as app.config[...] assignments. Endpoints called only by other servers, such as webhooks, often need the exemption; it should then check a signature instead.
From the rule's source, csrf_check_off.rs.
from django.views.decorators.csrf import csrf_exempt @csrf_exempttx0 reports: this view accepts requests without a CSRF tokendef hook(request): pass WTF_CSRF_ENABLED = Falsetx0 reports: this setting turns off CSRF protectionapp.config["WTF_CSRF_ENABLED"] = Falsetx0 reports: this setting turns off CSRF protectionapp.config["WTF_CSRF_ENABLED"] = True Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:csrf-check-off" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:csrf-check-off] reason="..."tx0 explain tx0/python:csrf-check-off shows the same in the terminal. Found a false positive? Report it.