惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
S
Secure Thoughts
月光博客
月光博客
美团技术团队
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
W
WeLiveSecurity
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
G
GRAHAM CLULEY
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
罗磊的独立博客
The Register - Security
The Register - Security
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
B
Blog
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Engineering at Meta
Engineering at Meta
Latest news
Latest news
IT之家
IT之家
D
DataBreaches.Net
博客园 - 司徒正美
N
Netflix TechBlog - Medium
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Server-Side Request Forgery (SSRF)
Yuriy Safron · 2026-05-04 · via DEV Community

Your application fetches a URL. The user supplied it. Your server makes the request, follows the redirect, and returns the content.

The URL pointed to http://169.254.169.254/latest/metadata/iam/security-credentials/production-role.

Your application just handed the attacker your cloud credentials.


TL;DR

  • SSRF lets an attacker trick your server into making requests on their behalf — to internal services, cloud metadata endpoints, or infrastructure never meant to be reachable from the outside.
  • CVE-2024-29415 in the npm ip package allowed attackers to bypass SSRF protections using non-standard IP representations that isPublic() incorrectly classified as safe. CVSS 8.1 High.
  • Your suite almost certainly validates that your URL-fetchin feature works. It does not validate that it refuses to fetch http://169.254.169.254/latest/meta-data/ or http://127.1/admin.
  • Fix requires an allowlist of permitted destinations, not a blocklist. Blocklists fail because IP representations are infinite. Allowlists fail only if you misconfigure them.
  • AI-generated tests submit valid URLs and assert correct responses. They never submit internal service addresses. The SSRF surface stays untouched.

What it is

Server-Side Request Forgery (CWE-918, OWASP A10:2021) occurs when an application fetches a remote resource based on a URL supplied by the user without sufficiently validating that the destination is permitted.

The server makes the request with its own credentials and network position. In cloud environments, this means access to the instance metadata service, internal VPC services, Kubernetes API servers, Redis instances — any resource reachable from the server's network context but not from the public internet.

The attacker's HTTP request never touches those services directly. The server makes the request for them.

Developers introduce SSRF when building legitimately useful features: URL preview generation, webhook delivery, import from external URLs, image fetching from user-supplied sources. A developer adds a check to ensure the target is not a private IP address. The check uses a library function. The library function has edge cases the developer never tested. The feature ships, all happy-path tests pass, and the SSRF surface exists silently in production.

What makes SSRF particularly dangerous in cloud and microservices environments is the blast radius. A single vulnerability in one service can expose credentials for the entire cloud account, enable lateral movement to internal APIs, allow enumeration of the internal network topology, and provide an unauthenticated entry point to services that assume they are only reachable from trusted internal callers.


Real world damage

CVE-2024-29415 · npm ip package · May 2024 · CVSS 8.1 (High)

In May 2024, an SSRF vulnerability was published for the ip npm package — a widely used Node.js library for IP address manipulation and validation. The isPublic() function, intended to identify whether an IP address is globally routable, incorrectly classified several non-standard representations as public when they actually resolved to loopback or private addresses.

Representations including 127.1, 01200034567, 012.1.2.3, 000:0:0000::01, and ::fFFf:127.0.0.1 all passed the isPublic() check — meaning applications relying on this function to block SSRF requests would silently allow connections to localhost and private network services.

Source: GitHub Advisory GHSA-2p57-rm9w-gvfp and NVD CVE-2024-29415 (nvd.nist.gov/vuln/detail/CVE-2024-29415). Affected versions: ip through 2.0.1.

In a cloud environment, a request to http://127.1/latest/meta data/ on an AWS EC2 instance routes to the same metadata service as http://169.254.169.254/latest/meta-data/ — potentially exposing IAM credentials. A QA engineer running SSRF payload tests with non-standard IP representations would have caught this. No such tests existed in the pipelines of applications that trusted the ip package for SSRF protection.


The invisible bug problem

Test suites for URL-fetching features test that the feature fetches URLs correctly. They submit a valid external URL, assert a 200 response, and check that content was returned as expected.

Nobody submits http://127.0.0.1/admin, http://169.254.169.254/latest/meta-data/, or http://127.1/config.

The SSRF protection layer is never exercised because all test inputs are exactly what the protection was never designed to reject. The happy path never touches the validation logic from the adversarial direction.

SSRF lives entirely in the space between "what valid input looks like" and "what an attacker would actually submit" — and that space is never covered by tests written by someone thinking about how the feature works rather than how it breaks.


How QA engineers catch it

The core principle: every endpoint that accepts a URL, hostname, or IP address from user input must be tested with a systematic list of SSRF payloads targeting internal and cloud metadata addresses. Not just valid external URLs. Specifically adversarial inputs designed to reach private infrastructure.

SSRF payload reference

# Cloud metadata endpoints
http://169.254.169.254/latest/meta-data/                    # AWS
http://169.254.169.254/latest/meta-data/iam/security-credentials/
http://metadata.google.internal/computeMetadata/v1/         # GCP
http://169.254.169.254/metadata/instance                    # Azure

# Localhost variants
http://127.0.0.1/
http://localhost/
http://0.0.0.0/

# Non-standard representations — bypass naive isPublic() checks
http://127.1/                    # CVE-2024-29415 bypass
http://0x7f000001/               # hexadecimal
http://2130706433/               # decimal
http://012.0.0.1/                # octal

# Internal network ranges
http://192.168.1.1/
http://10.0.0.1/
http://172.16.0.1/

Enter fullscreen mode Exit fullscreen mode

PyTest

import pytest
import requests

BASE_URL = "https://your-app.com"

SSRF_PAYLOADS = [
    # cloud metadata
    "http://169.254.169.254/latest/meta-data/",
    "http://169.254.169.254/latest/meta-data/iam/security-credentials/",
    "http://metadata.google.internal/computeMetadata/v1/",
    "http://169.254.169.254/metadata/instance",
    # localhost variants
    "http://127.0.0.1/",
    "http://localhost/",
    "http://0.0.0.0/",
    # CVE-2024-29415 bypass patterns — non-standard representations
    "http://127.1/",
    "http://0x7f000001/",
    "http://2130706433/",
    "http://012.0.0.1/",
    # internal network ranges
    "http://192.168.1.1/",
    "http://10.0.0.1/",
    "http://172.16.0.1/",
]

METADATA_MARKERS = [
    "ami-id", "instance-id", "computeMetadata",
    "access_key", "secret_access_key", "security-credentials"
]

@pytest.fixture
def auth_session():
    session = requests.Session()
    session.post(f"{BASE_URL}/login", json={
        "username": "testuser",
        "password": "test_password"
    })
    return session

@pytest.mark.parametrize("payload", SSRF_PAYLOADS)
def test_ssrf_payload_rejected(auth_session, payload):
    # every internal/cloud address must be rejected — never 200
    response = auth_session.post(
        f"{BASE_URL}/api/fetch-url",
        json={"url": payload}
    )
    assert response.status_code in [400, 403, 422], (
        f"SSRF payload not rejected: {payload} "
        f"returned {response.status_code}"
    )

@pytest.mark.parametrize("payload", SSRF_PAYLOADS)
def test_ssrf_no_internal_content_in_response(auth_session, payload):
    # even if rejected with wrong status, body must not contain metadata
    response = auth_session.post(
        f"{BASE_URL}/api/fetch-url",
        json={"url": payload}
    )
    body = response.text
    for marker in METADATA_MARKERS:
        assert marker not in body, (
            f"Internal service content '{marker}' found in response "
            f"for payload: {payload}"
        )

def test_ssrf_non_standard_ip_representations(auth_session):
    # CVE-2024-29415: isPublic() bypass via non-standard IP formats
    bypass_payloads = [
        "http://127.1/",
        "http://0x7f000001/",
        "http://2130706433/",
        "http://012.0.0.1/",
    ]
    for payload in bypass_payloads:
        response = auth_session.post(
            f"{BASE_URL}/api/fetch-url",
            json={"url": payload}
        )
        assert response.status_code in [400, 403, 422], (
            f"Non-standard IP bypass not blocked: {payload}"
        )

def test_ssrf_valid_external_url_still_works(auth_session):
    # confirm SSRF protection does not break legitimate requests
    response = auth_session.post(
        f"{BASE_URL}/api/fetch-url",
        json={"url": "https://httpbin.org/get"}
    )
    assert response.status_code == 200

Enter fullscreen mode Exit fullscreen mode

Robot Framework

*** Settings ***
Library    RequestsLibrary
Library    Collections

*** Variables ***
${BASE_URL}    https://your-app.com

@{CLOUD_METADATA}
...    http://169.254.169.254/latest/meta-data/
...    http://169.254.169.254/latest/meta-data/iam/security-credentials/
...    http://metadata.google.internal/computeMetadata/v1/
...    http://169.254.169.254/metadata/instance

@{LOCALHOST_VARIANTS}
...    http://127.0.0.1/
...    http://localhost/
...    http://0.0.0.0/

@{CVE_2024_29415_BYPASSES}
...    http://127.1/
...    http://0x7f000001/
...    http://2130706433/
...    http://012.0.0.1/

@{INTERNAL_RANGES}
...    http://192.168.1.1/
...    http://10.0.0.1/
...    http://172.16.0.1/

@{METADATA_MARKERS}
...    ami-id    instance-id    computeMetadata
...    access_key    secret_access_key    security-credentials

*** Test Cases ***
SSRF Cloud Metadata Endpoints Must Be Rejected
    Create Session    app    ${BASE_URL}
    FOR    ${payload}    IN    @{CLOUD_METADATA}
        ${response}=    POST On Session    app    /api/fetch-url
        ...    json={"url": "${payload}"}    expected_status=any
        Should Be True    ${response.status_code} in [400, 403, 422]
        ...    msg=Cloud metadata payload not rejected: ${payload}
        FOR    ${marker}    IN    @{METADATA_MARKERS}
            Should Not Contain    ${response.text}    ${marker}
        END
    END

SSRF Localhost Variants Must Be Rejected
    Create Session    app    ${BASE_URL}
    FOR    ${payload}    IN    @{LOCALHOST_VARIANTS}
        ${response}=    POST On Session    app    /api/fetch-url
        ...    json={"url": "${payload}"}    expected_status=any
        Should Be True    ${response.status_code} in [400, 403, 422]
        ...    msg=Localhost variant not rejected: ${payload}
    END

SSRF CVE-2024-29415 Bypass Representations Must Be Rejected
    # non-standard IP formats that bypass naive isPublic() checks
    Create Session    app    ${BASE_URL}
    FOR    ${payload}    IN    @{CVE_2024_29415_BYPASSES}
        ${response}=    POST On Session    app    /api/fetch-url
        ...    json={"url": "${payload}"}    expected_status=any
        Should Be True    ${response.status_code} in [400, 403, 422]
        ...    msg=CVE-2024-29415 bypass not blocked: ${payload}
    END

SSRF Internal Network Ranges Must Be Rejected
    Create Session    app    ${BASE_URL}
    FOR    ${payload}    IN    @{INTERNAL_RANGES}
        ${response}=    POST On Session    app    /api/fetch-url
        ...    json={"url": "${payload}"}    expected_status=any
        Should Be True    ${response.status_code} in [400, 403, 422]
        ...    msg=Internal range not rejected: ${payload}
    END

SSRF Valid External URL Still Works
    # confirm protection does not break legitimate requests
    Create Session    app    ${BASE_URL}
    ${response}=    POST On Session    app    /api/fetch-url
    ...    json={"url": "https://httpbin.org/get"}
    Should Be Equal As Strings    ${response.status_code}    200

Enter fullscreen mode Exit fullscreen mode

TypeScript — Playwright API testing

import { test, expect, APIRequestContext } from '@playwright/test';

const SSRF_PAYLOADS = {
  cloudMetadata: [
    'http://169.254.169.254/latest/meta-data/',
    'http://169.254.169.254/latest/meta-data/iam/security-credentials/',
    'http://metadata.google.internal/computeMetadata/v1/',
    'http://169.254.169.254/metadata/instance',
  ],
  localhostVariants: [
    'http://127.0.0.1/',
    'http://localhost/',
    'http://0.0.0.0/',
  ],
  // CVE-2024-29415: non-standard representations bypass isPublic()
  cve202429415Bypasses: [
    'http://127.1/',
    'http://0x7f000001/',
    'http://2130706433/',
    'http://012.0.0.1/',
  ],
  internalRanges: [
    'http://192.168.1.1/',
    'http://10.0.0.1/',
    'http://172.16.0.1/',
  ],
};

const METADATA_MARKERS = [
  'ami-id', 'instance-id', 'computeMetadata',
  'access_key', 'secret_access_key', 'security-credentials',
];

let apiContext: APIRequestContext;

test.beforeAll(async ({ playwright }) => {
  apiContext = await playwright.request.newContext({
    baseURL: 'https://your-app.com',
  });
  await apiContext.post('/login', {
    data: { username: 'testuser', password: 'test_password' }
  });
});

test.afterAll(async () => {
  await apiContext.dispose();
});

for (const payload of SSRF_PAYLOADS.cloudMetadata) {
  test(`SSRF — cloud metadata rejected: ${payload}`, async () => {
    const response = await apiContext.post('/api/fetch-url', {
      data: { url: payload }
    });

    expect(
      [400, 403, 422],
      `Cloud metadata payload not rejected: ${payload}`
    ).toContain(response.status());

    const body = await response.text();
    for (const marker of METADATA_MARKERS) {
      expect(body, `Metadata marker '${marker}' found for: ${payload}`)
        .not.toContain(marker);
    }
  });
}

for (const payload of SSRF_PAYLOADS.localhostVariants) {
  test(`SSRF — localhost variant rejected: ${payload}`, async () => {
    const response = await apiContext.post('/api/fetch-url', {
      data: { url: payload }
    });
    expect(
      [400, 403, 422],
      `Localhost variant not rejected: ${payload}`
    ).toContain(response.status());
  });
}

for (const payload of SSRF_PAYLOADS.cve202429415Bypasses) {
  test(`SSRF — CVE-2024-29415 bypass rejected: ${payload}`, async () => {
    // non-standard IP formats that bypass naive isPublic() checks
    const response = await apiContext.post('/api/fetch-url', {
      data: { url: payload }
    });
    expect(
      [400, 403, 422],
      `CVE-2024-29415 bypass not blocked: ${payload}`
    ).toContain(response.status());
  });
}

for (const payload of SSRF_PAYLOADS.internalRanges) {
  test(`SSRF — internal range rejected: ${payload}`, async () => {
    const response = await apiContext.post('/api/fetch-url', {
      data: { url: payload }
    });
    expect(
      [400, 403, 422],
      `Internal range not rejected: ${payload}`
    ).toContain(response.status());
  });
}

test('SSRF — valid external URL still works', async () => {
  // confirm SSRF protection does not break legitimate requests
  const response = await apiContext.post('/api/fetch-url', {
    data: { url: 'https://httpbin.org/get' }
  });
  expect(response.status()).toBe(200);
});

Enter fullscreen mode Exit fullscreen mode

Run SSRF tests in isolation:

npx playwright test --grep "SSRF"

Enter fullscreen mode Exit fullscreen mode

CI/CD gate

ssrf-security-tests:
  stage: test
  script:
    - pytest tests/security/test_ssrf.py -v
    - npx playwright test --grep "SSRF"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  allow_failure: false

Enter fullscreen mode Exit fullscreen mode

Pair with a Semgrep rule that flags calls to requests.get(), fetch(), or axios.get() where the URL argument derives from user input without a preceding allowlist check. The static check catches new vulnerable patterns before they reach the test environment.

Environment note

SSRF behavior changes significantly between local development and cloud deployment. A test that passes locally because the development environment has no metadata service may completely miss that the same request succeeds in production against http://169.254.169.254/.

Run your SSRF payload suite against an environment that mirrors the cloud infrastructure, ideally one where the metadata service is reachable so a successful bypass is caught as a test failure rather than silently passing.

If you run on Kubernetes, also test against internal service DNS names resolvable from within the cluster, since SSRF in a Kubernetes environment can expose the API server and other cluster-internal services.


Why AI fails here

When a team asks GitHub Copilot to write tests for a URL-fetching endpoint, it writes tests that submit a valid external URL and assert that content is returned correctly. The SSRF protection layer is never exercised because the test inputs are exactly what the protection was never designed to intercept.

The structural reason LLMs fail at SSRF: the vulnerability exists in the relationship between the feature and the infrastructure around it.
Testing for SSRF requires knowing that http://169.254.169.254/ is significant, that http://127.1/ resolves to loopback, and that a cloud server's network context gives it access to resources an internet client cannot reach. This context does not come from the code being tested. It comes from understanding the deployment environment, the cloud provider's architecture, and the history of SSRF bypass techniques.

The concrete failure: a team builds a webhook delivery system that validates the destination URL before sending. They use ip.isPublic() as the guard. Copilot generates twelve tests. All pass. The tests submit valid external domains and assert they are accepted. The tests submit obvious private addresses like http://192.168.1.1/ and assert they are rejected. Three months after release, a penetration tester submits http://127.1/admin as the webhook URL. isPublic("127.1") returns true. The server makes the request. The tester receives the internal admin panel response. The Copilot suite had zero tests for non-standard IP representations.


How to prevent

1. Allowlist of permitted outbound destinations — define the specific external domains or IP ranges your application legitimately needs to reach in each feature and permit only those. Every other destination is rejected before any network request is made. An allowlist does not need to enumerate all possible attack representations. If the destination is not explicitly permitted, it is rejected by default.

2. Post-resolution IP validation — after resolving a user supplied hostname to its canonical IP address, check the resolved IP against forbidden ranges using a hardened library that handles all standard and non-standard representations. This catches DNS rebinding attacks because the check happens on the resolved IP, not the original hostname. It catches encoding bypass attacks because the resolved IP is always in standard dotted-decimal notation after resolution.

3. Network-level defense in depth — configure your deployment infrastructure so that application servers running user-facing features cannot reach the cloud metadata service, internal database ports, or Kubernetes API server even if application-level SSRF protection fails. On AWS, use IMDSv2 to prevent unauthenticated metadata retrieval. Apply security group rules that explicitly deny outbound connections from application servers to internal service ranges.

Prevention only works when the SSRF payload suite verifies it under adversarial inputs, including the non-standard IP representations that bypass naive checks. A validation function that blocks 127.0.0.1 but allows 127.1 is not a validation function. The test suite is the only way to know the difference.


Conclusion

SSRF in those environments is not a theoretical finding. It is the vector that collapses the boundary between the public internet and internal control plane infrastructure.

The consistent pattern across every system I have tested: developers did not fail to implement SSRF protection. They implemented it using blocklists, trusted library functions without testing edge cases, and never generated the adversarial payloads that would have revealed the gaps.

Writing a test that submits http://127.1/ takes thirty seconds. Not writing it costs you the metadata service.


Part of the Break It on Purpose series, published weekly for QA
engineers and SDETs who find bugs before attackers do.