Skip to content

Hub: Flask and Django multi-value request inputs are now taint sources - #2388

Merged
remigiusz-antczak merged 3 commits into
mainfrom
feat/hub-taint-21
Nov 16, 2026
Merged

remigiusz-antczak merged 3 commits into
mainfrom
feat/hub-taint-21

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Python taint rules missed attacker input read through multi-value accessors. request.args.getlist(...), request.form.getlist(...), request.GET.getlist(...), request.POST.getlist(...) and the fully qualified flask.request.$A.getlist(...) are now sources at every site where the single-value accessors already were.

An intermediate commit skipped sink arguments named in ALL_CAPS to silence a false positive on a constant URL. The independent review showed that the skip was bypassable: a response-derived value stored in an ALL_CAPS name (a callback URL, a SQL string, a module global) reached requests or cursor.execute with no finding. The skip is removed, and those three probes plus the flask getlist form are ruleid cases in scripts/test_semgrep_py_guards.py. Known limit (a false positive, accepted over a bypass): a chained requests.get(CONST).text or .json() with a constant-variable URL still reports.

Tests: 3/3 (test_semgrep_py_guards, test_semgrep_py_pathtrav, test_semgrep_defaults). Bench: vuln hits unchanged, clean twins silent for perun rules, MAX_FALSE_POSITIVES unchanged.
🤖 Generated with Claude Code

remigiusz-antczak and others added 3 commits November 16, 2026 07:48
The Python taint rules read request.args[...] and request.args.get(...) as sources but not request.args.getlist(...), so a Flask or Django multi-value read (args, form, values, GET, POST) reaching a sink was missed. Every rule that lists the request.$A.get(...) source now also lists request.$A.getlist(...).

perun.py.unsafe-api-consumption reported the chained `requests.get(URL).text` for any non-literal URL: the response source expression contains the URL sink, so the call counted as its own source. A sink argument that is an ALL_CAPS constant name is now skipped, as the existing literal-URL skip already did. A tainted URL in the same chained form still reports. Known limit: a lowercase local assigned a literal is still reported in the chained form.

Checked against bench/tool-only: all nine vuln hits are unchanged and the clean twins stay silent for the perun rules.

Tests: 3/3 (test_semgrep_py_guards with getlist, constant-URL chained ok and response-derived chained ruleid cases, test_semgrep_py_pathtrav, test_semgrep_defaults)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The perun.py.unsafe-api-consumption sink regexes skipped any argument named like an ALL_CAPS constant. A name says nothing about where the value came from, so a response-derived ALL_CAPS variable or module global reached the sink with no finding (for example a callback URL or query string read from an API response and bound to a constant-style name). Only an inline http(s) string literal is skipped now.

Known limit: a chained requests.get(CONSTANT_URL).text or .json() on a constant URL reports again, because the sink counts as its own source. A false positive is cheaper than a bypass.

The fully qualified flask.request.$A.getlist(...) form is now a source wherever flask.request.$A.get(...) is.

Tests: 3/3 (test_semgrep_py_guards with response-derived ALL_CAPS url, sql and global probes plus flask.request getlist, test_semgrep_py_pathtrav, test_semgrep_defaults). Bench: vuln hits unchanged, clean silent for perun rules, MAX_FALSE_POSITIVES unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test_semgrep_injection pinned the exact source list of the git-argument-injection rule; it now includes the request.$A.getlist and flask.request.$A.getlist sources, still an exact match. test_semgrep_taint expected no finding on a requests.get("https://" + h) behind an `in` allowlist guard, but the ssrf rule no longer honors that bypassable guard, so line 13 is an expected finding now.

Tests: 13/13 scripts/test_semgrep_*.py pass offline

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@remigiusz-antczak
remigiusz-antczak merged commit 772c3f6 into main Nov 16, 2026
13 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the feat/hub-taint-21 branch November 16, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant