Cloud & app security

Static Application Security Testing (SAST): A Practical Guide

SAST reads your code before it runs and points to the exact file and line where a flaw lives. Used well, it catches injection and secrets early — used badly, it drowns you in false positives.

Cysoro Security TeamPublished · 9 min read
if (userInput) { query(db, input); // SQL injection}! CLOUD & APP SECURITY Static appsecurity testing Find flaws before code runs.
Quick answer

Static application security testing, or SAST, is a white-box method that analyzes source code, bytecode or binaries for security flaws without running the application. It builds a model of the code, tracks untrusted data from sources to dangerous sinks, and reports the file and line where a flaw may exist. It finds injection, cross-site scripting, hardcoded secrets and weak cryptography early, but it cannot see runtime, configuration or business-logic flaws on its own.

Key takeaways

  • SAST scans code without running it, so it finds flaws early and points to the exact file and line.
  • It is strong on injection, cross-site scripting, secrets and weak cryptography, and weak on runtime and access-control flaws.
  • Run it in the IDE and in CI, triage by severity and reachability, and pair it with DAST, SCA and manual review.

Most security flaws are written into code long before anyone runs the application. Static application security testing finds them while the code is still on a developer's screen, with the file and line number attached, so fixing them is cheap and fast.

What is static application security testing?

Static application security testing, or SAST, is a white-box method that analyzes source code, bytecode or binaries for security flaws without running the application. It examines how data flows through the code and flags patterns that could become vulnerabilities.

OWASP describes SAST tools as tools that analyze source code or compiled versions of code to help find security flaws. The method is also called static code analysis, and it fits early in development, in the editor, on pull requests and in CI/CD pipelines.

Read the OWASP Developer Guide on static analysis for the vendor-neutral definition and limits used in this article.

Code flaws are only one part of application security. Our guide to AI intrusion detection systems explains how teams detect attacks on running systems.

SAST does not run your code, so it needs no test environment, no database and no login. That makes it fast to run and easy to add to a pipeline, but it also means it cannot see what happens at runtime, which is why it is one layer, not the whole program.

How does SAST work?

SAST builds a model of your code, tracks untrusted data from sources to dangerous sinks, and reports paths where that data reaches a sensitive operation without proper validation. The report names the file, line and code snippet involved.

Taint analysis: follow untrusted data to the sinkSourceuser input,HTTP, file, envPropagationthrough functionsand variablesSanitizer?validation orencoding?SinkSQL,HTMLIf untrusted data reaches a sink without a sanitizer, SAST flags it as a possible flaw.If a sanitizer is present on the path, the tool should not flag it.
How SAST uses taint analysis to track untrusted data. Illustration by Cysoro.

First, the tool parses the code into an abstract syntax tree, which is a structured map of functions, variables and calls. Some tools also build a control-flow graph and a data-flow graph, so they can follow how values move and change.

Next, it applies rules. Pattern rules look for known risky code, such as a hardcoded password, a weak hash, or a dangerous function. Taint rules track a value from a source, such as user input, to a sink, such as a database query or HTML output, and check whether a sanitizer sits on the path.

Finally, it reports findings with severity, the CWE identifier, and the location. A good report also shows the data-flow path, so a developer can see why the tool flagged the code and decide whether it is a real flaw or a false positive.

What vulnerabilities does SAST find?

SAST is strong on flaws that show up as code patterns: SQL injection, cross-site scripting, command injection, hardcoded secrets, weak cryptography and dangerous API use. These are the flaws that follow a recognizable shape in source code.

The MITRE CWE Top 25 for 2025 ranks cross-site scripting, or CWE-79, first and SQL injection, or CWE-89, second. Both are classic SAST findings, because both happen when untrusted input reaches a query or a page without proper handling.

SAST also finds secrets in code, such as API keys and passwords, and weak cryptography, such as MD5, DES or a hardcoded encryption key. Those are simple to spot, because the risky value sits in the source itself.

It is weaker on business-logic flaws. Broken access control, the top category in the OWASP Top 10, often depends on what a user should be allowed to do, not on a code pattern. A tool can flag a missing check, but it cannot know your business rules without help.

Flaw typeSAST finds it?ExampleOWASP Top 10
SQL injectionYes, wellUser input in a queryA03 Injection
Cross-site scriptingYes, wellInput reflected in HTMLA03 Injection
Hardcoded secretsYes, wellAPI key in source codeA07 Identification failures
Weak cryptographyYes, wellMD5, DES, weak randomA02 Cryptographic failures
Broken access controlPartlyMissing check on an objectA01 Broken access control
Security misconfigurationPartlyDebug mode left onA05 Misconfiguration
Business logic flawsPoorlyPrice changed in a requestA04 Insecure design

Use this table to set expectations. If your main risk is access control or business logic, SAST alone will not cover it, and you need manual review and penetration testing as well.

SAST vs DAST vs SCA: what is the difference?

SAST, DAST and SCA test different things at different times. SAST scans code without running it, DAST tests a running application from the outside, and SCA checks third-party dependencies for known vulnerabilities.

MethodWhat it analyzesRuns the code?WhenWhat it finds best
SASTSource, bytecode, binariesNoIDE, pull request, CIInjection, secrets, weak crypto
DASTRunning applicationYesTest or stagingRuntime, config, auth flaws
SCADependency manifestsNoCI, on changeKnown CVEs in libraries
IASTRunning code with agentsYesTestRuntime flaws with code location
Manual reviewCode and designNoReview, auditLogic and access control

DAST finds flaws SAST cannot see, such as missing security headers, weak session handling and configuration errors in a deployed app. You can check headers yourself with the free security headers checker to see what DAST would notice first.

SCA finds flaws SAST cannot see either, because SAST looks at your code, not at the libraries you import. A library with a known CVE is a real risk even if your own code is clean, so SCA belongs in the same pipeline as SAST.

The three methods overlap a little, but they do not replace each other. A team that runs only SAST will miss runtime and dependency flaws, while a team that runs only DAST will miss code flaws that never trigger in a test run.

What are the benefits of SAST?

SAST gives early feedback, exact locations, and coverage of the whole codebase, including code paths that tests never run. A developer can fix a flaw in minutes while the code is still fresh, instead of weeks later after deployment.

Early fixes are cheaper. A flaw found in the editor costs far less to fix than the same flaw found in production, where it needs a patch, a release and a customer notice. SAST shifts that discovery left, into development, where fixes are routine.

SAST also scales. It can scan a large codebase in minutes, check every pull request, and enforce a quality gate that blocks a merge when a critical flaw appears. That consistency is hard to get from manual review alone.

Finally, SAST helps with compliance and audits. Many standards ask for code analysis, and a SAST report with severity, CWE and location gives auditors a clear record of what was checked and what was fixed.

What are the limits of SAST?

SAST has clear limits: false positives, missed flaws, no runtime view, and difficulty with code that cannot be compiled or with missing libraries. OWASP is direct about these limits, and teams that ignore them lose trust in the tool.

  • False positives. Many findings look risky but are not exploitable, because sanitization happens elsewhere or the path cannot run. Triage is essential.
  • False negatives. OWASP notes that current tools can automatically identify only a relatively small percentage of application security flaws.
  • No runtime view. SAST cannot find configuration issues, authentication problems that only appear when running, or flaws in deployed infrastructure.
  • Access control and logic. It struggles with authentication, access control and insecure use of cryptography that depends on context.
  • Build problems. Some tools need code that compiles, with the right libraries and build instructions, or they miss large parts of the codebase.
  • Language coverage. A tool may support one language well and another poorly. Check coverage for your stack before you commit.

The fix is not to drop SAST, but to tune it. Disable rules that always fire falsely, add custom rules for your frameworks, and focus on high-severity, reachable findings first. A tuned tool with 20 real findings beats an untuned tool with 2,000 noisy ones.

How do you use SAST in practice?

Run SAST in three places: in the IDE for instant feedback, on pull requests for review, and in CI/CD as a quality gate. Start with a small, high-confidence rule set, then expand as your team learns to triage.

  1. Start in the IDE. Install the SAST plugin for your editor, so developers see flaws as they type. This is the fastest feedback loop.
  2. Add it to pull requests. Scan each pull request and show new findings in the review, not just a long list of old ones.
  3. Add a CI gate. Block merges on new critical or high-severity findings, but allow the build to pass on low-severity noise while you tune.
  4. Triage by severity and reachability. Fix critical injection and secrets first, then high-severity flaws in code that handles user input.
  5. Fix, do not just suppress. Suppress a finding only with a reason, an owner and an expiry date, so it does not hide forever.
  6. Measure and tune monthly. Track how many findings are real, how long fixes take, and which rules produce the most false positives.

For a small team, start with a free tool. Semgrep's open-source engine runs with one command, semgrep --config auto ., and pulls in community rules covering the OWASP Top 10 and CWE Top 25. SonarQube Community Build is another free starting point that adds code quality checks.

For larger teams, look at paid tools such as Snyk Code, Checkmarx or Veracode, which add deeper data-flow analysis, dashboards and support. A 2026 comparison lists Semgrep Team at $35 per contributor per month and Snyk Code at $25 per developer per month, with free tiers for small use. Confirm current pricing on the vendor site before you budget.

Where SAST fits in the pipeline1IDEinstant feedbackas you type2Pull requestnew findingsin review3CI / CD gateblock criticalnew flaws4Deploywith DASTand SCA tooThe earlier you catch a flaw, the cheaper it is to fix.
SAST in the IDE, on pull requests and in CI/CD. Illustration by Cysoro.

How do you choose a SAST tool?

Choose by language coverage, speed, false-positive rate, CI integration and output format, not by marketing claims. Trial two tools on your own code and compare the findings you can actually fix.

  • Language coverage. Does it support your main languages well, including frameworks you use every day?
  • Speed. Can it scan a pull request in minutes, not hours, so developers do not wait?
  • False positives. Run it on your code and count how many findings are real. A fast tool with 90 percent noise is worse than a slower, accurate one.
  • Integration. Does it work in your IDE, pull requests and CI, and send results in SARIF, the standard format for static analysis output?
  • Custom rules. Can you write rules for your own frameworks, APIs and secrets, and version-control them?
  • Cost. Free tools such as Semgrep and SonarQube Community suit small teams, while enterprise tools suit large, regulated programs.

Also check how the tool handles AI-generated code. Generated code needs the same SAST scan as human code, and a tool that explains its findings in plain language helps developers fix generated flaws they did not write themselves.

The bottom line

Static application security testing is the earliest, cheapest way to find code flaws, and it belongs in every team's pipeline. It will not catch everything, and it will flag some things that are not real, but a tuned SAST setup with DAST and SCA beside it catches far more than any one method alone.

Start this week: run a free SAST scan on one repository, fix the critical findings, and add the scan to your pull requests. You can also check the deployed side of the same app with the free security headers checker to see what a runtime test would find next.

Frequently asked questions

What is static application security testing?

Static application security testing, or SAST, analyzes source code, bytecode or binaries for security flaws without running the application. It looks for code patterns and data flows that could lead to a vulnerability, and reports the file and line where the flaw sits.

What is the difference between SAST and DAST?

SAST analyzes code without running it, early in development, and points to the exact line. DAST tests a running application from the outside, by sending requests and watching responses. SAST finds code flaws, while DAST finds runtime and configuration flaws.

What vulnerabilities does SAST find?

SAST finds injection flaws such as SQL injection and cross-site scripting, hardcoded secrets, weak cryptography, dangerous APIs and insecure data flows. It is less good at business-logic flaws, broken access control and configuration issues.

Why does SAST produce so many false positives?

SAST tools use rules and models that cannot always tell whether a flagged pattern is actually reachable or exploitable. They flag code that looks risky, even when sanitization happens elsewhere or the code path cannot run. Tuning rules and checking reachability cuts the noise.

When should you run SAST?

Run SAST in the IDE while you write code, on pull requests for review, and in CI/CD before merging or deploying. Early runs give the fastest feedback, while CI runs enforce a quality gate for the whole team.

Is SAST enough on its own?

No. SAST is one layer. It misses runtime flaws, configuration issues, vulnerable dependencies and business-logic problems. Pair it with DAST for runtime testing, SCA for dependencies, and manual review or penetration testing for logic flaws.

What are the best SAST tools?

Common tools include Semgrep and SonarQube for open-source and team use, Snyk Code for developer-friendly scanning, GitHub CodeQL for deep semantic analysis, and Checkmarx and Veracode for enterprise programs. The best tool depends on your languages, CI setup and budget.

Does SAST work with AI-generated code?

Yes, and it matters more with AI-generated code, because generated code can contain the same flaws as human code, faster and at larger scale. Run SAST on every AI-generated change, and review the findings, because the model that wrote the code does not check it for security.

Sources

  1. OWASP Developer Guide — Static Application Security Testing
  2. OWASP — Source Code Analysis Tools
  3. Endor Labs — What Is SAST? Static Analysis in the Age of AI-Generated Code
  4. MITRE CWE — 2025 CWE Top 25 Most Dangerous Software Weaknesses
  5. Dev.to — 11 Best SAST Tools in 2026
Written & fact-checked byCysoro Security Team

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.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the OWASP Developer Guide on static analysis, OWASP source code analysis guidance and the MITRE CWE Top 25.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free