docs: note CSRF POST and DOM XSS rules in AGENTS.md (#2684)

Document that mutating dynamic-analysis actions must be POST with a CSRF
token, and that template auto-escaping does not protect innerHTML sinks.

Co-authored-by: Cursor Agent <[email protected]>
This commit is contained in:
Ajin Abraham
2026-09-20 19:38:24 -07:00
committed by GitHub
co-authored by Cursor Agent
parent c730571083
commit d3869adc46
+6 -2
View File
@@ -142,7 +142,9 @@ def my_view(request, api=False):
Django's template engine escapes variables by default. Do **not** use `{% autoescape off %}`
or the `|safe` filter on any value derived from scan data, manifests, or user input.
When rendering user-controlled strings outside of templates (e.g., in a JSON response
built by hand), use `django.utils.html.escape()` explicitly.
built by hand), use `django.utils.html.escape()` explicitly. Template auto-escaping
does not protect JavaScript DOM sinks: never assign scan, task, or user-derived
strings to `innerHTML`; use `textContent` (see `templates/general/tasks.html`).
### ORM — No Raw SQL
@@ -163,7 +165,9 @@ RecentScansDB.objects.raw(f'SELECT * FROM ... WHERE MD5 = "{checksum}"')
Django's `CsrfViewMiddleware` is enabled globally. Do not use `@csrf_exempt` on any
view that modifies state. API endpoints that accept an `X-Csrftoken` header or use
token-based auth are the only legitimate exception, and that pattern is already
established in the existing API views.
established in the existing API views. Mutating actions (including dynamic-analysis
start/stop/stream) must be POST with a CSRF token, not GET. Split GET-render from
POST-stream when a page both renders and then streams (e.g. logcat).
---