A source is the point where attacker-controlled data enters the application, such as an API request body or query parameter. A sink is a security-sensitive operation that becomes dangerous if that data reaches it, such as file access, command execution, or archive processing. Taint analysis is designed to determine whether a path exists between the two.
Why Source and Sink Mean Different Things in Taint Analysis
Source and sink are opposite ends of the same trust problem. The source is where untrusted or attacker-influenced input enters the code path, while the sink is where that input becomes dangerous if it is consumed without validation, encoding, or other handling. taint analysis exists to trace whether data can travel from one to the other across assignments, function calls, and transformations.
That distinction matters because many vulnerabilities are not caused by bad input alone, but by bad input reaching a sensitive operation. A string may be harmless in one branch and dangerous in another, so the analysis has to reason about flow, not just content. In practice, teams usually discover the failure only after a sink has been reachable through an unexpected path.
For readers looking for input-security basics, the OWASP API Security Top 10 is a useful companion because many source-to-sink paths start with API parameters, request bodies, or other externally supplied data. The core lesson is that source identifies exposure, while sink identifies impact.
How Taint Analysis Tracks a Dangerous Path
Taint analysis marks data as “tainted” once it comes from a source and then follows that mark through the program until it is cleared or reaches a sink. The practical value is that it helps security reviewers focus on exploitable flows instead of reviewing every variable equally. Static tools do this at compile time or on source code, while dynamic approaches can observe flows during execution.
Common sources include HTTP parameters, headers, deserialized objects, message queue payloads, file contents, and environment-derived inputs. Common sinks include SQL execution, shell command invocation, filesystem operations, archive extraction, template rendering, path joins, and deserialization. The exact source and sink pairs depend on the language and framework, but the logic stays the same: untrusted data plus a sensitive operation equals risk unless a trusted sanitisation step breaks the path.
Source: attacker-controlled or externally influenced input.
Propagation: assignments, concatenation, parsing, or object passing that preserve taint.
Sanitiser: a control that reduces or removes the dangerous property of the data for a specific sink.
Sink: an operation that can cause code execution, data exposure, or integrity loss.
Useful analysis depends on sink-specific rules, because a transformation that is safe for one sink may not be safe for another. For example, escaping for HTML output does not make a string safe for command execution. These controls tend to break down when frameworks abstract the data flow so heavily that the tool cannot see where input becomes executable or path-sensitive.
Common Variations and Edge Cases
Tighter taint rules often increase false positives, so teams have to balance detection coverage against developer noise and review effort. The hardest cases are usually not the obvious injections, but flows that pass through helper functions, custom wrappers, object mappers, or framework features that obscure whether a sanitiser really matched the sink.
Some edge cases depend on context. A value may be tainted for one sink but safe for another, and some sinks are only dangerous when combined with a particular format, encoding, or privilege boundary. There is no universal standard for this yet across every language stack, so mature tooling usually supplements generic taint rules with project-specific sink definitions and manual review of custom abstractions.
Another common mistake is treating “validated once” as a permanent property. Validation is only meaningful relative to the sink and the assumptions that remain true at the point of use. If the data is transformed later, or crosses into a different subsystem, the earlier safety decision may no longer hold. For source-to-sink review, the important question is not whether the data was touched, but whether it remains safe when it arrives.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10 provides the primary governance reference for this topic.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | A1 — Prompt Injection | Covers attacker-controlled input reaching unsafe downstream actions. |
| A3 — Tool Misuse | Models dangerous action when input reaches an execution sink. | |
| Recommendation — Treat untrusted inputs as tainted and block unsafe downstream tool or code execution. Restrict sensitive sinks so tainted data cannot trigger privileged tool actions. | ||
Practitioner Guidance
What to prioritise: Start with sinks that can change integrity or execute code, then work outward to lower-impact flows such as logging or rendering. A sink-first review usually finds the paths that matter fastest, especially in legacy code where sources are numerous but dangerous uses are concentrated.
What to verify: Confirm that each claimed sanitiser is actually sink-specific and still valid after any later transformation. The critical test is whether the data remains safe at the exact use site, not whether it passed a general validation rule earlier in the request lifecycle.
Common mistake: Do not assume a taint pass means the application is safe. Many real defects sit in custom glue code, framework adapters, or uncommon sinks that the default rule set does not model well. A narrow rule set can miss the exact path that an attacker would exploit.
Practitioner takeaway: Source and sink are only useful as a pair, because exploitability appears when attacker-influenced data survives long enough to reach a dangerous operation without being neutralised.
Related resources from NHI Mgmt Group
- What is the difference between scanning for a vulnerable sink and building a full source to sink analysis rule?
- What is the difference between vulnerability scanning and reachability analysis for open source risk?
- What is the difference between software composition analysis and an SBOM in open source security?
- What is the difference between an SBOM and package reputation analysis for open-source security?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on September 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org