November 24, 2026
8
min

An SSRF Attack Hits a Pod - Four Agents Investigate, Block, and Fix It

I chained four StreamForce agents into a pipeline that takes an SSRF detection all the way to a pull request.
Yehonatan Rumyantsev
Solution Engineer

TL;DR

I chained four StreamForce agents into a pipeline that takes an SSRF detection all the way to a pull request. The first agent investigates and triages. If it confirms the attack, three response agents fire in parallel: one creates runtime kernel-level block rules, one produces a WAF tuning report, and one opens a draft PR that fixes the vulnerable code.

The Scenario

I wanted a realistic attack scenario to demonstrate what a fully automated detection-to-remediation pipeline looks like: a containerized web application with an SSRF vulnerability, deployed on EKS behind a load balancer and a WAF, exploited from an external IP. The kind of setup that shows up in real incident reports.

Here's what I built:

  • A Python Flask app called link-preview-svc that fetches URLs on behalf of the user, a common pattern in link preview, PDF generation, and webhook proxy services
  • A /api/fetch-preview endpoint that takes a URL parameter and fetches it with no validation, the SSRF entry point
  • A /api/diagnostics endpoint that runs nslookup via subprocess.run(..., shell=True), the command injection entry point
  • Deployed on EKS in its own namespace, behind an internet-facing ALB and an AWS WAF WebACL with the AWSManagedRulesCommonRuleSet in Block mode

The app has known vulnerabilities, but the infrastructure around it is realistic. The ALB is internet-facing. The WAF has the standard AWS managed rule set attached in Block mode. The pod runs with the default service account, and the node's IMDS is accessible (IMDSv1 optional, hop limit 2).

The Pipeline

I created four StreamForce agents and chained them into a pipeline. The first agent triggers on any detection and investigates. If it confirms a real attack, three response agents fire in parallel:

Each chain has a condition. The Incident Investigator doesn't blindly forward every detection to all three agents. The chain evaluator reads the full finding text and fires only when the evidence in the body supports it: confirmed RCE, confirmed IMDS access, a web application attack on an internet-facing workload.

I'll walk through each agent, what it does, and what it found on a live run.

The Attack

I ran the attack from a DigitalOcean droplet in Frankfurt, a different IP than my own, so the detection looks like what a real external attacker would produce.

SSRF: IMDS Credential Theft

The SSRF uses a decimal IP encoding bypass. Instead of 169.254.169.254, I passed 2852039166, the same address as a 32-bit integer. The common rule set is in Block mode but doesn't cover decimal IP encoding:

curl "https://<ALB>/api/fetch-preview?url=http://2852039166/latest/meta-data/"

The app resolved it, fetched the IMDS metadata, and returned it in the response. With one more hop to /latest/meta-data/iam/security-credentials/, an attacker gets the node's IAM role credentials.

Command Injection: Shell Access

The /api/diagnostics endpoint passes user input directly into a shell command. Several injection techniques worked: semicolons, pipe characters, and newline encoding. The WAF didn't catch any of them. Here's the newline variant:

curl "https://<ALB>/api/diagnostics?host=google.com%0aid%0awhoami"

The %0a is a URL-encoded newline. The shell interprets it as a command separator, so id and whoami run after nslookup. The response came back with uid=0(root).

Both attacks triggered the runtime sensor. The IMDS access produced a network-based detection (TCP SYN to 169.254.169.254). The command injection produced a "Suspicious Binary Executed in Container" detection (/usr/bin/id and /usr/bin/whoami loaded from a gunicorn worker). Stream Security correlated them on the same pod and time window.

Agent 1: Incident Investigator

The Incident Investigator triggers on every detection. Its job is to investigate, determine if the activity is malicious, and produce a finding with enough context for the downstream agents to act on.

It has access to the full investigation toolkit: detections, inventory, logs, attack paths, config changes, and the knowledge base. Here's what it does in practice:

  1. Pulls the detection details and checks for prior human closes (so it doesn't re-investigate something an analyst already dismissed)
  2. Queries the pod's inventory record: what image it runs, what namespace, what node, whether it has IRSA
  3. Pulls network flow logs, API logs, file logs, and process logs from the runtime sensor
  4. Looks up the source IP against VirusTotal and IPinfo
  5. Checks the attack path from the internet to the pod
  6. Correlates with other detections on the same resource in the last 7 days

The agent triaged the detection as Malicious, Confidence: High, Priority: P1 and produced a Critical-severity finding. It identified:

  • Confirmed RCE: gunicorn worker (pid 241706) spawned /bin/sh with args -c nslookup google.com\nid\nwhoami
  • Confirmed execution: /usr/bin/id and /usr/bin/whoami loaded in the container
  • Confirmed IMDS attempt: TCP SYN to 169.254.169.254, node has IMDSv1 optional and hop limit 2
  • Recurring pattern: identical attack chain fired two days earlier, closed only by automated triage
  • Source IP: DigitalOcean hosting, Frankfurt, flagged as suspicious by one vendor

I didn't tell the agent any of that. It found it by querying the same tools a human analyst would use, in the same order a human would follow.

Agent 2: Runtime Block Rule Creator

When the investigation confirms a real attack, this agent creates runtime prevention rules at the kernel level. These are eBPF-based hooks that can block specific system calls (network connections, process executions, file opens) scoped to a specific namespace and workload.

The critical constraint: every rule needs human approval. The agent proposes rules, but nothing takes effect until a human approves. Approved rules start in audit mode, logging what would be blocked without actually blocking. The action is set to deny, which takes effect only after a human promotes the rule to enforce. Approval is enforced by the platform. Audit mode is enforced by the prompt:

Rules you create always start in AUDIT (observe-only) and block nothing until a human reviews and promotes them. You cannot promote or enforce. That is intentionally a human action. Do NOT create cluster-wide or account-wide rules unless the investigation explicitly justifies it.

On this run, the agent created 6 rules, each pending approval:

  • Connect hook: block outbound connections to 169.254.169.254 from the link-preview namespace
  • Exec hook: block shell spawning (/bin/sh, /bin/bash) from the gunicorn process
  • Open hook: block reads of /etc/shadow and Kubernetes service account tokens from the container

Each rule is scoped to the specific cluster, namespace, and container image. On this run, nothing applied cluster-wide. The recommended next step: monitor the audit logs, confirm no false positives, then promote to enforce.

Agent 3: WAF Rule Advisor

This agent doesn't change the WAF. It produces a report with specific, prioritized recommendations for what to change and why.

It starts by looking up the WAF WebACL associated with the ALB (via the attack path and inventory), examines the current rule groups and their actions, then analyzes which payloads bypassed the WAF and which were caught.

The report included 4 prioritized recommendations:

  1. Add missing managed rule sets: AWSManagedRulesLinuxRuleSet, AWSManagedRulesUnixRuleSet, AWSManagedRulesKnownBadInputsRuleSet, and AWSManagedRulesSQLiRuleSet in Block mode
  2. Add SSRF-specific custom rules for decimal, hex, and octal IP encoding bypasses of 169.254.169.254
  3. Add a custom rule to block requests targeting cloud metadata paths (/latest/meta-data/)
  4. Enable WAF logging, which is currently disabled

Each recommendation includes the exact rule group ID, the current action, the recommended action, what it would block, and the false positive risk. It's a report you can hand to the team that owns the WAF and they can act on it without re-investigating.

Agent 4: Vulnerability Fix PR

This is the agent that closes the loop. It reads the investigation findings, finds the source repository, reads the vulnerable code, and opens a draft pull request with the fix.

The agent has two plugins:

  • github-org-inspector: listRepositories, searchCode, to find the right repo when the investigation only mentions an ECR image name
  • github-pr: getRepoTree, getFileContent, createPullRequest, to read the code and open a PR with exact find-and-replace edits

The agent doesn't know the repository name ahead of time. The investigation findings mention an ECR image (link-preview-svc), but the GitHub repo is called ssrf-demo-app. The agent calls listRepositories, scans the list, finds the matching repo, browses its file tree, reads the application code, and identifies the vulnerable pattern.

The fix it produced:

  • Added URL validation before the fetch: parses the URL, resolves the hostname, and rejects requests to link-local (169.254.0.0/16), private (10/8, 172.16/12, 192.168/16), and loopback ranges
  • Handles decimal IP encoding bypasses (the same technique the attacker used)
  • Removed the /debug/exec backdoor endpoint entirely (the agent found this on its own while reading the code; the investigation never mentioned it)
  • Replaced shell=True in the diagnostics endpoint with safe argument passing

The PR was opened as a draft. Nothing merges automatically. A developer reviews it, tests it, and decides whether to merge.

What Keeps It Safe

Automation that touches security infrastructure needs guardrails. Here's what this pipeline has:

Chain conditions. The downstream agents don't fire on every investigation. Each chain has a condition prompt that the evaluator checks against the full finding text. If the investigation says "suspicious but unconfirmed," the response agents don't fire. They chain only when the body of the finding contains confirmed evidence: confirmed RCE, confirmed IMDS access, specific malicious processes that executed.

Human approval + audit mode. The runtime prevention agent proposes rules that need human approval before activation. Approved rules start in audit mode: they log what would be blocked without actually blocking. Promoting to enforce is a separate human decision. Approval is enforced by the platform: the agent cannot activate a rule on its own. Audit mode is enforced by the prompt.

Report, don't modify. The WAF advisor produces a report. It doesn't have write access to the WAF. The recommendations go to the team that owns the WAF configuration.

Draft PRs only. The code fix agent opens draft pull requests. Nothing is merged automatically. A developer reviews the diff, runs the tests, and decides whether to merge.

Narrow scope. On this run, every rule and recommendation was scoped to the specific cluster, namespace, and workload where the incident occurred.

The same work done manually (investigating the detection, writing kernel-level rules, analyzing the WAF configuration, finding the repo, reading the code, and opening a PR) would take a team hours spread across multiple people. And the investigation would sit in a queue before anyone looked at it.

These agents aren't replacing analysts. They're doing the work that sits between "a detection fired" and "someone got around to it." The investigation still needs a human to read the finding. The runtime rules still need a human to approve them and promote to enforce. The WAF recommendations still need a human to apply them. The PR still needs a developer to review and merge it.

What changes is that by the time a human looks, the work is already staged and waiting.

About Stream Security

Stream is the AI-native platform built to fight AI-enabled attacks. It autonomously prevents, detects, hunts, and remediates exposures and threats across production at machine speed - driving risk toward zero. It replaces the fragmented stack of scanners, runtime agents, exposure tools and playbooks with one live model of production.Defending Production needs a new approach: Stream is the only Autonomous Production Defense Platform that works across your entire production estate. It runs on a patented CloudTwin®, a high-fidelity security data harmonization layer that models Cloud, SaaS, identity, runtime, AI, network, perimeter, on-prem, security controls, and the behavior running on top of them into one live model of production: real-time, fully correlated, continuously updating. Not a snapshot. And it does not stop at boundaries - the boundaries that fragment every other tool are the same boundaries an attacker moves across. Inside CloudTwin they are one system.

Yehonatan Rumyantsev
Solution Engineer

We wouldn’t believe it either.

Get a demo