By NHI Mgmt Group Editorial TeamDomain: Cyber SecuritySource: SonarPublished June 3, 2026

TL;DR: Taint analysis can trace user-controlled data across files and method calls to expose injection flaws, according to Sonar, while AI coding agents still reproduce SQL injection patterns because the generation loop does not follow data across call boundaries. That gap keeps injection risk alive even when code compiles and tests pass, and it makes source-to-sink tracking central to modern code security.


At a glance

What this is: Sonar explains how taint analysis follows data from source to sink across files, and why that matters for catching injection flaws that AI-generated code still reproduces.

Why it matters: For IAM and security teams, the lesson is that secure coding controls must prove where untrusted data can flow, not just whether the final code block looks safe.

By the numbers:

  • When AWS credentials are exposed publicly, attackers attempt access within an average of 17 minutes and as quickly as 9 minutes in some cases.
  • Only 44% of developers are reported to follow security best practices for secrets management, exposing a significant developer behaviour gap.

👉 Read Sonar's taint analysis walkthrough for injection flaws in AI-generated code


Context

Injection flaws persist because the dangerous value is often created far from the sink where it is executed. Static checks that inspect one file or method in isolation can miss the path that carries tainted input through controllers, services, and repositories into a database call. In application security, the core problem is not just unsafe string handling, but losing visibility into how untrusted data moves across boundaries.

This is also relevant to identity and NHI governance because the same source-to-sink logic underpins how tokens, API keys, service inputs, and agent-driven actions become dangerous when they are not tracked end to end. AI coding agents can reproduce insecure patterns without understanding that a value originated outside the trust boundary, which makes taint-aware analysis more important as code generation accelerates.

Sonar's example is typical of a broader class of failures rather than an isolated Spring Boot issue. The pattern applies across XSS, path traversal, and SQL injection because the governance problem is consistent: the control must follow data, not just inspect syntax.


Key questions

Q: How should security teams govern AI-generated code in production environments?

A: Security teams should treat AI-generated code as normal production code with extra provenance risk. Require architectural review, test coverage, static analysis, and approval before merge. Then bind the agent and the build pipeline to least privilege, short-lived credentials, and complete audit logging so implementation speed does not outrun control.

Q: Why do injection flaws still appear in code that compiles and passes tests?

A: Because compilation and functional tests do not prove that user-controlled data stayed separated from executable logic. A program can behave correctly in normal cases while still allowing unsafe propagation from source to sink. Injection defects surface only when analysis tracks untrusted input across the full execution path and confirms whether it reaches a query, command, or rendering operation.

Q: What do security teams get wrong about blind SQL injection?

A: They often assume the absence of visible data leakage means the application is safe. Blind SQL injection can still be confirmed through timing or behavioural changes, which means the query is being manipulated even when the page looks normal. Validation must account for invisible exploitation paths.

Q: How do teams know whether taint analysis is actually working?

A: Look for findings that show a full path from source to sink, including intermediate propagation steps and the exact framework or API involved. If the tool only flags isolated string concatenation but cannot trace the origin of the value, its coverage is too shallow for injection governance. Effective analysis should explain why the data was dangerous, not just where it landed.


Technical breakdown

Source-to-sink taint tracking in application code

Taint analysis marks external input as unsafe at the moment it enters an application, then follows that value through assignments, parameters, and method calls until it reaches a sink such as database queries, file writes, or output rendering. The strength of the model is that it survives abstraction. A controller may only pass a parameter onward, and a service may look harmless, but the taint graph still preserves the original trust boundary. That is why source-to-sink analysis catches bugs that file-by-file review often misses.

Practical implication: require source-to-sink tracing for code paths that accept user input and reach query, output, or filesystem operations.

Why AI coding agents keep reproducing injection patterns

AI coding agents generate code by pattern completion, not by building a security proof of how values move across call boundaries. If the model learned insecure examples from public repositories, it can recreate the same concatenation, interpolation, or unsafe parameter handling that produces injection flaws. The key weakness is not syntax quality. It is the absence of a trust-flow model that distinguishes user-controlled data from application-controlled logic.

Practical implication: treat AI-generated code as untrusted until automated analysis confirms that input handling and query construction are separated.

Execution flow annotations show where the sink becomes dangerous

Execution flow views make taint analysis operational by annotating each hop in the chain. A source marks the point where untrusted data enters, intermediate steps show propagation through pass-through methods, and the sink identifies the exact operation where unsafe execution occurs. This matters because the fix is usually not at the final sink alone. The trust decision is already embedded in earlier design choices, including whether the code uses string concatenation instead of parameterized queries.

Practical implication: use execution flow views to locate the first unsafe propagation point, not only the final vulnerable line.


Threat narrative

Attacker objective: The attacker wants to turn an ordinary request parameter into executable SQL that can read, alter, or destroy database content.

  1. Entry occurs when user-controlled HTTP input enters the application through a request parameter and is marked as tainted data.
  2. Escalation happens as the tainted value is passed unchanged through controller and service layers until it is concatenated into a SQL string.
  3. Impact occurs when the unsafe SQL reaches the database sink and executes as an injection-prone query that can expose or manipulate records.

NHI Mgmt Group analysis

AI-generated code needs trust-flow validation, not just syntax validation. The Sonar example shows why code can compile, test, and still remain unsafe when the generation process does not reason about where input originates. That is a governance gap, not merely a coding defect. For security teams, the practical conclusion is that AI-assisted development must be paired with analysis that proves safe data flow before merge.

Source-to-sink analysis is becoming a baseline control for modern application security. String sanitisation checks alone do not scale across controller, service, repository, and framework layers. Taint analysis maps neatly to AppSec, SDLC governance, and secure code review because it answers the only question that matters in injection testing: can untrusted data reach a dangerous operation unchanged? Teams that cannot answer that question do not have sufficient control assurance.

Injection risk is increasingly an identity-adjacent problem when secrets, tokens, and delegated inputs drive application behaviour. In practice, many compromised paths begin with trusted credentials, service inputs, or agent-mediated actions that are treated as safe too early. That is why identity governance and application security now overlap in runtime code review. Practitioners should treat every externally supplied value as a potential control boundary until analysis proves otherwise.

Taint analysis creates a named governance gap we should call data-flow blindness. Data-flow blindness is the failure to track untrusted input across methods, files, and framework abstractions before it reaches execution. This is exactly the condition that allows injection flaws to survive review even when individual lines look harmless. Teams should close it with analysis that follows data rather than relying on local code inspection.

What this signals

Data-flow blindness will become a recurring failure mode as AI coding tools scale output faster than review capacity. Teams will need to verify that code review, SAST, and taint tracing are aligned on the same execution path, or injection defects will keep slipping through normal assurance checks. The practical signal is not how much code was generated, but whether untrusted data paths were proven safe before deployment.

Identity and application security are converging at the point where trusted inputs become executable behaviour. That matters for service accounts, API tokens, and agent-driven workflows because the same trust assumptions that protect credentials can be bypassed when code fails to preserve data boundaries. Security programmes should expect more demand for cross-functional controls that link identity governance with runtime code analysis.

This is also where AI governance becomes operational rather than theoretical. If code generation is treated as a productivity layer without a corresponding trust-flow control, organisations will accumulate hidden injection risk faster than they can remediate it. The control objective is to make data provenance visible at the moment the application decides how to use it.


For practitioners

  • Instrument source-to-sink analysis in CI Run taint-aware scanning on pull requests that touch controllers, services, repositories, templating, or file-handling code so propagation across boundaries is checked before merge.
  • Prioritise parameterised execution paths Replace string concatenation and interpolation at database and command sinks with prepared statements or equivalent parameter binding so user input is never treated as executable logic.
  • Flag AI-generated code for boundary review Require an additional security review when code is produced by AI coding assistants and touches request handling, query construction, or filesystem operations.
  • Map taint findings to ownership by component Assign controller, service, and repository findings to the teams that own each layer so remediation covers propagation points, not only the final vulnerable line.

Key takeaways

  • Injection flaws survive because unsafe data flow is harder to see than unsafe syntax.
  • AI coding agents can reproduce insecure patterns unless taint-aware controls verify how values move across boundaries.
  • Practitioners should use source-to-sink analysis, parameter binding, and boundary-specific review to close data-flow blindness.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
MITRE ATT&CKTA0006 , Credential Access; TA0009 , Collection; TA0010 , ExfiltrationThe article centres on injection paths that expose or manipulate data after unsafe input reaches a sink.
NIST CSF 2.0PR.AC-3Input handling and execution boundaries affect access control and trust enforcement in application paths.
NIST SP 800-53 Rev 5SI-10Input validation is directly relevant to injection prevention and taint-traced application behaviour.
CIS Controls v8CIS-16 , Application Software SecurityThe article is about secure code analysis and injection prevention in application development.
OWASP Non-Human Identity Top 10NHI-09AI-generated code and secrets-driven application behaviour create adjacent NHI governance risk.

Review AI-assisted development paths for secret handling and trust-boundary failures that resemble NHI abuse.


Key terms

  • Taint Analysis: A method for tracking untrusted data as it moves through a system until it reaches a sensitive operation. In agentic environments, it helps security teams see when external content can influence tool selection, code changes, or other privileged actions that should not have been reachable from that input.
  • Source To Sink: A source to sink path is the full route data takes from where it enters a system to where it is acted on in a security-sensitive way. In injection analysis, the source is usually user-controlled input and the sink is the operation that becomes dangerous if the data is not constrained.
  • Prepared Statement: A database query pattern that separates code from data so user input cannot change the structure of the statement. It is one of the most reliable ways to prevent injection because the database treats parameters as values, not executable query logic.
  • Execution Flow: Execution flow is the annotated path a tool shows to explain how data moved through the code before a finding reached its sink. It helps reviewers understand not just that a flaw exists, but exactly which methods, assignments, and API calls allowed the unsafe value to propagate.

What's in the full article

Sonar's full analysis covers the operational detail this post intentionally leaves for the source:

  • Step-by-step execution flow annotations across controller, service, and repository layers
  • The exact Spring Boot taint path that reaches jdbcTemplate.query() and how Sonar labels each hop
  • Framework-specific fix guidance for prepared statements and safe parameter binding
  • Cross-language taint analysis coverage across Java, JavaScript, Python, C#, Go, and PHP

👉 Sonar's full post shows the execution flow, framework-specific remediation, and multi-language taint coverage.

Deepen your knowledge

The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, secrets management, and identity lifecycle controls. It helps practitioners connect identity governance to the broader security programmes that support safe application delivery.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 19, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org