Why SAST, SCA, DAST and Container Scanning Matter

Picture a small team that ships a new feature on Friday. The code passes all unit tests. The demo looks great. On Monday, an attacker reads the full user table.

Where was the problem? It can be in four places. It can be in the code that your team wrote. It can be in a library that you downloaded. It can be in the server settings of the live app. Or it can be in the Docker image that runs the app.

Each place needs a different scan:

  • SAST reads your source code.
  • SCA checks the open source packages you use.
  • DAST attacks your running app from the outside.
  • Container scanning checks your Docker image and its operating system packages.

This is not a vendor pitch. One scan cannot see what the other scans see. In this post, you get a plain explanation of each scan, a small example, free tools to try, and a simple pipeline that uses all four.

Why does this matter more now? AI coding assistants write a large part of new code today. They write fast, but they can repeat old, unsafe patterns. They can also suggest old package versions, or package names that do not exist. Attackers now register those fake names. Automated scans catch these problems before a person must find them by hand.

Read OWASP Top 10 (2025) Explained: A Simple Guide for Developers

What is SAST? (Static Application Security Testing)

SAST reads your source code and finds security bugs before the code runs. Think of it as a spell checker for security. It does not start the app. It looks at the text of the code and at how data moves through it.

simple SAST example

Here is a small Python login query:

username = request.form["username"]
query = "SELECT * FROM users WHERE name = '" + username + "'"
cursor.execute(query)

The code adds user input directly into a SQL string. An attacker can type ' OR '1'='1 as the username. The query then returns every user. This is SQL injection.

A SAST tool sees that username comes from a web form. It also sees that the value goes into cursor.execute() with no change. The tool flags the line and gives you the file name and line number.

The fix is a parameterized query:

username = request.form["username"]
cursor.execute("SELECT * FROM users WHERE name = %s", (username,))

What SAST is good at

  • It finds bugs early, often in the editor or in the pull request.
  • It points to the exact line of code.
  • It finds hard-coded passwords and API keys.

What SAST cannot see

  • It cannot see bugs in libraries that you did not write.
  • It cannot see server settings, such as missing security headers.
  • It can give false positives. A person must check some findings.

Free tools to try: Semgrep, SonarQube Community Build, and CodeQL (free for public GitHub repos).

What is SCA? (Software Composition Analysis)

SCA checks the open source packages in your project against lists of known vulnerabilities (CVEs). Most modern apps contain more library code than team code. If one library has a known hole, your app has that hole too.

SCA reads files such as package.json, requirements.txt, pom.xml or go.mod. It also reads the lock files, because each package pulls in more packages. These hidden packages are transitive dependencies, and they are often where the risk is.

A simple SCA example

Here is part of a Java pom.xml file:

<dependency>
  <groupId>org.apache.logging.log4j</groupId>
  <artifactId>log4j-core</artifactId>
  <version>2.14.1</version>
</dependency>

The code of your app can be perfect. But this version of Log4j has Log4Shell (CVE-2021-44228). That bug let attackers run their own code on a server with one line of text in a log message. It became public in December 2021, and teams around the world worked through the holidays to find every copy.

An SCA tool flags this dependency in seconds. It tells you the CVE, the severity, and the safe version. Here, the fix is to update to version 2.17.1 or later.

Another real case: the 2017 Equifax breach used a known bug in Apache Struts. A patch was available about two months before the attack. SCA with an alert on that package can close a gap like this fast.

What SCA is good at

  • It finds known CVEs in direct and transitive dependencies.
  • It tells you which version fixes the problem.
  • It can check licenses, such as GPL code in a closed product.
  • It can make an SBOM (Software Bill of Materials), a full list of what is inside your app.

What SCA cannot see

  • It cannot find bugs in your own code.
  • It cannot find new bugs that are not yet on a CVE list.
  • It may miss OS packages inside your Docker image.

Free tools to try: OWASP Dependency-Check, GitHub Dependabot, npm audit, and pip-audit.

What is DAST? (Dynamic Application Security Testing)

DAST tests your app while it runs. It does not read the code. It acts like an attacker: it sends requests to the live app and studies the responses. SAST is a look at the blueprint. DAST is a test of the locked door.

A simple DAST example

Your team deploys a web app to a staging server. The code looks clean in SAST. Then you run a DAST scan against https://staging.example.com. The report shows three problems:

  1. The session cookie has no Secure and no HttpOnly flag. Malicious JavaScript can read it, and the browser can send it over plain HTTP.
  2. The server does not send a Content-Security-Policy header. This makes cross-site scripting (XSS) easier.
  3. An error page shows a full stack trace with the framework version.

None of these problems is in your source code. They come from server settings, framework defaults and the deployment. Only a scan of the running app can see them.

You can run a quick baseline scan with ZAP in one command:

docker run -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://staging.example.com

What DAST is good at

  • It finds runtime and configuration problems.
  • It works with any language, because it only talks to the app over HTTP.
  • It gives few false positives, because it shows real behavior.

What DAST cannot see

  • It cannot tell you which line of code causes the bug.
  • It runs late, because it needs a deployed app.
  • It misses pages that it cannot reach, such as pages behind a login, unless you configure it.

Important: Run DAST only against apps that you own or have written permission to test. Never point it at production without approval.

Free tools to try: ZAP and Nuclei. Burp Suite has a free Community Edition for manual testing.

What is container scanning?

Container scanning checks your Docker image for known vulnerabilities and bad settings. An image is more than your app. It contains a full operating system layer, system libraries, language runtimes and your packages. Each layer can bring its own CVEs.

A simple container scanning example

Here is a short Dockerfile:

FROM node:14
WORKDIR /app
COPY . .
RUN npm install
CMD ["node", "server.js"]

It looks harmless. But it has two problems:

  1. node:14 reached end of life in April 2023. It gets no more security fixes. The base image also brings a full Debian system with many old packages, such as OpenSSL and glibc.
  2. The app runs as root. If an attacker breaks into the app, they get root inside the container.

Scan the image with Trivy:

trivy image myapp:1.0

Trivy lists each CVE with the package name, the installed version and the fixed version. Most of the findings for this image come from the base image, not from your code.

Here is a safer version:

FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
USER node
CMD ["node", "server.js"]

The new image uses a supported Node.js version and a small Alpine base. It installs only production packages and runs as a normal user. A smaller image has fewer packages, so it has fewer places for CVEs to hide.

What container scanning is good at

  • It finds CVEs in OS packages that SCA often misses.
  • It finds bad settings, such as a root user or secrets in image layers.
  • It can scan images in your registry again when new CVEs appear.

What container scanning cannot see

  • It cannot find logic bugs in your own code.
  • It cannot see runtime attacks. That needs runtime security tools.

Free tools to try: Trivy, Grype, and Docker Scout (free tier).

SAST vs SCA vs DAST vs container scanning: quick comparison

Scan What it checks When it runs Needs a running app? Example finding
SAST Your own source code In the editor and on each pull request No SQL injection in a login query
SCA Open source packages and their dependencies On each pull request and every day No Log4j 2.14.1 with Log4Shell
Container scanning Docker image: OS packages, runtime, settings After the image build and in the registry No Old OpenSSL in a node:14 base image
DAST The live app from the outside On staging, after deployment Yes Session cookie without the Secure flag

An easy way to remember: SAST checks what you wrote. SCA checks what you borrowed. Container scanning checks what you packed. DAST checks what you shipped.

How all four scans work together in a CI/CD pipeline

The best plan puts each scan at the earliest point where it can work. People call this shift left security. A bug that you find in a pull request costs minutes to fix. The same bug in production can cost days and your users’ trust.

Here is a simple order:

  1. In the editor: A SAST plugin marks unsafe code while you type.
  2. On each pull request: SAST and SCA run automatically. The pipeline stops the merge on critical findings.
  3. After the image build: Container scanning checks the new image before you push it to the registry.
  4. On staging: DAST runs against the deployed app.
  5. Every day: SCA and container scanning run again on the main branch and on registry images. New CVEs appear every day, and code that was safe last week can be unsafe today.

A starter GitHub Actions workflow

This workflow runs SAST with Semgrep, then builds the image and scans it with Trivy. Trivy checks the OS packages and the language packages inside the image, so it also covers a large part of SCA.

name: security-scans
on: [pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: SAST with Semgrep
        run: pipx run semgrep scan --config auto --error

      - name: Build the image
        run: docker build -t myapp:${{ github.sha }} .

      - name: Container and dependency scan with Trivy
        uses: aquasecurity/trivy-action@master  # pin to a release tag in real projects
        with:
          image-ref: myapp:${{ github.sha }}
          severity: CRITICAL,HIGH
          exit-code: '1'

Add the ZAP baseline command from the DAST section to your deployment job for staging. Start with the scan in report mode. When the team trusts the results, make it block the release.

Common mistakes to avoid

  • Too many alerts on day one. If you block on every low finding, developers will ignore the tool. Start with critical issues and tighten later.
  • Scan once and forget. New CVEs appear after you ship. Schedule daily scans for dependencies and images.
  • Ignore the base image. In many images, most CVEs come from the base image, not from your app. Update it often.
  • No owner. A finding with no owner never gets fixed. Assign each one to a person or a team.
  • Trust AI-written code without a scan. Treat code from an AI assistant like code from a new team member. Review it and scan it.

Frequently asked questions

What is the difference between SAST and DAST?

SAST reads the source code without running it. DAST tests the running app from the outside, like an attacker. SAST finds bugs early and shows the exact line. DAST finds runtime and configuration problems that are not in the code.

Is SCA the same as SAST?

No. SAST checks the code that your team writes. SCA checks the open source packages that your app uses, and compares them with lists of known CVEs.

Do I need container scanning if I already use SCA?

Yes. SCA reads your package files. Container scanning also checks the operating system packages in the image, such as OpenSSL or glibc. These packages are not in your package.json or requirements.txt.

Which scan should a small team start with?

Start with SCA. It is easy to set up, it gives clear fixes, and many real attacks use known bugs in old packages. Add SAST next, then container scanning, then DAST.

Are free security scanning tools good enough?

For most small and medium teams, yes. Semgrep, OWASP Dependency-Check, Trivy and ZAP are widely used. Paid tools add dashboards, better triage and support. They are useful when you have many repositories.

Does AI-generated code need security scanning?

Yes. AI assistants can repeat unsafe patterns from old code. They can also suggest old package versions or package names that do not exist. Scan AI-written code the same way as human-written code.

Final thoughts

Security bugs hide in four places: your code, your packages, your image and your live app. SAST, SCA, container scanning and DAST each cover one of these places. If you skip one, you leave one door open.

You do not have to do everything this week. Turn on SCA today. Add SAST to your pull requests next week. Scan your images after that. Then add DAST on staging. In one month, your pipeline can catch most common problems before your users see them.

Which scan does your team use now, and which one is missing? Tell us in the comments. We read every one.