Bookmarks

SAST — Static Application Security Testing

A method for finding vulnerabilities in source code without running the program: the scanner parses the code and its data paths and finds typical weaknesses before build and release.

Also: static code analysis, static code security analysis, static code scanner

checked 9 Nov

All terms

SAST scans source code for vulnerabilities before the program is built and run. The scanner is built into CI and runs on every build, so the developer sees the weakness in their own branch rather than a tester after release. Alongside it comes DAST — analysis of a running application from the outside.

What it finds and what it misses

The scanner builds a model from the code — a syntax tree, a call graph and data-flow graphs — and looks for paths along which untrusted data reaches dangerous operations without validation.

Error classExample
Injectionsan SQL query assembled by concatenating a user-supplied string
XSSuser data ends up in HTML without escaping
Secrets in codeAPI keys and passwords hardcoded into the repository
Weak cryptographypassword hashing with MD5, outdated encryption modes
Missing access checksa handler writes to the database without checking user permissions

No execution takes place, so SAST does not find logic errors, environment misconfigurations or vulnerabilities in dependencies — dynamic analysis and SCA cover those.

Semgrep and CodeQL

Semgrep searches using rules that resemble code samples: a rule is written as a fragment of code with placeholders and metavariables, so a team can describe its own rule in minutes without studying the language’s internal representation. CodeQL works differently: it turns the repository into a database with a syntax tree and flow graphs, and finds complex data paths with SQL-like queries. Both tools support many languages and can trace the path of tainted data from source to sink.

yamlA Semgrep rule for finding SQL injection
rules:  - id: sql-injection-concat    message: SQL query built by concatenating an unchecked string    languages: [python]    severity: HIGH    patterns:      - pattern: $CURSOR.execute("..." + $X)

How it is used

SAST is placed in the pipeline alongside tests: a quick run on changed files, a full run on a schedule. Results are often emitted in SARIF format and labelled against the CWE weakness catalogue, while findings are triaged manually: static scanners produce many false positives, and they are tuned gradually, otherwise developers stop reading the reports.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

In depth in the references

where the topic is covered in detail