What is SAST (Static Application Security Testing)?
Static application security testing (SAST) analyses an application's source code, bytecode or binaries without running it, to find security flaws such as SQL injection, cross-site scripting, path traversal and hard-coded secrets. Because it reads the code directly, it can run early in development, often on every pull request, before the application is ever deployed.
SAST at a glance
| Question | Answer |
|---|---|
| What does it scan? | Your own source code (some tools also bytecode or binaries) |
| Does it run the app? | No. It reads the code |
| What does it find? | Injection, XSS, path traversal, unsafe deserialisation, weak cryptography, hard-coded secrets |
| When does it run? | In the IDE, on pull requests and in the build |
| Main weakness | False positives, and no view of runtime configuration |
| Complements | SCA for dependencies and DAST for the running app |
How SAST works
A SAST engine parses each file into a syntax tree and runs rules over it. Rules come in roughly three kinds, and the difference matters for how much you can trust a result:
| Rule kind | What it checks | Example | How much it proves |
|---|---|---|---|
| Text pattern | A risky string or call appears | A call to eval or a string that looks like a password | Little: it needs a person to look |
| Code structure | A risky construct in the syntax tree | A cookie created without the Secure flag | More: the construct is really there |
| Data flow (taint) | Untrusted input reaches a dangerous call without being cleaned | A request parameter flows into a SQL query | Most: it shows the path |
Data-flow analysis tracks sources (where untrusted input enters, such as request parameters), sinks (dangerous calls such as a database query or a shell command) and sanitisers (functions that make the input safe). A finding is raised when input can travel from a source to a sink without passing a sanitiser. Better engines follow that path from one function into another and across files.
What SAST finds
Most SAST findings map to a CWE and to an OWASP Top 10 category:
- Injection (SQL, command, LDAP, template): CWE-89, CWE-78
- Cross-site scripting: CWE-79
- Path traversal: CWE-22
- Unsafe deserialisation: CWE-502
- Weak or misused cryptography: CWE-327
- Hard-coded credentials and secrets: CWE-798
- Server-side request forgery: CWE-918
SAST vs DAST vs SCA
| SAST | DAST | SCA | |
|---|---|---|---|
| Tests | Your own source code | The running application, from outside | Third-party dependencies |
| Needs the app running? | No | Yes | No |
| Sees | Every code path, including ones tests never reach | Only what it can reach and exercise | Which components and versions you ship |
| Finds | Flaws in code you wrote | Exploitable behaviour and deployment problems | Known CVEs and licence issues |
| Typical noise | False positives | False negatives on unexplored paths | Long lists without exploit context |
They answer different questions, so mature teams run all three. See SBOM vs SCA for the dependency side.
Why SAST produces false positives
A pattern rule cannot tell a safe use from an unsafe one, so it flags both. When every match is reported as high severity, developers learn to ignore the report, and the one real injection path gets closed with the noise. Three practices help:
- Separate proven issues from things to review. A data-flow finding with a source-to-sink path is a different thing from a pattern hit, and should be labelled differently.
- Gate only on new findings. Fail the pull request for issues it introduces; work the existing backlog separately.
- Tune per repository. Suppress a rule with a recorded reason instead of switching the scanner off.
SAST and programming languages
Language support is where SAST tools differ most. A tool can "support" a language with a handful of text patterns or with full data-flow analysis, and the results are not comparable. When you evaluate a tool for Java, Kotlin, Scala, C#, PHP or any other language, ask:
- Does it have data-flow rules for this language, or only patterns?
- Does it understand the frameworks you use (for example Spring, Django, Express or Laravel), so it knows where input enters?
- Does it follow data across files?
How to add SAST to a pipeline
- Run it on every pull request, scanning the changed code, and comment findings inline.
- Block merges only on new high-confidence issues.
- Run a full scan of the default branch on a schedule to catch rules added since.
- Scan for secrets in the same pass; a leaked key is often the fastest way in.
- Track mean time to fix, not the size of the backlog.
How Onam approaches SAST
Onam Code Security runs Onam's own static analysis engine over C, C++, C#, Go, Java, JavaScript, TypeScript, Kotlin, PHP, Python, Ruby, Scala and Swift. Data-flow rules follow untrusted input across functions and files within a repository, and results are split into security issues the engine can show and hotspots a person should confirm, each with its CWE and OWASP category. Secret detection runs in the same pass. One honest limit: C and C++ get code-structure and pattern rules only, without data-flow analysis, and Rust is not analysed yet.
Frequently asked questions
What is SAST?
SAST (static application security testing) analyses source code, bytecode or binaries without running the application, to find security flaws such as SQL injection, cross-site scripting, path traversal and hard-coded secrets early in development.
What is the difference between SAST and DAST?
SAST reads the source code without running it and can see paths tests never reach, but it produces false positives. DAST attacks the running application from outside and finds what is really exploitable, but only on the paths it manages to exercise. They complement each other.
What is the difference between SAST and SCA?
SAST looks for flaws in the code your team wrote. SCA (software composition analysis) looks at the open-source and third-party components you depend on and matches them against known vulnerabilities and licence rules.
Why does SAST have so many false positives?
Pattern rules cannot tell a safe use of a risky call from an unsafe one, so they flag both. Tools that separate data-flow findings (with a source-to-sink path) from pattern matches, and pipelines that gate only on new issues, keep the noise manageable.
When should SAST run?
On every pull request for the changed code, with a scheduled full scan of the main branch. Running it in the IDE as well catches issues before they are committed.
What is taint analysis in SAST?
Taint analysis tracks untrusted input from where it enters the application (a source) to a dangerous operation (a sink), and raises a finding when the input arrives without passing through a sanitiser. It is the most reliable kind of SAST rule.