Maximum protection with static taint analysis

SonarQube's taint analysis is a deep security scan that tracks user-controllable data through your entire application, to identify sophisticated injection vulnerabilities.

Get startedContact sales
Image depicts taint analysis

How taint analysis works

Taint analysis tracks untrusted user input throughput the execution flow ensuring no untrusted and unsanitized input can reach a sensitive function. Sonar’s taint analysis transforms your whole code base into a large graph model that represents all possible execution paths. It then simulates the data flow between all data assignments, creating a precise simulation of what your code does at runtime - without actually executing it.

Taint analysis operates by modelling four core elements within the code:

Taint source: The entry point of untrusted data, such as a user HTTP request


// 1) Taint source: untrusted user input
function handleRequest(req) {
    const userInput = req.query.username; // source


Passthrough:  A function or process that parses and returns untrusted data, effectively allowing untrusted data to flow through it


// 2) Passthrough: data flows through code
    let name = userInput;


Sanitizer/Validator: A function or process that cleanses or validates the data, neutralizing the security risk before the data reaches a sink.


// 3) Sanitizer / validator
function sanitize(str) {
    //very simple example: allow only letters and numbers
    return str.replace(/[^a-zA-Z0-9]/g, '');
}
name = sanitize(name); // sanitize before using


Sensitive sink: A function where untrusted data could cause harm, such as executing a system command, or running a database query.


// 4) Sensitive sink: where misuse could cause trouble
// e.g., inserting into HTML without escaping, or running a command
console.log('Welcome, ${name}!`); // safe if sanitized
// If we skipped sanitize, this could risk injection in other sinks


A vulnerability is found when the analysis discovers an uninterrupted path from a source to a sink without passing through an adequate sanitizer or validator.

What makes Sonar’s taint analysis the best in the industry

sonar

Unmatched accuracy

Uses cross-file and cross function analysis to pinpoint complex injection flaws which minimizes false positives and builds developer trust.

magnifying glass

Breadth of Scope

This deep data flow analysis is framework-aware and supports most common frameworks and libraries.

stopwatch

Real-time

Security issues are synchronized to your IDE, so you can investigate and fix vulnerabilities with clear guidance.

oss

Dependency-aware

Extends the analysis to third-party open source libraries , uncovering any hidden vulnerabilities that may arise from the interaction between your code and its dependencies.

Taint analysis benefits

warning

Uncover complex injection risks

Trace user-controlled data across the full execution flow even across multiple files to pinpoint and fix hard-to-find vulnerabilities like SQL injection and cross-site scripting (XSS).

secure

Enhance security posture and compliance

Taint analysis strengthens an organization's overall security posture. This helps AppSec teams achieve robust application security and meet compliance requirements like PCI DSS.

false positive

Reduces false positives

Our precise taint analysis only raises an issue when a proven, exploitable path exists from an external, untrusted source to a security-sensitive operation, without sufficient sanitization. This sophisticated tracing lowers the number of false positives.

Build trust into every line of code

Image for rating

4.6 / 5

Frequently asked questions

Taint Analysis is an advanced static analysis technique that provides deep insight into your code's security posture by tracking the data flow. It works by tracing untrusted user input (the taint) from where it enters your application (the source) all the way to where it's used in a critical operation (the sink). The core function of taint analysis is to identify injection attacks, which are the leading cause of security incidents.

Taint analysis is essential because it helps you uncover complex, deeply hidden security flaws that simple pattern matching often misses. Taint analysis helps organizations maintain a strong security posture and easily track adherence to industry standards and regulatory compliance requirements.