Repository navigation
Taint Tracking
Canonical source: docs/taint-tracking.md.
Taint tracking follows untrusted data from a source through assignments to a dangerous sink. A flow becomes a taint-* finding rated CRITICAL or HIGH, with a trace of the steps. In SARIF the trace becomes a codeFlow, which GitHub code scanning shows step by step.
Turn it off with --no-taint or taint=False.
| Language | Engine | Module |
|---|---|---|
| Python |
ast, inter-statement; see scope below |
core/py_taint.py |
| JavaScript, C#, C++, Go, Ruby, Rust | tree-sitter data-flow engine (with [treesitter]) |
core/ts_engine.py, core/ts_specs.py
|
| same, without tree-sitter | line-based fallback | core/taint_fallback.py |
| Java, HTML, SQL | none | — |
Java taint tracking is an open issue (#6).
- In the latest release, v1.4.0, Python taint tracking stays inside one function of one file.
- On the current
mainbranch (unreleased; PR #8), Python taint tracking also follows calls one level deep within the same file, using parameter-to-sink summaries. A call that passes untrusted data into a helper is reported with a source, call-site and sink trace that names both functions. - Deeper call chains (two or more levels), cross-file calls, and the tree-sitter and fallback engines remain intra-procedural. Issue #1 remains open for the rest of that work.
Parameters of recognized route handlers are treated as sources. Containers are coarse: a dict or list that receives tainted data is tainted as a whole. Custom sanitizers are not recognized; use --disable-rule or rename through a known sanitizer.
| Kind | Examples |
|---|---|
| Remote | Flask/Django/FastAPI request.*, route-handler parameters, Express req.*, Go *http.Request, C# [Http*] action parameters, Rails params, input(), stdin, gets, cin, fgets, read_line, sockets |
| Local | environment variables, sys.argv / os.Args / argv / env::args, file contents, command-line flags |
| Rule id | Sinks |
|---|---|
taint-command-injection |
os.system, subprocess with shell=True or a tainted program, exec.Command, Process.Start, system(), backticks, Command::new
|
taint-code-injection |
eval, exec, Function(), instance_eval, … |
taint-sql-injection |
execute/query/Exec with a query built from tainted data |
taint-deserialization |
pickle.loads, yaml.load, Marshal.load, BinaryFormatter, … |
taint-template-injection |
render_template_string, Template(...)
|
taint-path-traversal |
open, os.Open, File.ReadAllText, send_file, http.ServeFile, … |
taint-xss |
innerHTML, document.write, Markup, template.HTML, html_safe, … |
taint-ssrf |
requests.get, urlopen, fetch, http.Get, HttpClient, … |
taint-open-redirect |
redirect(...), res.redirect, http.Redirect
|
taint-format-string |
printf(user) and friends (C/C++) |
taint-dynamic-dispatch |
getattr(obj, user), send(params[...])
|
Numeric casts, shlex.quote, HTML escaping, os.path.basename / filepath.Base / File.basename, URL encoding, and parameterized queries (placeholders with a separate argument list) clear taint.
- A remote source reaching a CRITICAL-class sink (command, code, SQL injection) is CRITICAL.
- The same flow from a local source is one level lower (HIGH).
- Deserialization flows are HIGH.
- SSRF, XSS, open-redirect, path-traversal, template and dynamic-dispatch sinks ignore local sources.
- The same sink with only literal arguments keeps the lower non-taint rating (for example
os.system("ls -l")is MEDIUM). -
subprocess.run(["ping", host])(fixed program, no shell) is not a command-injection CRITICAL.
When a taint flow ends on the same line and CWE as an existing finding, that finding is upgraded instead of duplicated.
A short Flask example and the full lists are in docs/taint-tracking.md.
Created by ML / ML Innovations Research Lab. Korg (AI assistant, Grok Bot), contributor. · Repository · Apache License 2.0
Start here
Using Code Cleaner
Contributing