The 'SOC 2 Compliant' Breach: How an SSRF-to-IMDS Pivot Bypassed the WAF and Stole the JWT Signing Key in 4 Minutes
They had a clean SOC 2 Type II audit report, a $150k/yr Cloudflare Enterprise WAF, and green lights on Datadog. An attacker slipped past the WAF with an IPv6-mapped address, reached a forgotten IMDSv1 endpoint, pivoted through over-permissive IAM into an unauthenticated Redis cache, and extracted the JWT signing key in 252 seconds. Here is how we contained it before any customer data left, deployed eBPF kernel enforcement, and rebuilt their zero-trust architecture.
1. The Incident: A Green Audit, Zero Alerts, and a Complete VPC Breach
Twenty-four days before our red-team emergency engagement, a high-growth Series B FinTech platform handling $120M in annualized transactions received their official SOC 2 Type II attestation report from an accredited auditor. All 68 controls were marked as green. Their enterprise web application firewall (WAF) was configured to block known OWASP injection vectors. Their Datadog SIEM ingested over 1.2 terabytes of application logs daily.
At 02:14:18 UTC on a Thursday morning, an adversary initiated an exploit sequence through an innocuous public endpoint: an automated PDF invoice generator accepting a customer brand logo via `POST /api/v1/invoices/generate`.
By 02:18:30 UTC — exactly 4 minutes and 12 seconds later — the attacker held the application's RSA private signing key, a shell inside the VPC, and a forged superadmin token, and was positioned to start exfiltrating data on 420,000 corporate bank accounts.
Not a single threshold alert was triggered on their Datadog dashboard. The SIEM showed green. The WAF showed green. The compliance officer slept soundly.
Anatomy of the 252-Second Intrusion:
2. The Illusion of Compliance: Why Your $150,000 WAF and SOC 2 Report Failed
Corporate security departments operate under a fatal delusion: they mistake compliance for security.
A SOC 2 report is an attestation from a CPA firm that tells your customers your security controls exist and, for Type II, operated over a review period. It verifies that you have a password policy, that employees complete annual phishing modules, and that you have a documented change-management Jira workflow. It does not verify whether your Linux kernel permits arbitrary `connect()` syscalls to `169.254.169.254`. It does not test whether an unsegmented VPC allows a frontend rendering container to query your private Redis cache.
Let us be unmistakably clear about the three systemic architectural lies that modern security teams purchase every year:
Lie #1: "Our Cloud WAF Protects Our APIs from Injection"
WAFs operate in userspace at Layer 7 by matching regex strings against inbound HTTP bodies. They understand basic SQL injection strings like `' OR '1'='1`. They are completely blind to protocol translation anomalies. When an attacker encodes an IP as a decimal (`2852039166`), an octal (`0251.0376.0251.0376`), or an IPv6-mapped bracket, the string never matches the WAF's pattern. The backend then normalizes it back into the link-local metadata address 169.254.169.254 (Chromium and the WHATWG URL parser behind Node's fetch both do this), making the WAF rule useless.
Lie #2: "Our Private Subnet (VPC) Isolates Our Backend"
Traditional network engineers believe putting Redis, PostgreSQL, and microservices inside a "private subnet" constitutes security. In reality, once an attacker achieves a single blind SSRF or remote code execution (RCE) on a single edge service, they are already inside the perimeter. Inside the VPC, microservices communicate over unencrypted HTTP, trust IP addresses implicitly, and leave caching tiers unauthenticated. Perimeter security without Zero-Trust is a hard eggshell with a liquid center.
Lie #3: "AWS RDS Encryption at Rest Protects Our Data"
RDS "encryption at rest" protects against a single threat: someone walking into an AWS data center in Virginia, unscrewing a physical NVMe hard drive, and running away with it. If an attacker extracts database credentials or uses an IAM role with RDS connect permissions, AWS transparently decrypts every single record on the fly. Without client-side KMS Envelope Encryption, encryption-at-rest is marketing theater.
3. The Exploit Chain: Dual-Stack SSRF to a Forgotten IMDSv1 Endpoint
AWS IMDSv2 does stop this kind of SSRF: a session token requires a `PUT` request with the `X-aws-ec2-metadata-token-ttl-seconds` header, which a URL-fetching browser cannot send, and a hop limit of 1 keeps containers from reaching it at all. The client believed IMDSv2 was enforced everywhere. It was enforced everywhere except one place.
The invoice generator ran on a separate worker fleet built from an older launch template with `http-tokens: optional`, so IMDSv1 still answered plain `GET` requests. It used headless Chromium (Puppeteer) to render PDFs and loaded the customer's `logo_url` directly as a page. Given `http://[::ffff:a9fe:a9fe]/latest/meta-data/iam/security-credentials/`, Chromium fetched the role's temporary credentials and rendered them into the PDF it sent back.
4. Lateral Movement: How Implicit VPC Trust Handed Over the Signing Keys
Once the IAM role credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`) were exfiltrated from the IMDS endpoint, the adversary inspected the role's attached IAM policies.
The policy violated the principle of least privilege: someone had attached `AmazonSSMFullAccess` and `AmazonElastiCacheReadOnlyAccess` during a debugging sprint 8 months prior.
Using the AWS CLI, the attacker listed the internal ElastiCache endpoint (`cache-cluster.internal.vpc:6379`), then used `aws ssm send-command` to run a shell command on the PDF worker itself, which put them inside the VPC. From there, `redis-cli` connected without a password: Redis AUTH had never been enabled because the engineers believed "it is only accessible from inside the private VPC."
Inside Redis key `auth:jwt:signing_key:v2`, the attacker found the unencrypted RSA-2048 private key. In under 30 seconds, they generated an asymmetric signature for an admin JWT that granted universal access across all API gateways.
5. The Containment: Revoke, Rotate, and Enforce at the Kernel with eBPF Tetragon
When HawkInspect Pro received the triage distress call at 02:29 UTC, our primary directive was: Achieve immediate blast-radius containment without taking the application offline or disrupting paying users.
First we cut the attacker off: revoke the stolen credentials, rotate the signing key, close the egress path. Then, instead of waiting for a 45-minute CI/CD build to patch the PDF worker, we enforced the fix at the Linux kernel layer using eBPF and Tetragon, which sees the real destination address after any URL parsing.
Containment Achieved in 38 Minutes:
At 02:33 UTC, four minutes after the call, the client's on-call engineer (on our instruction) revoked the instance role's active sessions, removed the leftover SSM and ElastiCache permissions, and cut the PDF worker's outbound internet route. We then rotated the JWT signing key, which invalidated the forged superadmin token. By 03:07 UTC, 38 minutes after the call, the Tetragon policy was running on every worker node and every instance required IMDSv2 with a hop limit of 1. When the attacker came back through the same PDF endpoint at 03:11, the kernel killed the Chromium process before its connection completed. VPC Flow Logs and database query logs confirmed the attacker never started a bulk export: no customer records left the VPC.
6. Architectural Rebuild: KMS-Held Keys, Envelope Encryption & SPIFFE Workload Identity
Emergency containment stops the hemorrhage. Rebuilding the architecture means that the next time one worker is compromised, it no longer opens the rest of the network.
Over the next 72 hours, we deployed the complete HawkInspect Pro Zero-Trust Cloud Blueprint:
Client-Side KMS Envelope Encryption
Eliminated reliance on RDS disk encryption. Sensitive database fields (account numbers, routing data, PII) are encrypted at the client level using per-record AES-256-GCM Data Encryption Keys (DEKs) generated by AWS KMS, whose HSMs are FIPS 140-3 validated. Only the KMS-encrypted copy of each DEK is stored. An attacker dumping the PostgreSQL database only obtains cryptographically random ciphertext.
Cryptographic SPIFFE/SPIRE Workload Identity
Destroyed implicit VPC IP trust. Every microservice gets a SPIFFE ID with short-lived X.509 SVIDs rotated hourly, and service-to-service calls require mutual TLS (TLS 1.3) through Envoy sidecars. ElastiCache does not support client-certificate auth, so Redis now requires in-transit TLS plus per-service AUTH credentials, and the JWT signing key moved out of Redis into AWS KMS, where it can sign tokens but can never be exported.
Strict Envoy Egress SNI Allowlisting
Blocked unrestricted outbound internet connectivity across all subnets. All external requests must traverse an egress proxy enforcing a strict domain allowlist (`api.stripe.com`, `api.sendgrid.com`). Reverse shells and C2 exfiltration attempts are dropped instantly.
Read-Only Root Filesystems & Seccomp-BPF
Hardened container runtimes with `readOnlyRootFilesystem: true`, non-root execution (UID 10001), and a customized Seccomp-BPF syscall filter. The PDF worker image contains Chromium and nothing else: no shell, no package manager. Even with code execution inside the container, an attacker cannot write binaries to disk or gain new privileges.
07. The Unvarnished Post-Mortem & The Question Every CTO Must Ask
Not Cloudflare's fault. Not Datadog's fault. Not AWS's fault.
The vulnerability was an Architectural Perimeter Fallacy that assumed private VPC subnets are secure and treated compliance certifications (SOC 2) as actual defense.
// FLAW: Implicit internal trust const redis = new Redis("cache-cluster.internal.vpc:6379"); // Anyone inside the VPC reads raw JWT private keys const jwtPrivateKey = await redis.get("jwt_private_key");
Implicit VPC trust, plaintext microservice communication, unauthenticated Redis caches, and reliance on userspace WAF regex filters.
// HARDENED: envelope encryption with AWS KMS (FIPS 140-3 HSMs) const { Plaintext: dataKey, CiphertextBlob: encryptedKey } = await kms.generateDataKey({ KeyId: process.env.KMS_KEY_ARN, KeySpec: 'AES_256' }); const ciphertext = aesGcmEncrypt(dataKey, rawDataBuffer); // encrypt locally dataKey.fill(0); // plaintext key is never stored // Store ciphertext + encryptedKey. Reading it back requires kms:Decrypt.
mTLS (TLS 1.3) workload identity, signing keys held in KMS, client-side envelope encryption, and kernel-level eBPF enforcement.
A Compliance Report Is Not a Penetration Test
Assume the Edge Is Already Compromised
Enforce Below the Application Where You Can
"If an attacker achieved an arbitrary SSRF in your PDF generator tonight, what stops them from reading your internal Redis cache within 4 minutes?"
Have your engineering leadership review this exploit path against your current AWS/GCP infrastructure before your next funding round or customer compliance review:
Schedule an Adversarial Zero-Trust Architecture Audit
Have senior red-team architects audit your cloud infrastructure, eliminate SSRF/BOLA vectors, and deploy eBPF kernel defenses under strict mutual NDA.