Dynamic Application Security Testing (DAST)

The Authentication Bypass SAST Never Found

February 14, 2021. Valentine's Day. The day someone sent us "love" in the form of a security disclosure.

Subject: "Your admin panel has no authentication on staging"

I laughed. Impossible. Our staging environment required authentication. I had implemented it myself.

Then I clicked the link: https://staging.example.com/admin?debug=true

My stomach dropped. Full admin access. No authentication required. A simple query parameter bypassed all auth checks.

The code:

// middleware/auth.ts
export function requireAuth(req, res, next) {
  // Skip auth in debug mode for easier testing
  if (req.query.debug === 'true') {
    return next();  // ❌ MASSIVE VULNERABILITY
  }
  
  // ... normal auth checks
}

This code had passed:

  • βœ… SAST scans (no code-level vuln)

  • βœ… Unit tests (debug mode worked as designed)

  • βœ… Code review (looked reasonable for staging)

What failed? Nobody tested the running application with a security mindset.

That's what DAST does. It attacks your running application like a real attacker would, finding vulnerabilities that only appear at runtime.

This article documents how we integrated DAST into our pipeline and caught 47 runtime vulnerabilities that SAST never detected.

What You'll Learn

  • DAST fundamentals and how it differs from SAST

  • Integrating OWASP ZAP into CI/CD pipelines

  • Authenticated scanning for protected endpoints

  • Managing and prioritizing DAST findings

  • DAST for APIs and microservices

  • Performance optimization for fast feedback

What is DAST?

Dynamic Application Security Testing analyzes running applications by sending requests and analyzing responsesβ€”like an attacker would.

SAST vs DAST Comparison

spinner

Key Insight: Use both. SAST finds potential issues in code; DAST confirms they're exploitable in production.

Setting Up DAST: OWASP ZAP

We use OWASP ZAP (Zed Attack Proxy) - free, open-source, powerful.

Basic ZAP Scan in GitLab CI/CD

Custom ZAP Scan with Docker

For more control, run ZAP directly:

Authenticated Scanning

Most applications require authentication. ZAP needs to authenticate to test protected endpoints.

Method 1: Form-Based Authentication

Run with config:

Method 2: JWT Token Authentication

For API-first applications:

If you have a long-lived session:

Real Vulnerability Examples

Example 1: Authentication Bypass (The Valentine's Day Gift)

Vulnerability: Debug parameter bypasses authentication

ZAP Finding:

Fixed Code:

Example 2: Insecure Direct Object Reference (IDOR)

Vulnerability: Users can access other users' orders

ZAP Finding:

Vulnerable Code:

Fixed Code:

Example 3: Missing Security Headers

ZAP Finding:

Fixed with Helmet.js:

Example 4: SSL/TLS Configuration Issues

ZAP Finding:

Fixed (Nginx):

API Security Testing with ZAP

Modern applications are API-first. ZAP can scan APIs using OpenAPI/Swagger specs.

OpenAPI/Swagger Scan

GraphQL API Scan

Optimizing DAST Performance

DAST scans are slow. Our optimization strategies:

1. Scan Depth Configuration

2. Scope Limiting

Only scan changed areas:

3. Scheduled Comprehensive Scans

Managing DAST Findings

Risk Prioritization

Suppressing False Positives

Real Results

Findings (First 6 Months)

Impact

Key Takeaways

βœ… DAST finds runtime vulnerabilities SAST can't detect βœ… Authenticated scanning essential - most vulnerabilities behind login βœ… Combine SAST + DAST for comprehensive coverage βœ… Optimize scan depth - fast scans for MRs, comprehensive for main βœ… API scanning critical for microservices architectures βœ… Security headers easy to fix, high impact βœ… Run DAST in staging - never scan production without permission

What's Next

SAST finds code-level issues. DAST finds runtime issues. But what about the hybrid approach? The next article covers IAST (Interactive Application Security Testing) and Runtime Application Self-Protection (RASP)β€”security testing that combines the best of both worlds.


Next Article: IAST and Runtime Protection β†’arrow-up-right


Part of the DevSecOps 101 Series

Last updated