Flask protects nothing by default, so test by requesting every view with no session and confirming a redirect rather than a 200. Then read the queries for f-string or % interpolation, which is where Flask apps still get SQL injection.
Where this class of bug actually lives in a Flask app
- Views without
@login_required. The decorator is per function. A blueprint registered without abefore_requestguard has whatever protection each view remembered. - String-built SQL.
f"SELECT * FROM invoices WHERE id = {invoice_id}"is still common in Flask codebases that use raw cursors. - Session contents. Flask signs the cookie but does not encrypt it. A
roleoruser_idread fromsessionis readable and, with a leakedSECRET_KEY, forgeable. - Debug mode. The Werkzeug debugger gives a remote console on a 500, pinned to a guessable PIN derived from machine paths.
What to try first
- Request every route with no cookie and confirm a 302 to login rather than a 200.
- Grep for
execute(with an f-string or%and trace the parameter to a request value. - Decode the session cookie and look for anything authorization depends on.
- Trigger a 500 in any non-production-but-reachable instance and look for the debugger.
A reproduction you can keep
The session cookie is the fastest read. It is signed, not encrypted:
# session contents, base64 payload before the signature
python3 - <<'PY'
import base64, sys
c = "eyJyb2xlIjoibWVtYmVyIiwidXNlcl9pZCI6MTJ9.ZZZ.signature"
p = c.split(".")[0]
print(base64.urlsafe_b64decode(p + "=" * (-len(p) % 4)))
PY
curl -sS -i https://staging.example.com/invoices/1003 -H 'Cookie: session=***'
# vulnerable: session says role=member, and invoice 1003 belongs to someone else
# fixed: nothing authorizing in the session payload; 404 on the foreign idWhat "fixed" has to look like
Read authorization state from the database on each request, never from a value the client can see and, with a leaked key, rewrite. The fixed result is a foreign id returning 404 and a session payload carrying only an opaque user reference.
Where people get this wrong
- A weak or committed
SECRET_KEYmakes the session cookie a forgeable authorization token. render_template_stringwith user input is server-side template injection, which is remote code execution, not XSS.- CSRF protection in Flask-WTF is per form. A JSON API endpoint without it takes cross-site writes happily.
What Offense does here
Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.
Questions this page answers
Is the Flask session cookie encrypted?
No. It is signed. Anyone can read it; anyone with the SECRET_KEY can write it.
Where do Flask apps most often get SQL injection?
Raw cursor queries built with f-strings or % formatting, usually in a reporting or admin view added later.
Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.