Pricing Insights
Book a demo

SAST

SAST: Static Application Security Testing

SAST checks source code for vulnerabilities without running the application. The analyzer reads code the way an experienced reviewer would, only faster and across the whole project at once. It builds a model of the program and looks for places where unchecked data reaches a dangerous function.

Its main advantage is early detection. A problem shows up in the pull request, down to the file and line, when it is cheapest to fix.

How it works

  • Parse the code into a syntax tree and a control-flow graph.
  • Taint analysis: trace data from a source (request parameter, file, queue message) to a sink such as an SQL query, an OS command or an HTML template.
  • Rule-based search: dangerous functions, weak cryptography, hardcoded secrets, unsafe deserialization.
  • The result is a list of findings with the vulnerability type (CWE), severity and location in the code.

What it finds

SQL injectionCWE-89User input is concatenated into the query text
Cross-site scripting (XSS)CWE-79Data is written to HTML without escaping
OS command injectionCWE-78A parameter reaches a shell call
Path traversalCWE-22A file name from the request is opened without validation
Secrets in codeCWE-798A password, token or key is written directly in the source
Weak cryptographyCWE-327MD5, SHA-1, DES, ECB, a home-made cipher
Insecure deserializationCWE-502An object is restored from untrusted data

Example

Vulnerable: input is concatenated into SQL
String sql = "SELECT * FROM accounts WHERE iban = '"
    + request.getParameter("iban") + "'";
ResultSet rs = conn.createStatement().executeQuery(sql);
Fixed: parameterized query
PreparedStatement ps = conn.prepareStatement(
    "SELECT * FROM accounts WHERE iban = ?");
ps.setString(1, request.getParameter("iban"));
ResultSet rs = ps.executeQuery();
What it looks like in a report

CWE-89 · SQL Injection · AccountController.java:42 · source request.getParameter("iban") → sink Statement.executeQuery

Limitations and common mistakes

  • False positives: the analyzer does not know the business logic, so some findings need manual review.
  • It cannot see server misconfiguration or problems that appear only at runtime. DAST covers those.
  • It does not check third-party libraries. That is the job of SCA.

How to choose a SAST tool

  1. Languages and frameworks: the analyzer must understand every language in the project. Check niche ones separately: 1C, PL/SQL, Kotlin, Swift, Dart.
  2. Checking changes in a merge request within minutes, not only a full scan at night.
  3. Triage: suppressing false positives with a recorded reason, so they do not come back after the next scan.
  4. Custom rules: the ability to add checks for internal libraries and requirements.
  5. Where it runs: in an isolated environment the code must not leave for an external cloud.
  6. Reports mapped to CWE and OWASP Top 10, which auditors and regulators ask for.

SAST, SCA and DAST: what is the difference

SASTSCADAST
What it checksYour own source codeThird-party librariesThe running application from outside
Needs a runNoNoYes, a test environment
WhenEvery merge requestEvery build and on a new CVEOn a test environment before release
FindsInjections, XSS, secrets, weak cryptographyKnown CVEs, licenses, malicious packagesConfiguration, authentication and header errors
Does not seeOther people's libraries, server configurationErrors in your codeThe exact place in the code

Tools

SemgrepSonarQubeCodeQLBandit (Python)Brakeman (Ruby)SpotBugs + Find Security Bugs (Java)gosec (Go)

Questions and answers

How is SAST different from DAST?

SAST looks at source code without running it. DAST tests the running application from the outside. They find different classes of problems and complement each other.

Is one SAST scanner enough?

One engine has its own blind spots. Different analyzers are strong in different languages and vulnerability classes, so teams often run several together and merge the results, removing duplicates.

When should SAST run?

On every pull request or commit as a fast check of the changes, and regularly as a full scan of the whole repository.

What is static code analysis?

Checking a program from its source text without running it. In the broad sense it covers both code quality checks (linters) and vulnerability search. SAST is static analysis aimed specifically at security.

Does SAST work for mobile apps?

Yes. Analyzers check source code in Kotlin, Java, Swift, Objective-C and Dart. Typical mobile findings are insecure data storage on the device, disabled certificate validation and keys in code. Checks of the built APK or IPA are complemented by dynamic analysis and OWASP MASVS requirements.

Do I need SAST if I have SCA?

Yes. SCA checks third-party libraries and SAST checks your own code. SCA will not see a vulnerability in your team's code, and the reverse is also true.

SAST in TRAIO →