Definition
SAST (static application security testing) analyzes the source code your team writes for security bugs such as injection or unsafe deserialization. SCA (software composition analysis) inventories the third-party components you depend on and matches them against databases of known vulnerabilities and licenses. They cover different code, so most teams run both.
SAST and SCA compared
| SAST | SCA | |
|---|---|---|
| Looks at | Your own source code | Third-party packages, from manifests and lockfiles |
| Method | Parses the code and follows data flow | Looks up each package version in advisory databases |
| Finds | New bugs: SQL injection, XSS, path traversal, hard-coded secrets | Known vulnerabilities (CVEs), license problems, outdated packages |
| Typical false alarm | A flow that cannot happen at run time | A vulnerable function your code never calls |
| Examples | Semgrep, CodeQL, SonarQube, Checkmarx | npm audit, Dependabot, OSV-Scanner, Trivy, Snyk Open Source |
A third category, DAST (dynamic application security testing), tests the running application from the outside.
When to use each
- SAST on each pull request, for the code your team changes.
- SCA on each lockfile change and on a schedule, because new advisories appear for versions you already ship. Reachability analysis reduces the noise.
The gap between them
Most of the code in an application is third-party code. SAST does not read it, because it is not yours. SCA does not read it either: it compares names and versions with a list. So a dependency with malicious code that nobody has reported yet passes both.
That is the area of package malware detection: reading the dependency's source for install-time payloads, credential theft, exfiltration and backdoors. Togoder Security does this with an AI review of each file of each package in a lockfile, and publishes the results as public reports. See npm malware scanners compared.
Frequently asked questions
Do I need both SAST and SCA?
Yes, in most projects. SAST finds bugs in the code you write and SCA finds known vulnerabilities in the components you use. Neither covers the other's area.
Is SCA a type of SAST?
No. Both are static, because neither runs the application, but SCA is a lookup of component versions in vulnerability databases, while SAST analyzes the logic of your own code. Vendors often sell both in one platform.
Does SAST or SCA detect malicious packages?
SCA flags a malicious package only after it is reported and has an advisory. SAST normally does not scan dependencies at all. Unreported malware requires a tool that reads the dependency's source.