Most container security advice stops at the image. Scan for vulnerabilities, use a slim base, drop root, pin versions. That’s all necessary, but it’s only half the story. My DevSecOps article covered the build and admission layers—image scanning, pipeline checks, IaC scanning. This article covers what happens after deployment. An image is a static artifact. A container is a running process, and running processes do things you didn’t predict.

The compromise doesn’t happen when you build the image. It happens when the container runs, and something makes it behave differently than expected. A malicious package phones home. A misconfigured mount exposes the host filesystem. A kernel exploit breaks out of the namespace. None of these leave traces in your image scan.

Runtime security is the practice of watching what containers actually do, and flagging behavior that doesn’t match their purpose. This article walks through building a practical Falco lab, writing rules that catch real attacks, and understanding what runtime detection can and cannot do.

Container runtime security architecture showing Falco monitoring syscalls from containers and alerting on suspicious behavior

Why image scanning isn’t enough

Image scanning is a static analysis problem. You examine the layers, check the packages, verify the digest. If the image passes, you deploy it. But consider what happens after deployment:

  • A legitimate container runs a shell because a developer exec’d in for debugging, and forgot to close the session.
  • A compromised dependency in a Python application downloads and executes a cryptominer at 3 AM.
  • A misconfigured volume mount gives the container write access to /etc on the host.
  • An attacker exploits a kernel vulnerability (like Dirty Pipe or Dirty COW) to escape the container namespace entirely.

None of these scenarios involve a vulnerable package in the image. The image was clean when it was scanned. The problem emerged at runtime, from the interaction between the container and its environment.

This is the gap runtime security addresses. Instead of asking “is this image safe?”, you ask “is this container behaving the way it should?”

What Falco actually does

Falco is a CNCF graduated project originally created by Sysdig. At its core, it’s a rules engine that consumes system call events from the Linux kernel and evaluates them against a rule set. When a rule matches, it generates an alert.

The architecture is straightforward:

  1. Kernel instrumentation: Falco uses either a kernel module (traditional) or eBPF (modern) to intercept system calls. This happens at the kernel level, so it sees every syscall from every container on the host.
  2. Event enrichment: Each syscall is enriched with context: container ID, image name, Kubernetes pod/namespace, process tree, file paths, network connections, user IDs.
  3. Rule evaluation: Rules are written in a YAML-based language. They define conditions like “a shell spawned inside a container that shouldn’t have one” or “a binary executed from /tmp” or “a network connection to a known C2 IP.”
  4. Output: Alerts can go to stdout, files, syslog, HTTP endpoints, gRPC, or cloud-native systems like Falcosidekick for forwarding to Slack, PagerDuty, Splunk, etc.

Falco doesn’t prevent anything. It detects. Prevention requires integration with admission controllers (like Falco’s experimental prevention mode) or runtime enforcement tools like Tetragon. But detection is the prerequisite. You can’t prevent what you don’t see.

Building the lab

The best way to understand runtime detection is to build a lab where you can safely trigger alerts and see what they look like. Here’s a minimal setup that runs entirely on a single machine.

Prerequisites

  • A Linux machine or VM (Falco’s kernel module requires Linux; eBPF works on newer kernels)
  • Docker and Docker Compose
  • Root access (for kernel module/eBPF)

The lab environment

Create a project directory and the following docker-compose.yml:

version: '3.8'

services:
  falco:
    image: falcosecurity/falco:0.38.0
    container_name: falco
    privileged: true
    pid: host
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - /proc:/host/proc:ro
      - /boot:/host/boot:ro
      - /lib/modules:/host/lib/modules:ro
      - /usr:/host/usr:ro
      - /etc:/host/etc:ro
      - ./falco-rules:/etc/falco/rules.d
      - ./falco-output:/var/log/falco
    command: >
      --modern-bpf
      --json-output
      --log-level=info
    cap_add:
      - SYS_PTRACE
      - SYS_ADMIN
      - CAP_DAC_READ_SEARCH

  target-app:
    image: python:3.11-slim
    container_name: target-app
    working_dir: /app
    volumes:
      - ./app:/app
    command: sleep infinity
    security_opt:
      - "no-new-privileges:true"
    cap_drop:
      - ALL
    read_only: true
    tmpfs:
      - /tmp
      - /run

  attacker:
    image: ubuntu:22.04
    container_name: attacker
    command: sleep infinity
    privileged: true
    pid: host

This compose file creates three containers:

  • falco: The runtime security monitor with access to kernel events
  • target-app: A hardened Python application container (non-root, read-only rootfs, dropped capabilities)
  • attacker: A privileged container simulating a compromised or malicious workload

Save this as docker-compose.yml and create the directory structure:

mkdir -p falco-rules falco-output app

Falco configuration

Falco ships with a solid default rule set, but the real value comes from custom rules tuned to your environment. Create falco-rules/custom.yaml:

# Custom Falco rules for the container runtime security lab
# Save as falco-rules/custom.yaml

- rule: Terminal Shell in Container
  desc: A shell was spawned in a container with an attached terminal
  condition: >
    spawned_process and container
    and proc.name in (bash, sh, zsh, fish, ksh, tcsh)
    and proc.tty != 0
  output: >
    Terminal shell spawned in container (user=%user.name container=%container.name image=%container.image.repository shell=%proc.name cmdline=%proc.cmdline)
  priority: WARNING
  tags: [container, shell, mitre_execution]

- rule: Suspicious Binary in Container
  desc: Execution of suspicious binaries commonly used for reconnaissance or exploitation
  condition: >
    spawned_process and container
    and proc.name in (nc, netcat, nmap, masscan, curl, wget, python3, perl, ruby, lua, node, php)
    and not proc.name in (python3)  # allow python for our app
  output: >
    Suspicious binary executed in container (user=%user.name container=%container.name binary=%proc.name cmdline=%proc.cmdline)
  priority: WARNING
  tags: [container, reconnaissance, mitre_discovery]

- rule: Write to Binary Directory
  desc: Writing to directories that should be immutable in containers
  condition: >
    open_write and container
    and (fd.name startswith /bin or fd.name startswith /sbin or fd.name startswith /usr/bin or fd.name startswith /usr/sbin or fd.name startswith /lib)
  output: >
    Write to binary directory in container (user=%user.name container=%container.name file=%fd.name proc=%proc.name)
  priority: ERROR
  tags: [container, persistence, mitre_persistence]

- rule: Mount Namespace Escape Attempt
  desc: Attempts to manipulate mount namespaces from within a container
  condition: >
    container and (evt.type in (mount, umount, unshare, setns, pivot_root))
  output: >
    Mount namespace manipulation detected (container=%container.name evt=%evt.type user=%user.name)
  priority: CRITICAL
  tags: [container, escape, mitre_privilege_escalation]

- rule: Access to Host Filesystem via Proc
  desc: Container accessing host filesystem through /proc
  condition: >
    open_read and container
    and fd.name startswith /proc/
    and fd.name contains /root/
  output: >
    Container accessing host filesystem via /proc (container=%container.name file=%fd.name proc=%proc.name)
  priority: WARNING
  tags: [container, escape, mitre_credential_access]

- rule: Kubernetes Service Account Token Access
  desc: Reading Kubernetes service account token from within a container
  condition: >
    open_read and container
    and fd.name = /var/run/secrets/kubernetes.io/serviceaccount/token
  output: >
    Service account token accessed (container=%container.name proc=%proc.name)
  priority: INFO
  tags: [container, kubernetes, credential_access]

- rule: Crypto Miner Binary Execution
  desc: Known cryptominer binary names executed in container
  condition: >
    spawned_process and container
    and proc.name in (xmrig, xmr-stak, cpuminer, minerd, cgminer, bfgminer, ethminer, claymore, phoenixminer, lolminer, teamredminer, nbminer, gminer, trex, cryptonight, monerod)
  output: >
    Cryptominer binary executed (container=%container.name binary=%proc.name cmdline=%proc.cmdline)
  priority: CRITICAL
  tags: [container, crypto_miner, mitre_resource_development]

- rule: Unexpected Outbound Connection
  desc: Container making outbound connection to non-standard port
  condition: >
    container and evt.type = connect and fd.net and fd.sport >= 1024
    and fd.dport not in (80, 443, 53, 5432, 3306, 6379, 27017, 9200, 5672, 1521, 1433)
  output: >
    Unexpected outbound connection (container=%container.name proc=%proc.name src=%fd.sip sport=%fd.sport dst=%fd.dip dport=%fd.dport)
  priority: WARNING
  tags: [container, network, mitre_command_and_control]

These rules cover the main attack categories: execution, persistence, privilege escalation, credential access, discovery, and command-and-control. They’re intentionally noisy for a lab environment—production rules would be more selective.

Application code for testing

Create a simple Python app in app/main.py that we’ll use to test legitimate behavior:

#!/usr/bin/env python3
"""
Simple HTTP server for testing Falco rules.
This represents a legitimate containerized application.
"""

import http.server
import socketserver
import os
import sys
import time

PORT = 8080

class HealthHandler(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        if self.path == '/health':
            self.send_response(200)
            self.send_header('Content-type', 'application/json')
            self.end_headers()
            self.wfile.write(b'{"status": "healthy"}')
        elif self.path == '/':
            self.send_response(200)
            self.send_header('Content-type', 'text/plain')
            self.end_headers()
            self.wfile.write(b'Container Runtime Security Lab - Target App\n')
        else:
            self.send_response(404)
            self.end_headers()

    def log_message(self, format, *args):
        # Suppress default log messages
        pass

if __name__ == '__main__':
    print(f"Starting target app on port {PORT}")
    with socketserver.TCPServer(("", PORT), HealthHandler) as httpd:
        httpd.serve_forever()

Starting the lab

# Start all containers
docker compose up -d

# Verify Falco is running and generating events
docker compose logs -f falco

You should see JSON-formatted alerts scrolling by. Falco is now monitoring syscalls from both target-app and attacker containers.

Triggering and analyzing alerts

Now let’s generate some alerts by simulating attacks from the attacker container.

Test 1: Shell spawn in container

# Exec into the attacker container and spawn a shell
docker exec -it attacker bash
# Inside the container:
bash
# Exit
exit
exit

Check Falco logs—you should see a “Terminal Shell in Container” alert with the container name, user, and command line.

Test 2: Suspicious binary execution

docker exec -it attacker bash
# Inside the container, try various binaries:
nc -h
python3 -c "print('hello')"
curl --version
# Exit
exit
exit

The “Suspicious Binary in Container” rule should fire for nc, curl, and potentially others. Note that python3 is allowed in our rule (commented out in the condition).

Test 3: Write to binary directory

docker exec -it attacker bash
# Try to write to /bin (should fail in target-app due to read-only, but attacker is privileged)
echo "malicious" > /bin/evil
# Exit
exit
exit

The “Write to Binary Directory” rule should trigger. This simulates an attacker dropping a backdoor binary.

Test 4: Mount namespace manipulation

docker exec -it attacker bash
# These require privileged access and will trigger the escape rule
mount --bind /tmp /mnt
unshare -m
# Exit
exit
exit

Test 5: Host filesystem access via /proc

docker exec -it attacker bash
# Read host files through /proc
cat /proc/1/root/etc/passwd
cat /proc/1/root/etc/shadow 2>/dev/null || echo "No access to shadow"
# Exit
exit
exit

This is a classic container escape technique—accessing the host filesystem through the PID 1 process’s /proc entry.

Test 6: Cryptominer simulation

docker exec -it attacker bash
# Simulate a cryptominer binary name (creates empty file, makes executable, runs)
echo '#!/bin/bash\necho "mining..."' > xmrig
chmod +x xmrig
./xmrig
# Exit
exit
exit

The “Crypto Miner Binary Execution” rule should fire immediately on the binary name match.

Test 7: Unexpected outbound connection

docker exec -it attacker bash
# Connect to a non-standard port
nc -zv 8.8.8.8 4444 2>/dev/null || echo "Connection failed (expected)"
python3 -c "import socket; s=socket.socket(); s.connect(('8.8.8.8', 9999))" 2>/dev/null || echo "Failed"
# Exit
exit
exit

Understanding the alert output

Falco’s JSON output includes rich context. Here’s a typical alert from our lab:

{
  "output": "Terminal shell spawned in container (user=root container=attacker image=ubuntu shell=bash cmdline=bash)",
  "priority": "WARNING",
  "rule": "Terminal Shell in Container",
  "time": "2026-11-16T10:30:45.123456789Z",
  "output_fields": {
    "container.id": "abc123...",
    "container.name": "attacker",
    "container.image.repository": "ubuntu",
    "container.image.tag": "22.04",
    "proc.name": "bash",
    "proc.cmdline": "bash",
    "proc.pid": 1234,
    "proc.ppid": 1000,
    "proc.exe": "/usr/bin/bash",
    "user.name": "root",
    "user.uid": 0,
    "user.loginuid": 1000
  },
  "tags": ["container", "shell", "mitre_execution"]
}

Key fields for investigation:

  • container.name/image: Identifies the workload
  • proc.name/cmdline: What was executed
  • proc.pid/ppid: Process tree for context
  • user.name/uid: Who ran it (inside the container)
  • tags: MITRE ATT&CK mappings for correlation

Writing effective custom rules

The default Falco rules are a starting point. Effective custom rules follow these principles:

1. Start with your workload’s normal behavior

Before writing detection rules, establish a baseline. Run your application normally for a week and collect all Falco events. Then identify what’s truly anomalous.

# Collect baseline events
docker compose logs falco | jq -r 'select(.rule != null) | .rule' | sort | uniq -c | sort -rn

2. Use container context, not just syscalls

Bad rule: “Alert on execve of nc” Good rule: “Alert on execve of nc in a container that doesn’t have nc in its image”

The second rule uses container image metadata to reduce false positives. Falco provides container.image.repository and container.image.tag for this.

3. Leverage process ancestry

A shell spawned by your application’s entrypoint is different from a shell spawned by sshd inside the container. Use proc.ppid and proc.aname (ancestor names) to distinguish.

condition: >
  spawned_process and container
  and proc.name = bash
  and not proc.aname in (python3, java, node, dotnet, gunicorn, uwsgi)

4. Tag with MITRE ATT&CK

Every rule should include MITRE tags. This enables correlation with other security tools and helps analysts understand the attack phase.

tags: [container, persistence, mitre_persistence, T1505.003]

4. Handle the noise problem

Runtime detection is inherently noisy. Strategies:

  • Suppress known-good: Create exception lists for legitimate administrative activity
  • Aggregate alerts: Group similar alerts within a time window
  • Enrich with threat intel: Cross-reference IPs, domains, file hashes
  • Tier priorities: Only page on CRITICAL; batch WARNING/INFO for daily review

What Falco misses (and what catches it)

Runtime detection has blind spots. Understanding them is as important as knowing what it catches.

Kernel-level blind spots

  • eBPF/Module bypass: Sophisticated rootkits can hook the kernel before Falco loads
  • Hardware attacks: Rowhammer, Spectre/Meltdown don’t generate syscalls
  • Firmware persistence: Below the kernel entirely

Encryption blind spots

  • TLS traffic: Falco sees the connection but not the payload
  • Encrypted malware: Payloads decrypted in memory leave no disk trace

Logic blind spots

  • Business logic abuse: Legitimate API calls used maliciously (e.g., parameter tampering)
  • Data exfiltration via DNS: Small queries that don’t trigger volume thresholds

Complementary layers

Blind Spot Complementary Tool
Kernel rootkits Kernel integrity monitoring (IMA/EVM), secure boot
Encrypted traffic Network TLS inspection, eBPF-based SSL/TLS visibility (Cilium Tetragon)
Business logic Application-level WAF, API gateways, RASP
Data exfil DLP, egress firewall rules, DNS monitoring
Fileless malware Memory scanning, behavioral EDR

Falco is one layer. It excels at detecting unexpected process behavior in containers. It doesn’t replace network security, application security, or host hardening.

Integrating into a detection pipeline

In production, Falco alerts don’t go to a log file. They feed a detection pipeline:

Falco → Falcosidekick → [Kafka/NATS/HTTP] → SIEM (Splunk/Elastic/Sentinel)
                                    → SOAR (Cortex XSOAR, Phantom)
                                    → Notification (Slack, PagerDuty, Email)
                                    → Enrichment (VirusTotal, AlienVault, MITRE)

A minimal Falcosidekick configuration:

# falcosidekick.yaml
falco:
  listen_port: 2801

outputs:
  slack:
    webhookurl: "https://hooks.slack.com/services/XXX/YYY/ZZZ"
    channel: "#security-alerts"
    username: "falco"
    icon_emoji: ":falco:"

  elasticsearch:
    host: "https://elasticsearch:9200"
    index: "falco-%Y.%m.%d"
    username: "elastic"
    password: "${ELASTIC_PASSWORD}"

  loki:
    host: "http://loki:3100"
    labels:
      job: "falco"
      environment: "production"

stats:
  prometheus:
    enabled: true
    port: 9090

This gives you searchable alerts, dashboards, and automated enrichment—without manually reading JSON logs.

Scaling considerations

Performance impact

Falco’s overhead is typically 1-3% CPU on modern kernels with eBPF. The kernel module has slightly higher overhead. For high-density hosts (100+ containers), consider:

  • Running Falco as a DaemonSet in Kubernetes (one per node)
  • Using the eBPF probe (modern-bpf) for lower overhead
  • Filtering namespaces you don’t care about (e.g., kube-system)
  • Horizontal scaling of Falcosidekick for output processing

Rule management at scale

  • Version control rules: Store in Git, deploy via CI/CD
  • Test rules before deploy: Use falco --validate and falcoctl for rule testing
  • Namespace-aware rules: Use k8s.ns.name to scope rules to specific namespaces
  • Gradual rollout: Deploy new rules in “monitor only” mode first
# Validate rules before deployment
falco --validate --modern-bpf -c /etc/falco/falco.yaml

Lab cleanup

# Stop and remove containers
docker compose down -v

# Remove generated logs
rm -rf falco-output

The lab is ephemeral—no persistent state, no cloud resources, no cost beyond compute time.

Where this fits in your security program

Runtime detection doesn’t replace image scanning, admission control, or network policies. It completes them:

Layer Tool Example What It Catches
Build Trivy, Grype, Syft Vulnerable packages, secrets, misconfig in image
Admission Kyverno, OPA Gatekeeper Non-compliant deployments before they run
Network Cilium, Calico, NetworkPolicy Unauthorized lateral movement, egress
Runtime Falco, Tetragon, Tracee Unexpected behavior in running containers
Response Falcosidekick + SOAR Automated containment, forensic capture

The DevSecOps article covered the build and admission layers. This article covers runtime. The network layer deserves its own treatment.

Practical next steps

If you want to take this beyond the lab:

  1. Deploy Falco on a staging cluster as a DaemonSet with eBPF
  2. Run baseline collection for two weeks before enabling alerts
  3. Write 5-10 custom rules specific to your applications
  4. Integrate with your SIEM via Falcosidekick
  5. Create runbooks for the top 10 rule categories
  6. Run tabletop exercises simulating container escape scenarios
  7. Evaluate prevention: Tetragon or Falco’s prevention mode for blocking, not just alerting

Resources for deeper study


Want to run the lab yourself? Download the complete lab package: docker-compose.yml, custom.yaml, app/main.py, and README.md with setup instructions and cleanup steps.