SAST, or Static Application Security Testing, is a white-box testing method that analyzes source code, bytecode, or binaries for security vulnerabilities without executing the program. It parses code, traces how untrusted data flows through it, and flags patterns such as SQL injection, hardcoded secrets, and weak cryptography. It runs early — in the IDE or on every pull request — but cannot see runtime behavior, so it complements DAST and SCA rather than replacing them.
Key takeaways
- SAST reads source code without running it, finding injection, hardcoded secrets, and weak crypto before code reaches production.
- It works by parsing code and tracing untrusted data from its source to where it is used — the earlier it runs, the cheaper the fix.
- SAST cannot find runtime issues, business-logic flaws, or vulnerable third-party libraries, so pair it with DAST and SCA.
Most security testing waits until software is built and running. SAST does not. It reads the code while it is still being written and flags the flaws attackers would find later — when fixing them costs far more. If your team ships code without a static scan, the first person to read it carefully may be an attacker.
What is SAST?
SAST stands for Static Application Security Testing. It is a white-box testing method that analyzes source code, bytecode, or binaries for security vulnerabilities without executing the program. OWASP describes it as a technique that lets you analyze and detect potential security issues in your code, early in the development lifecycle.
The word "static" is the key. The scanner never runs your application. Instead, it reads the code the way a careful reviewer would — following how data moves, checking which functions are called, and comparing patterns against rules for known weakness classes such as the OWASP Top 10 and CWE.
SAST is also called static analysis or source code analysis. OWASP's developer guide notes that these tools can be added into your IDE, so developers get feedback while they are still writing the code.
That early feedback is the whole point: a flaw found in the IDE costs minutes to fix, while the same flaw found in production costs a hotfix, a release, and possibly an incident.
How does SAST work?
A SAST scan runs in four stages. Understanding them explains both what the tool is good at and why it sometimes cries wolf.
1. Parse. The tool turns source code into an abstract syntax tree, a structured model of functions, variables, and control structures. Some tools work from bytecode or compiled binaries instead, which is useful when source is not available.
2. Map control flow. The tool builds a map of every path execution can take — branches, loops, and function calls — so it can reason about code that only runs in certain conditions.
3. Trace data flow. This is the clever part. Taint analysis tracks untrusted data from its source, such as a web form field or an API parameter, through the code to the sink where it is used, such as a database query. If user input reaches a SQL query without sanitization, that is SQL injection.
4. Match rules. Detection rules encode patterns for known weakness classes, mapped to catalogs such as the OWASP Top 10 and CWE. A match produces a finding with a category, a severity, and the exact file and line number — which is why OWASP notes that SAST output helps developers, since it highlights the problematic code by filename, location, line number, and even the affected snippet.
What vulnerabilities does SAST find?
SAST is strongest at flaws that show up as patterns in code. The classic example is SQL injection: user input flows straight into a database query with no sanitization. A scanner flags it the moment the code is written, with the file and line number attached.
- Injection flaws. SQL injection, cross-site scripting, command injection, and LDAP injection — anywhere untrusted input reaches a sensitive operation.
- Hardcoded secrets. Passwords, API keys, and tokens written directly into source code, where anyone with repository access can read them.
- Weak cryptography. MD5 or SHA-1 used for security-sensitive purposes, DES or RC4, ECB mode, hardcoded keys, and disabled certificate verification.
- Insecure functions. Known-dangerous functions, deprecated libraries, and unsafe deserialization of untrusted data.
- Broken access control in code. Missing authorization checks on sensitive operations, where the code never verifies the caller is allowed to do what they asked.
- Data exposure. Sensitive data logged in plain text, error messages that leak internals, or HTTP used where HTTPS is required.
Rules are usually mapped to the OWASP Top 10, so a finding arrives with a category your team already recognizes. That mapping also makes SAST useful for compliance evidence: a clean scan report, with triaged findings, is a concrete artifact for audits.
SAST vs DAST vs SCA: what's the difference?
SAST, DAST, and SCA are not alternatives — they read different material at different moments, and the gaps of one are the coverage of another. A complete application security program uses all three.
| SAST | DAST | SCA | |
|---|---|---|---|
| What it reads | Your source code | A running application | Third-party dependencies |
| Method | White-box, inside-out | Black-box, outside-in | Inventory vs known CVEs |
| When it runs | IDE, pull request, CI | Staging, before release | Every dependency update |
| Finds | Injection, secrets, weak crypto | Auth bypass, missing headers, session flaws | Known vulnerabilities in libraries |
| Misses | Runtime and config issues | Code flaws not triggered in tests | Flaws in your own code |
| False positives | Higher | Lower | Low |
| Needs source? | Yes | No | No, needs manifests |
DAST attacks a running application from the outside with no access to the code, simulating what an attacker sees: it sends malformed input, checks response headers, and walks login flows. It finds the things SAST cannot — misconfigurations, session bugs, and authentication bypasses that only exist once the app is deployed.
SCA inventories third-party components and matches them against known vulnerabilities. Since most modern applications are mostly third-party code, SCA covers the largest share of the codebase by volume — but it never looks at the code your team wrote, which is exactly what SAST reads.
You can check the deployed side of the equation with our free security headers checker, which tests a live site for the headers DAST tools look for.
What are the benefits of SAST?
SAST earns its place in the pipeline for four reasons, and the first one is the most important.
- Early detection. SAST runs from the first commit, before the application exists as a running system. It is the only technique that reads the code your team wrote before anyone else does.
- Exact locations. Findings come with file, line, and snippet, so developers can fix them without a security engineer translating the report.
- Fast feedback. A scan runs in seconds to minutes on a pull request, so it fits into CI without slowing the team down.
- Consistent enforcement. Rules apply the same way to every pull request, every developer, and every repository — no reviewer fatigue, no skipped checks.
- Secure coding education. Developers who see the same finding explained three times stop writing that pattern, which is the real long-term win.
What are the limitations of SAST?
SAST is powerful, but it is not a security program on its own. OWASP is blunt about this: current SAST tools can automatically identify only a relatively small percentage of application security flaws, and they do not replace manual review or other testing techniques.
- False positives. With no runtime context, SAST must guess whether a flagged pattern is exploitable. A query that looks injectable may be safe because the input is validated in another function the scanner could not follow. Triage is real work.
- False negatives. Code the scanner cannot parse, frameworks it does not understand, and flaws that only appear when components interact will all slip through.
- No runtime visibility. SAST cannot see race conditions, misconfigurations, authentication flows, or how services behave in production. It will not find a missing security header or a broken session timeout.
- No business-logic understanding. A discount applied twice, a user reading another tenant's invoice, or a workflow that skips an approval step are all invisible to a pattern-matching scanner.
- Language and framework dependence. A tool only works for the languages it supports, and its rules must be kept current as frameworks change.
A clean SAST run is not a security sign-off. It means the scanner found no matching patterns — which is a useful fact, but a long way from "this application is secure."
How do you implement SAST in a CI/CD pipeline?
Rolling out SAST is a process change as much as a tool purchase. Teams that succeed follow the same sequence.
- Start in the IDE. Give developers a scanner in their editor first, so they see findings while writing code. This builds trust before any gate blocks a merge.
- Scan on every pull request. Run the scan in CI and post results as review comments, with file and line links. Keep it advisory at first — no blocking — until the team trusts the signal.
- Set a baseline. Scan the existing codebase, triage the backlog once, and record it as the baseline. New code must be clean; old findings get fixed on a schedule, not all at once.
- Gate on new critical findings. Once false positives are under control, block merges that introduce new critical or high-severity findings. Keep the gate narrow: blocking on everything guarantees developers will route around the tool.
- Scan on a schedule too. Rules improve over time, so run a full scan nightly or weekly against the main branch to catch what new rules find in old code.
- Feed results into the backlog. Findings should become tracked work items with owners and due dates, not a report that sits in a dashboard nobody opens.
For small teams, the lightest version of this is a free tool such as Semgrep in CI plus CodeQL on public repositories. The tool matters less than the habit: every pull request scanned, every new critical finding fixed or explicitly accepted.
How do you handle SAST false positives?
False positives are the number one reason teams abandon SAST, so treat them as a process problem, not a tool problem.
Tune the ruleset. Start with the rules that match your stack and your risk, and disable rules that fire constantly on safe patterns. A smaller, trusted ruleset beats a large, noisy one.
Triage quickly and visibly. When a developer marks a finding as a false positive, record why — "input validated in sanitize() at line 42" — so the next person does not re-investigate the same pattern.
Use data-flow analysis. Tools that trace taint from source to sink produce far fewer false positives than simple pattern matchers, because they check whether the dangerous input actually reaches the dangerous operation.
Measure the rate. Track the share of findings that turn out to be real. If it drops below about one in three, the ruleset needs tuning or the team will stop reading the results.
Which SAST tool should you choose?
OWASP lists selection criteria that still hold up: support for your programming language comes first, then detection ability against the OWASP Top 10, accuracy in terms of false positive and false negative rates, OWASP Benchmark score, license cost, and output format — ideally SARIF, the standard format for static analysis results.
Open-source options include Semgrep, which is lightweight and pattern-based and covers many languages; CodeQL, which powers GitHub code scanning and is free for public repositories; SonarQube Community, which combines security rules with code quality checks; and Brakeman for Ruby on Rails.
Commercial options include Checkmarx, Fortify, and Veracode, which offer deeper analysis, broader language coverage, and support contracts. They suit larger teams and regulated environments where audit evidence and vendor support matter.
Do not pick a tool on a benchmark score alone. Run two or three candidates against your own codebase for two weeks and compare the findings on your code, in your frameworks, with your developers doing the triage.
The tool with the best results on someone else's benchmark may not be the best on yours. OWASP maintains a list of source code analysis tools with licenses and language support to start from. And confirm the deployed side is covered too — our free SSL checker verifies the certificate and TLS configuration of a live site, which no SAST tool can see.
Does SAST help with compliance?
Yes, and for many teams that is the reason the budget appears. Secure development standards increasingly expect static analysis as part of the build: PCI DSS requires code review or automated scanning for payment applications, and frameworks such as OWASP SAMM list security testing as a core practice.
SAST reports also serve as audit evidence. A scan history showing that every release was scanned, with findings triaged and criticals fixed before deployment, is a concrete artifact an auditor can check. Keep the reports, keep the triage decisions, and keep the policy that defines which severities block a release.
That said, compliance is a floor, not a goal. A scanner configured to satisfy an audit checkbox — run once a year, findings never triaged — delivers no security at all. The value comes from running it on every pull request and acting on what it finds.
The bottom line
SAST is the earliest and cheapest security test you can run: it reads the code your team wrote and flags the flaws that would otherwise reach production. It finds injection, hardcoded secrets, and weak crypto with exact file and line numbers, and it runs fast enough to sit on every pull request.
It is not enough on its own. Pair it with DAST for the running application and SCA for third-party libraries, keep the rules tuned so developers trust the results, and treat a clean scan as a good start rather than a clean bill of health. If you want the broader picture, our small business cybersecurity checklist covers application security alongside backups, updates, and device security.
Frequently asked questions
What does SAST stand for?
SAST stands for Static Application Security Testing. It is also called static analysis or source code analysis, because it examines source code, bytecode, or compiled binaries without executing the program.
What is the difference between SAST and DAST?
SAST is white-box testing that reads your source code before the application runs, while DAST is black-box testing that attacks a running application from the outside. SAST finds code-level flaws early; DAST finds runtime issues such as broken authentication and missing security headers.
Does SAST replace penetration testing?
No. SAST finds code patterns automatically, but OWASP notes that current SAST tools can automatically identify only a relatively small percentage of application security flaws. Penetration testing and manual code review find business-logic flaws and chained attacks that no scanner catches.
When should SAST run in the development process?
As early as possible. OWASP's developer guide says SAST can run locally in the IDE, and can also be configured on push, on pull request, or in CI/CD pipelines. Running it on every pull request gives developers feedback before the code is merged.
What vulnerabilities does SAST find?
Common findings include SQL injection, cross-site scripting, hardcoded credentials and secrets, weak or broken cryptography, insecure deserialization, and the use of known-dangerous functions. Rules are usually mapped to the OWASP Top 10 and the CWE catalog.
Why does SAST produce false positives?
SAST has no runtime context, so it must guess whether a flagged pattern is actually exploitable. A query that looks injectable may be safe because the input is validated elsewhere. Tuning rules, triaging findings, and using data-flow analysis reduce the noise.
Is SAST free?
There are free and open-source SAST tools, including Semgrep, CodeQL for public repositories, and SonarQube Community, as well as commercial tools such as Checkmarx, Fortify, and Veracode. OWASP maintains a list of source code analysis tools with their licenses and language support.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the OWASP Developer Guide on SAST, OWASP's Source Code Analysis Tools page, and the OWASP DevSecOps Guideline.
How we write and fact-check →