Q: A cloud-native application hosted on AWS EC2 allows users to input a URL, and the server fetches the image at that URL to generate a thumbnail. An attacker inputs `http://169.254.169.254/latest/meta-data/iam/security-credentials/`. What is this attack called, and how do you mitigate it at the infrastructure level?
This is a Server-Side Request Forgery (SSRF) attack. The attacker is tricking the server into making an HTTP request on their behalf to the internal AWS Instance Metadata Service (IMDS).
Master cloud-native security and container runtime defense: Prepare with KodeKloud's CKS course with live browser-based terminal sandboxes.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "In our DevSecOps implementation, we solved this by introducing automated security quality gates. The interviewer is testing: Server-Side Request Forgery (SSRF), IMDSv1 vs IMDSv2, cloud metadata risks.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Production Solution & Architecture
This is a Server-Side Request Forgery (SSRF) attack. The attacker is tricking the server into making an HTTP request on their behalf to the internal AWS Instance Metadata Service (IMDS). Because the request originates from the EC2 instance itself, it succeeds, and the server dutifully returns the instance's highly privileged, temporary IAM credentials to the attacker. Infrastructure Mitigation: While input validation is necessary, the defense-in-depth infrastructure fix is to enforce IMDSv2 (Instance Metadata Service Version 2) on the EC2 instances. IMDSv2 requires a specific PUT request containing a secret token header before it responds to any GET requests. A basic SSRF vulnerability typically only allows an attacker to forge simple GET requests, rendering the attack against the metadata service useless.
- Immediate Triage: This is a Server-Side Request Forgery (SSRF) attack. The attacker is tricking the server into m
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Revoking compromised credentials immediately without analyzing forensic audit trails for active exploitation when configuring Security native application Deactivating a compromised access key prevents abuse while preserving forensic identity for CloudTrail investigations to assess blast radius.
- Terminating compromised instances immediately during incident triage without isolating volatile RAM state when configuring Security native application Terminating compromised instances immediately destroys volatile memory evidence (RAM dumps) required to establish intrusion timelines.
-
Injecting plaintext secrets into container environment variables rather than fetching from dynamic secret vaults when configuring Security native application
Container environment variables are visible via
docker inspector Kubernetes API queries, leaking sensitive API tokens to developers. - Failing to enforce automated credential rotation for third-party SaaS integration tokens when configuring Security native application Static long-lived API tokens shared across internal services represent the highest-probability vector for supply-chain credential compromise.