Dynamic Testing & Runtime Security

Runtime Application Self-Protection (RASP)

3 min read

RASP protects applications from within during runtime. Unlike WAFs that sit in front of your app, RASP instruments the application itself to detect and block attacks.

How RASP Works

Traditional WAF:
┌─────────┐     ┌─────────┐     ┌─────────────┐
│ Request │ ──▶ │   WAF   │ ──▶ │ Application │
└─────────┘     └─────────┘     └─────────────┘
              (Pattern matching)

RASP:
┌─────────┐     ┌───────────────────────────────┐
│ Request │ ──▶ │ Application                   │
└─────────┘     │  ┌─────────────────────────┐  │
                │  │ RASP Agent (Embedded)   │  │
                │  │ • Monitors execution    │  │
                │  │ • Blocks attacks        │  │
                │  │ • Has runtime context   │  │
                │  └─────────────────────────┘  │
                └───────────────────────────────┘

RASP vs WAF

AspectWAFRASP
PositionNetwork perimeterInside application
ContextHTTP layer onlyFull runtime context
False positivesHigherLower
Bypass resistanceLowerHigher
Performance impactLowMedium
DeploymentNetwork configCode/agent integration
VisibilityLimitedComplete

What RASP Protects Against

Attack TypeHow RASP Detects It
SQL InjectionMonitors database driver calls for injected SQL
Command InjectionIntercepts OS exec calls with tainted input
Path TraversalTracks file operations with user-controlled paths
XXEMonitors XML parser for external entity loading
DeserializationBlocks dangerous class instantiation
SSRFValidates HTTP client calls against whitelist

RASP Solutions

Open Source

ToolLanguageType
OpenRASP (Baidu)Java, PHP, Node.jsAgent-based
Sqreen (acquired)Python, Node.js, RubySaaS + Agent
ModSecurity (with CRS)Any (reverse proxy)WAF/RASP hybrid

Commercial

ToolLanguagesFeatures
Contrast SecurityJava, .NET, Node, Python, Go, RubyFull RASP + IAST
Imperva RASPJava, .NETEnterprise scale
Signal Sciences (Fastly)Any (module)WAF + RASP
Dynatrace AppSecJava, .NET, Node, PHP, GoAPM + Security

Implementing RASP: OpenRASP Example

Java Agent Installation

# Download OpenRASP
wget https://github.com/baidu/openrasp/releases/download/v1.3.7/rasp-java.tar.gz
tar -xzf rasp-java.tar.gz

# Install to Java application
java -jar RaspInstall.jar -install /path/to/tomcat

Configuration

# openrasp/conf/openrasp.yml
security:
  sql:
    # Monitor all SQL queries
    policy: log  # log, block
  command:
    # Block command injection
    policy: block
  file:
    # Monitor file operations
    policy: log
  xxe:
    # Block XXE attacks
    policy: block

# Whitelist trusted operations
whitelist:
  sql:
    - "SELECT * FROM users WHERE id = ?"

RASP in Container Environments

Kubernetes Sidecar Pattern

# deployment.yaml with RASP sidecar
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  template:
    spec:
      containers:
        - name: app
          image: my-app:latest
          env:
            - name: JAVA_TOOL_OPTIONS
              value: "-javaagent:/rasp/rasp.jar"
          volumeMounts:
            - name: rasp-agent
              mountPath: /rasp

      initContainers:
        - name: rasp-init
          image: rasp-agent:latest
          command: ['cp', '/agent/rasp.jar', '/rasp/']
          volumeMounts:
            - name: rasp-agent
              mountPath: /rasp

      volumes:
        - name: rasp-agent
          emptyDir: {}

RASP Monitoring and Alerting

# Alert on RASP blocks
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: rasp-alerts
spec:
  groups:
    - name: rasp
      rules:
        - alert: RASPAttackBlocked
          expr: increase(rasp_attacks_blocked_total[5m]) > 10
          for: 1m
          labels:
            severity: warning
          annotations:
            summary: "High number of attacks blocked by RASP"

When to Use RASP

ScenarioRecommendation
High-value applicationsUse RASP + WAF
Regulatory complianceRASP provides deep visibility
Legacy applicationsWAF may be easier
MicroservicesConsider service mesh + RASP
Development/stagingUse in monitoring mode
ProductionStart with logging, graduate to blocking

Best Practices

  1. Start in monitoring mode: Log attacks before blocking
  2. Tune for your app: Whitelist legitimate patterns
  3. Monitor performance: RASP adds overhead (~2-5% CPU)
  4. Integrate with SIEM: Feed RASP logs to security monitoring
  5. Layer defenses: Use RASP alongside WAF, not instead of

In the next module, we'll tackle secrets management and infrastructure security. :::

Quick check: how does this lesson land for you?

Quiz

Module 4: Dynamic Testing & Runtime Security

Take Quiz
FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.