Server-Side Request Forgery (SSRF) Detection
You are performing a focused security assessment to find SSRF vulnerabilities in a codebase. This skill uses a three-phase approach with subagents: recon (find all places that make outbound TCP, DNS, or HTTP requests), batched verify (trace whether user-supplied input reaches those call sites, in parallel batches of 3), and merge (consolidate batch reports into one file).
Prerequisites: sast/architecture.md must exist. Run the analysis skill first if it doesn't.
What is SSRF
SSRF occurs when an attacker can cause the server to make outbound network requests to an arbitrary destination — including internal services, cloud metadata endpoints, or other external targets — by supplying or influencing the URL, hostname, IP, or port used in a server-side request.
The core pattern: unvalidated, user-controlled input reaches the destination argument of an outbound network call.
What SSRF IS
- HTTP client calls where the URL or host is built from user input:
requests.get(user_url)
- Fetching a resource whose location is provided by the client:
fetch(req.body.webhook_url)
- DNS lookups on a hostname supplied by the user:
dns.lookup(req.query.host)
- Raw TCP connections to a host/port derived from user input:
socket.connect((user_host, user_port))
- File-fetching functions used with HTTP/FTP URLs from user input:
file_get_contents($user_url)
- URL redirectors that forward to a user-supplied destination without validation
- Webhooks, import-from-URL, screenshot services, PDF renderers, image proxies — any feature that fetches a remote resource on behalf of the user
What SSRF is NOT
Do not flag these:
- Open redirects: Redirecting the browser (HTTP 302) to a user-supplied URL — that's a client-side redirect, not a server-side request
- XSS via URL: Rendering a user-supplied URL in an
<a> tag without escaping — that's XSS
- IDOR: Accessing another user's data by changing an object ID — separate vulnerability class
- Hardcoded outbound calls: HTTP requests to fixed, fully hardcoded URLs with no user influence — not SSRF
Patterns That Prevent SSRF
When you see these patterns, the code is likely not vulnerable:
1. Strict allowlist of permitted destinations
ALLOWED_HOSTS = {"api.example.com", "cdn.example.com"}
parsed = urlparse(user_url)
if parsed.hostname not in ALLOWED_HOSTS:
raise ValueError("Destination not allowed")
requests.get(user_url)
2. Allowlist of permitted URL prefixes / schemes
ALLOWED_PREFIXES = ["https://api.example.com/", "https://cdn.example.com/"]
if not any(user_url.startswith(p) for p in ALLOWED_PREFIXES):
abort(400)
requests.get(user_url)
3. No user influence on the destination
# Destination fully hardcoded — no user input involved
response = requests.get("https://api.thirdparty.com/data")
Note: IP blocklists (blocking 169.254.0.0/16, 10.0.0.0/8, etc.) are not sufficient protection — they can be bypassed via DNS rebinding, URL encoding, IPv6 notation, decimal IP representation, or redirect chains. Do not treat a blocklist as making a site safe; classify it as Likely Vulnerable.
Vulnerable vs. Secure Examples
Python — requests
# VULNERABLE: URL fully controlled by user
@app.route('/fetch')
def fetch():
url = request.args.get('url')
response = requests.get(url)
return response.text
# SECURE: strict allowlist on destination host
ALLOWED = {"api.example.com"}
@app.route('/fetch')
def fetch():
url = request.args.get('url')
if urlparse(url).hostname not in ALLOWED:
abort(403)
response = requests.get(url)
return response.text
Python — urllib
# VULNERABLE: user controls the URL passed to urlopen
def preview(request):
target = request.GET.get('target')
data = urllib.request.urlopen(target).read()
return HttpResponse(data)
# SECURE: only allow https scheme to a hardcoded host
def preview(request):
target = request.GET.get('target')
parsed = urlparse(target)
if parsed.scheme != 'https' or parsed.hostname != 'media.example.com':
return HttpResponse(status=400)
data = urllib.request.urlopen(target).read()
return HttpResponse(data)
Node.js — fetch / axios
// VULNERABLE: webhook URL comes directly from request body
app.post('/webhook/test', async (req, res) => {
const { url } = req.body;
const result = await fetch(url);
res.json(await result.json());
});
// SECURE: allowlist check before fetch
const ALLOWED_HOSTS = new Set(['hooks.example.com']);
app.post('/webhook/test', async (req, res) => {
const { url } = req.body;
const { hostname } = new URL(url);
if (!ALLOWED_HOSTS.has(hostname)) return res.status(403).send('Forbidden');
const result = await fetch(url);
res.json(await result.json());
});
Node.js — http.request
// VULNERABLE: host and path from query string
app.get('/proxy', (req, res) => {
const { host, path } = req.query;
http.get({ host, path }, (proxyRes) => proxyRes.pipe(res));
});
Ruby on Rails — Net::HTTP / OpenURI
# VULNERABLE: open() fetches arbitrary URL
def import
url = params[:url]
content = URI.open(url).read # also triggers for open(url) via Kernel#open
# ...
end
# SECURE: restrict scheme and host
def import
url = params[:url]
uri = URI.parse(url)
raise "Forbidden" unless uri.is_a?(URI::HTTPS) && uri.host == "data.example.com"
content = uri.open.read
# ...
end
PHP — cURL
// VULNERABLE: user-supplied URL piped into curl
function fetch_preview($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Called as: fetch_preview($_GET['url'])
// SECURE: validate URL against allowlist before curl
function fetch_preview($url) {
$allowed = ['https://cdn.example.com/'];
foreach ($allowed as $prefix) {
if (strpos($url, $prefix) === 0) {
// ... proceed with curl
}
}
throw new Exception("Destination not allowed");
}
PHP — file_get_contents
// VULNERABLE: file_get_contents with http:// wrapper and user input
$url = $_GET['source'];
$data = file_get_contents($url); // fetches remote URL if scheme is http/https/ftp
Java — Spring / OkHttp
// VULNERABLE: RestTemplate with user-controlled URL
@GetMapping("/proxy")
public ResponseEntity<String> proxy(@RequestParam String url) {
RestTemplate restTemplate = new RestTemplate();
return restTemplate.getForEntity(url, String.class);
}
// VULNERABLE: OkHttp with user-controlled host
public String fetch(String host, String path) {
Request request = new Request.Builder()
.url("https://" + host + path)
.build();
return client.newCall(request).execute().body().string();
}
Go — net/http
// VULNERABLE: user-supplied URL passed to http.Get
func proxyHandler(w http.ResponseWriter, r *http.Request) {
target := r.URL.Query().Get("url")
resp, err := http.Get(target)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
io.Copy(w, resp.Body)
}
// VULNERABLE: user controls host in net.Dial
func dialHandler(w http.ResponseWriter, r *http.Request) {
host := r.URL.Query().Get("host")
port := r.URL.Query().Get("port")
conn, _ := net.Dial("tcp", host+":"+port)
// ...
}
C# — HttpClient
// VULNERABLE: user-supplied URL passed to HttpClient
[HttpGet("proxy")]
public async Task<IActionResult> Proxy([FromQuery] string url)
{
var response = await _httpClient.GetAsync(url);
var content = await response.Content.ReadAsStringAsync();
return Content(content);
}
Execution
This skill runs in three phases using subagents. Pass the contents of sast/architecture.md to all subagents as context.
Phase 1: Find All Outbound Network Call Sites
Launch a subagent with the following instructions:
Goal: Find every location in the codebase where the application makes an outbound network request — HTTP, HTTPS, FTP, TCP, or DNS — regardless of whether that destination is user-controlled. Write results to sast/ssrf-recon.md.
Context: You will be given the project's architecture summary. Use it to understand the tech stack, HTTP client libraries in use, and any networking or webhook-related components.
What to search for — outbound request call sites:
You are looking for any code that opens a network connection or fetches a remote resource. Flag ANY call where a non-trivially-hardcoded URL, host, or address value is passed as an argument. You are not yet tracing whether that value is user-controlled; that is Phase 2's job.
Python HTTP clients:
requests.get(url), requests.post(url), requests.put(url), requests.request(method, url), requests.Session().get(url)
urllib.request.urlopen(url), urllib2.urlopen(url)
httpx.get(url), httpx.post(url), httpx.AsyncClient().get(url)
aiohttp.ClientSession().get(url), aiohttp.ClientSession().post(url)
Python socket / DNS:
socket.connect((host, port)), socket.create_connection((host, port))
dns.resolver.resolve(name), socket.getaddrinfo(host, ...)
Python file-fetching with remote schemes:
urllib.request.urlopen(url) where url may be http/https/ftp
open(url) via from urllib.request import urlopen or similar (flag if url may be remote)
Node.js / JavaScript HTTP clients:
fetch(url), node-fetch(url)
axios.get(url), axios.post(url), axios.request({url})
http.get(url), https.get(url), http.request(options), https.request(options)
got(url), superagent.get(url), needle.get(url), undici.request(url)
require('request')(options)
Node.js socket / DNS:
net.createConnection({host, port}), net.connect(port, host)
dns.lookup(hostname, ...), dns.resolve(hostname, ...), dns.resolve4(hostname)
Ruby HTTP clients:
Net::HTTP.get(uri), Net::HTTP.start(host, ...), Net::HTTP.get_response(url)
URI.open(url), open(url) (Kernel#open / OpenURI)
RestClient.get(url), RestClient::Resource.new(url)
Faraday.new(url).get(path), HTTParty.get(url)
Typhoeus::Request.new(url)
PHP HTTP clients and file functions:
curl_setopt($ch, CURLOPT_URL, $url) followed by curl_exec($ch)
file_get_contents($url) — flag when $url may be an http/https/ftp URL
fopen($url, 'r') with a remote URL scheme
Guzzle: $client->request('GET', $url), $client->get($url)
Symfony HttpClient: $client->request('GET', $url)
Java HTTP clients:
new URL(url).openConnection(), new URL(url).openStream()
HttpURLConnection / HttpsURLConnection with a dynamic URL
OkHttpClient().newCall(new Request.Builder().url(url)...)
RestTemplate.getForObject(url, ...), RestTemplate.getForEntity(url, ...)
WebClient.get().uri(url), WebClient.create(url)
Apache HttpClient: httpClient.execute(new HttpGet(url))
Go HTTP clients and network dials:
http.Get(url), http.Post(url, ...), http.NewRequest("GET", url, ...)
net.Dial("tcp", addr), net.DialTCP(...), net.DialTimeout("tcp", addr, ...)
net.LookupHost(hostname), net.LookupAddr(addr), net.ResolveIPAddr(...)
net.ResolveTCPAddr("tcp", addr)
C# / .NET HTTP clients:
HttpClient.GetAsync(url), HttpClient.PostAsync(url, ...), HttpClient.SendAsync(request)
WebRequest.Create(url), WebClient.DownloadString(url), WebClient.DownloadData(url)
HttpWebRequest with a dynamic URL
Shell-out to network tools (via subprocess, exec, system, etc.):
subprocess.run(["curl", url, ...]), subprocess.Popen(["wget", url, ...])
os.system("curl " + url), exec("wget " + url)
- Any
curl, wget, nc, ncat, nmap invocation where the target is a variable
What to skip (these are safe — do not flag):
- Calls where the entire URL and hostname are fully hardcoded string literals with no dynamic parts:
requests.get("https://api.example.com/data")
- Internal loopback connections to
localhost or 127.0.0.1 that are clearly part of service-to-service architecture (e.g., connecting to a local queue) — flag these if the address is dynamic
Output format — write to sast/ssrf-recon.md:
# SSRF Recon: [Project Name]
## Summary
Found [N] outbound network call sites.
## Outbound Call Sites
### 1. [Descriptive name — e.g., "HTTP GET in webhook dispatcher"]
- **File**: `path/to/file.ext` (lines X-Y)
- **Function / endpoint**: [function name or route]
- **Call type**: [HTTP GET / HTTP POST / TCP dial / DNS lookup / subprocess curl / etc.]
- **Library / method**: [requests.get / fetch / http.Get / curl_exec / etc.]
- **Destination argument**: `var_name` or `url_expression` — [brief note, e.g., "assembled from query param" or "partially hardcoded path with variable host"]
- **Code snippet**:
[the outbound call and the lines immediately before it that construct the destination]
[Repeat for each site]
After Phase 1: Check for Candidates Before Proceeding
After Phase 1 completes, read sast/ssrf-recon.md. If the recon found zero outbound call sites (the summary reports "Found 0" or the "Outbound Call Sites" section is empty or absent), skip Phase 2 and Phase 3 entirely. Instead, write the following content to sast/ssrf-results.md and stop:
# SSRF Analysis Results
No vulnerabilities found.
Only proceed to Phase 2 if Phase 1 found at least one outbound call site.
Phase 2: Verify — Trace User Input to Outbound Call Sites (Batched)
After Phase 1 completes, read sast/ssrf-recon.md and split the outbound call sites into batches of up to 3 sites each. Launch one subagent per batch in parallel. Each subagent traces taint only for its assigned sites and writes results to its own batch file.
Batching procedure (you, the orchestrator, do this — not a subagent):
- Read
sast/ssrf-recon.md and count the numbered site sections (### 1., ### 2., etc.) under "Outbound Call Sites".
- Divide them into batches of up to 3. For example, 8 sites → 3 batches (1-3, 4-6, 7-8).
- For each batch, extract the full text of those site sections from the recon file.
- Launch all batch subagents in parallel, passing each one only its assigned sites.
- Each subagent writes to
sast/ssrf-batch-N.md where N is the 1-based batch number.
- Identify the project's primary language/framework from
sast/architecture.md and select only the matching examples from the "Vulnerable vs. Secure Examples" section above. For example, if the project uses Node.js with fetch/axios, include only the "Node.js — fetch / axios" and "Node.js — http.request" examples. Include these selected examples in each subagent's instructions where indicated by [TECH-STACK EXAMPLES] below.
Give each batch subagent the following instructions (substitute the batch-specific values):
Goal: For each assigned outbound network call site, determine whether a user-supplied value controls or influences the destination (URL, host, path, port, or scheme). Our goal is to find SSRF vulnerabilities. Write results to sast/ssrf-batch-[N].md.
Your assigned outbound call sites (from the recon phase):
[Paste the full text of the assigned site sections here, preserving the original numbering]
Context: You will be given the project's architecture summary. Use it to understand entry points, middleware, and how data flows through the application.
SSRF reference — what to look for:
SSRF occurs when user-controlled input reaches the destination argument of a server-side outbound network call without an effective allowlist on where the server may connect.
What SSRF is NOT — do not flag these as SSRF:
- Open redirects: HTTP 302 to a user URL — client-side redirect, not a server-side request
- XSS via URL: User URL rendered in HTML without escaping — XSS
- IDOR: Object ID tampering — separate class
- Fully hardcoded outbound URLs with no user influence — not SSRF
For each outbound call site, trace the destination argument(s) backwards to their origin:
Direct user input — the destination is assigned directly from a request source with no transformation:
- HTTP query params:
request.GET.get('url'), req.query.url, params[:url], $_GET['url'], c.Query("url")
- Request body / JSON fields:
request.json['webhook_url'], req.body.target, params[:source]
- Path parameters:
req.params.host, params[:endpoint]
- HTTP headers:
request.headers.get('X-Forwarded-For'), req.headers['destination']
- Cookies:
req.cookies.redirect_url
Indirect / assembled destination — the URL is built by concatenating a hardcoded prefix with a user-supplied suffix or path:
"https://example.com/" + user_path — may still be exploitable via path traversal or scheme injection depending on the HTTP client
base_url + user_query — user controls the query string, potentially injectable
- Flag these as Likely Vulnerable and note which portion is user-controlled
User input stored and later fetched — the destination was previously saved from user input (e.g., a stored webhook URL) and is now retrieved from the database to make a request:
- Find where the stored value was written — was it accepted from user input without allowlist validation at write time?
- Was any validation applied at read time before the request?
Server-side / hardcoded value — the destination comes from config, an environment variable, a hardcoded constant, or server-side logic with no user influence — this site is NOT exploitable.
For each call site, also check for mitigations:
- Strict allowlist of hosts/prefixes: A hardcoded set of permitted hostnames or URL prefixes that the destination is validated against before the request is made — this is an effective mitigation. Mark as Not Vulnerable.
- Scheme-only restriction (e.g., only allow
https://): Partial mitigation — reduces impact but does not prevent SSRF to arbitrary HTTPS hosts. Still flag as Likely Vulnerable.
- Blocklist of private IP ranges / metadata endpoints:
169.254.169.254, 10.0.0.0/8, 192.168.0.0/16, etc. — not sufficient. Bypassable via DNS rebinding, alternate IP representations, and redirect chains. Flag as Likely Vulnerable.
- DNS resolution + IP check (resolve hostname first, then check resolved IP against blocklist): Stronger than a pure blocklist, but still susceptible to DNS rebinding between the check and the request (TOCTOU). Flag as Likely Vulnerable unless the same resolved IP is explicitly pinned for the request.
Vulnerable vs. secure examples for this project's tech stack:
[TECH-STACK EXAMPLES]
Classification:
- Vulnerable: User input demonstrably reaches the outbound request destination with no effective mitigation (no allowlist or only a blocklist/scheme check).
- Likely Vulnerable: User input probably reaches the destination (indirect flow or partial construction), or only weak mitigation is present (blocklist, scheme-only check, partial URL prefix).
- Not Vulnerable: The destination is fully server-side, OR a strict host/prefix allowlist is enforced before the request.
- Needs Manual Review: Cannot determine the destination's origin with confidence (opaque helpers, complex conditional flows, or external libraries that resolve the URL).
Output format — write to sast/ssrf-batch-[N].md:
# SSRF Batch [N] Results
## Findings
### [VULNERABLE] Descriptive name
- **File**: `path/to/file.ext` (lines X-Y)
- **Endpoint / function**: [route or function name]
- **Issue**: [e.g., "HTTP query param `url` flows directly into requests.get()"]
- **Taint trace**: [Step-by-step from entry point to the call site — e.g., "request.args.get('url') → target_url → requests.get(target_url)"]
- **Impact**: [What an attacker can do — access cloud metadata at 169.254.169.254, pivot to internal services, port scan the internal network, exfiltrate data, bypass firewalls, etc.]
- **Mitigation present**: [None / Blocklist only / Scheme check only — explain why it's insufficient]
- **Remediation**: [Strict host allowlist, or remove user control over destination entirely]
- **Dynamic Test**:
[curl command or payload to confirm the finding.
Show the parameter, payload, and what to look for.
Example: curl "https://app.example.com/fetch?url=http://169.254.169.254/latest/meta-data/"
or for internal pivot: curl "https://app.example.com/fetch?url=http://internal-db:5432/"]
### [LIKELY VULNERABLE] Descriptive name
- **File**: `path/to/file.ext` (lines X-Y)
- **Endpoint / function**: [route or function name]
- **Issue**: [e.g., "User controls the path portion of a partially hardcoded URL" or "Stored webhook URL accepted without allowlist at write time"]
- **Taint trace**: [Best-effort trace with the uncertain or partial-control step identified]
- **Concern**: [Why it's still a risk — e.g., "Attacker may be able to redirect to an internal host via path traversal" or "Blocklist is bypassable via DNS rebinding"]
- **Remediation**: [Strict allowlist or remove user control]
- **Dynamic Test**:
[payload to attempt — e.g., path traversal or DNS rebinding scenario]
### [NOT VULNERABLE] Descriptive name
- **File**: `path/to/file.ext` (lines X-Y)
- **Endpoint / function**: [route or function name]
- **Reason**: [e.g., "URL is fully hardcoded" or "Strict host allowlist enforced before request"]
### [NEEDS MANUAL REVIEW] Descriptive name
- **File**: `path/to/file.ext` (lines X-Y)
- **Endpoint / function**: [route or function name]
- **Uncertainty**: [Why the destination's origin could not be determined]
- **Suggestion**: [What to trace manually — e.g., "Follow `resolve_target()` in helpers.py to check where the URL originates"]
Phase 3: Merge — Consolidate Batch Results
After all Phase 2 batch subagents complete, read every sast/ssrf-batch-*.md file and merge them into a single sast/ssrf-results.md. You (the orchestrator) do this directly — no subagent needed.
Merge procedure:
- Read all
sast/ssrf-batch-1.md, sast/ssrf-batch-2.md, ... files.
- Collect all findings from each batch file and combine them into one list, preserving the original classification and all detail fields.
- Count totals across all batches for the executive summary (total sites analyzed equals the number from recon / sum of assigned sites).
- Write the merged report to
sast/ssrf-results.md using this format:
# SSRF Analysis Results: [Project Name]
## Executive Summary
- Outbound call sites analyzed: [total across all batches]
- Vulnerable: [N]
- Likely Vulnerable: [N]
- Not Vulnerable: [N]
- Needs Manual Review: [N]
## Findings
[All findings from all batches, grouped by classification:
VULNERABLE first, then LIKELY VULNERABLE, then NEEDS MANUAL REVIEW, then NOT VULNERABLE.
Preserve every field from the batch results exactly as written.]
- After writing
sast/ssrf-results.md, delete all intermediate batch files (sast/ssrf-batch-*.md).
Important Reminders
- Read
sast/architecture.md and pass its content to all subagents as context.
- Phase 2 must run AFTER Phase 1 completes — it depends on the recon output.
- Phase 3 must run AFTER all Phase 2 batches complete — it depends on all batch outputs.
- Batch size is 3 outbound call sites per subagent. If there are 1-3 sites total, use a single subagent. If there are 10, use 4 subagents (3+3+3+1).
- Launch all batch subagents in parallel — do not run them sequentially.
- Each batch subagent receives only its assigned sites' text from the recon file, not the entire recon file. This keeps each subagent's context small and focused.
- Phase 1 is purely structural: flag any call site where the destination argument is dynamic (a variable, expression, or assembled string), regardless of whether user input flows there. Do not attempt to trace user input in Phase 1 — that is Phase 2's job.
- Phase 2 is purely taint analysis: for each site in its batch, trace the destination argument back to its origin. If it comes from a user-controlled source without an effective allowlist, the site is a real vulnerability.
- Blocklists are not mitigations: IP blocklists for private ranges and cloud metadata endpoints are easily bypassed. Always classify such sites as Vulnerable or Likely Vulnerable, not as safe.
- Partial URL control is still dangerous: even if the attacker only controls the path or query string portion of the URL, flag it as Likely Vulnerable — depending on the HTTP client behavior, redirect following, and target service, partial control can be enough.
- Stored destinations are tainted: if a URL or hostname was accepted from user input at write time and is later used for an outbound request, trace the write-time acceptance. Lack of allowlist validation at write time makes it SSRF.
- Subprocess curl/wget is SSRF too: shell-outs that run
curl or wget with a user-supplied URL are just as dangerous as HTTP client calls. Check for these, especially in image-processing, import, or download features.
- When in doubt, classify as "Needs Manual Review" rather than "Not Vulnerable". False negatives are worse than false positives in security assessment.
- DNS rebinding note: for findings where only a DNS-resolution-then-blocklist check is present, note the TOCTOU window explicitly in the finding — this is a known bypass technique.
- Clean up intermediate files: delete
sast/ssrf-recon.md and all sast/ssrf-batch-*.md files after the final sast/ssrf-results.md is written.
1---
2name: sast-ssrf
3description: >-
4 Detect Server-Side Request Forgery (SSRF) vulnerabilities in a codebase using
5 a three-phase approach: recon (find outbound call sites), batched verify (trace
6 user input to destinations in parallel subagents, 3 sites each), and merge
7 (consolidate batch results). Requires sast/architecture.md (run sast-analysis
8 first). Outputs findings to sast/ssrf-results.md. Use when asked to find SSRF
9 or server-side request forgery bugs.
10metadata:
11 source: https://skillmd.com/skills/aibot88/sast-ssrf
12---
13
14# Server-Side Request Forgery (SSRF) Detection
15
16You are performing a focused security assessment to find SSRF vulnerabilities in a codebase. This skill uses a three-phase approach with subagents: **recon** (find all places that make outbound TCP, DNS, or HTTP requests), **batched verify** (trace whether user-supplied input reaches those call sites, in parallel batches of 3), and **merge** (consolidate batch reports into one file).
17
18**Prerequisites**: `sast/architecture.md` must exist. Run the analysis skill first if it doesn't.
19
20---
21
22## What is SSRF
23
24SSRF occurs when an attacker can cause the server to make outbound network requests to an arbitrary destination — including internal services, cloud metadata endpoints, or other external targets — by supplying or influencing the URL, hostname, IP, or port used in a server-side request.
25
26The core pattern: *unvalidated, user-controlled input reaches the destination argument of an outbound network call.*
27
28### What SSRF IS
29
30- HTTP client calls where the URL or host is built from user input: `requests.get(user_url)`
31- Fetching a resource whose location is provided by the client: `fetch(req.body.webhook_url)`
32- DNS lookups on a hostname supplied by the user: `dns.lookup(req.query.host)`
33- Raw TCP connections to a host/port derived from user input: `socket.connect((user_host, user_port))`
34- File-fetching functions used with HTTP/FTP URLs from user input: `file_get_contents($user_url)`
35- URL redirectors that forward to a user-supplied destination without validation
36- Webhooks, import-from-URL, screenshot services, PDF renderers, image proxies — any feature that fetches a remote resource on behalf of the user
37
38### What SSRF is NOT
39
40Do not flag these:
41
42- **Open redirects**: Redirecting the browser (HTTP 302) to a user-supplied URL — that's a client-side redirect, not a server-side request
43- **XSS via URL**: Rendering a user-supplied URL in an `<a>` tag without escaping — that's XSS
44- **IDOR**: Accessing another user's data by changing an object ID — separate vulnerability class
45- **Hardcoded outbound calls**: HTTP requests to fixed, fully hardcoded URLs with no user influence — not SSRF
46
47### Patterns That Prevent SSRF
48
49When you see these patterns, the code is likely **not vulnerable**:
50
51**1. Strict allowlist of permitted destinations**
52```python
53ALLOWED_HOSTS = {"api.example.com", "cdn.example.com"}
54parsed = urlparse(user_url)
55if parsed.hostname not in ALLOWED_HOSTS:
56 raise ValueError("Destination not allowed")
57requests.get(user_url)
58```
59
60**2. Allowlist of permitted URL prefixes / schemes**
61```python
62ALLOWED_PREFIXES = ["https://api.example.com/", "https://cdn.example.com/"]
63if not any(user_url.startswith(p) for p in ALLOWED_PREFIXES):
64 abort(400)
65requests.get(user_url)
66```
67
68**3. No user influence on the destination**
69```python
70# Destination fully hardcoded — no user input involved
71response = requests.get("https://api.thirdparty.com/data")
72```
73
74> **Note**: IP blocklists (blocking 169.254.0.0/16, 10.0.0.0/8, etc.) are **not** sufficient protection — they can be bypassed via DNS rebinding, URL encoding, IPv6 notation, decimal IP representation, or redirect chains. Do not treat a blocklist as making a site safe; classify it as Likely Vulnerable.
75
76---
77
78## Vulnerable vs. Secure Examples
79
80### Python — requests
81
82```python
83# VULNERABLE: URL fully controlled by user
84@app.route('/fetch')
85def fetch():
86 url = request.args.get('url')
87 response = requests.get(url)
88 return response.text
89
90# SECURE: strict allowlist on destination host
91ALLOWED = {"api.example.com"}
92@app.route('/fetch')
93def fetch():
94 url = request.args.get('url')
95 if urlparse(url).hostname not in ALLOWED:
96 abort(403)
97 response = requests.get(url)
98 return response.text
99```
100
101### Python — urllib
102
103```python
104# VULNERABLE: user controls the URL passed to urlopen
105def preview(request):
106 target = request.GET.get('target')
107 data = urllib.request.urlopen(target).read()
108 return HttpResponse(data)
109
110# SECURE: only allow https scheme to a hardcoded host
111def preview(request):
112 target = request.GET.get('target')
113 parsed = urlparse(target)
114 if parsed.scheme != 'https' or parsed.hostname != 'media.example.com':
115 return HttpResponse(status=400)
116 data = urllib.request.urlopen(target).read()
117 return HttpResponse(data)
118```
119
120### Node.js — fetch / axios
121
122```javascript
123// VULNERABLE: webhook URL comes directly from request body
124app.post('/webhook/test', async (req, res) => {
125 const { url } = req.body;
126 const result = await fetch(url);
127 res.json(await result.json());
128});
129
130// SECURE: allowlist check before fetch
131const ALLOWED_HOSTS = new Set(['hooks.example.com']);
132app.post('/webhook/test', async (req, res) => {
133 const { url } = req.body;
134 const { hostname } = new URL(url);
135 if (!ALLOWED_HOSTS.has(hostname)) return res.status(403).send('Forbidden');
136 const result = await fetch(url);
137 res.json(await result.json());
138});
139```
140
141### Node.js — http.request
142
143```javascript
144// VULNERABLE: host and path from query string
145app.get('/proxy', (req, res) => {
146 const { host, path } = req.query;
147 http.get({ host, path }, (proxyRes) => proxyRes.pipe(res));
148});
149```
150
151### Ruby on Rails — Net::HTTP / OpenURI
152
153```ruby
154# VULNERABLE: open() fetches arbitrary URL
155def import
156 url = params[:url]
157 content = URI.open(url).read # also triggers for open(url) via Kernel#open
158 # ...
159end
160
161# SECURE: restrict scheme and host
162def import
163 url = params[:url]
164 uri = URI.parse(url)
165 raise "Forbidden" unless uri.is_a?(URI::HTTPS) && uri.host == "data.example.com"
166 content = uri.open.read
167 # ...
168end
169```
170
171### PHP — cURL
172
173```php
174// VULNERABLE: user-supplied URL piped into curl
175function fetch_preview($url) {
176 $ch = curl_init();
177 curl_setopt($ch, CURLOPT_URL, $url);
178 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
179 $result = curl_exec($ch);
180 curl_close($ch);
181 return $result;
182}
183// Called as: fetch_preview($_GET['url'])
184
185// SECURE: validate URL against allowlist before curl
186function fetch_preview($url) {
187 $allowed = ['https://cdn.example.com/'];
188 foreach ($allowed as $prefix) {
189 if (strpos($url, $prefix) === 0) {
190 // ... proceed with curl
191 }
192 }
193 throw new Exception("Destination not allowed");
194}
195```
196
197### PHP — file_get_contents
198
199```php
200// VULNERABLE: file_get_contents with http:// wrapper and user input
201$url = $_GET['source'];
202$data = file_get_contents($url); // fetches remote URL if scheme is http/https/ftp
203```
204
205### Java — Spring / OkHttp
206
207```java
208// VULNERABLE: RestTemplate with user-controlled URL
209@GetMapping("/proxy")
210public ResponseEntity<String> proxy(@RequestParam String url) {
211 RestTemplate restTemplate = new RestTemplate();
212 return restTemplate.getForEntity(url, String.class);
213}
214
215// VULNERABLE: OkHttp with user-controlled host
216public String fetch(String host, String path) {
217 Request request = new Request.Builder()
218 .url("https://" + host + path)
219 .build();
220 return client.newCall(request).execute().body().string();
221}
222```
223
224### Go — net/http
225
226```go
227// VULNERABLE: user-supplied URL passed to http.Get
228func proxyHandler(w http.ResponseWriter, r *http.Request) {
229 target := r.URL.Query().Get("url")
230 resp, err := http.Get(target)
231 if err != nil {
232 http.Error(w, err.Error(), 500)
233 return
234 }
235 io.Copy(w, resp.Body)
236}
237
238// VULNERABLE: user controls host in net.Dial
239func dialHandler(w http.ResponseWriter, r *http.Request) {
240 host := r.URL.Query().Get("host")
241 port := r.URL.Query().Get("port")
242 conn, _ := net.Dial("tcp", host+":"+port)
243 // ...
244}
245```
246
247### C# — HttpClient
248
249```csharp
250// VULNERABLE: user-supplied URL passed to HttpClient
251[HttpGet("proxy")]
252public async Task<IActionResult> Proxy([FromQuery] string url)
253{
254 var response = await _httpClient.GetAsync(url);
255 var content = await response.Content.ReadAsStringAsync();
256 return Content(content);
257}
258```
259
260---
261
262## Execution
263
264This skill runs in three phases using subagents. Pass the contents of `sast/architecture.md` to all subagents as context.
265
266### Phase 1: Find All Outbound Network Call Sites
267
268Launch a subagent with the following instructions:
269
270> **Goal**: Find every location in the codebase where the application makes an outbound network request — HTTP, HTTPS, FTP, TCP, or DNS — regardless of whether that destination is user-controlled. Write results to `sast/ssrf-recon.md`.
271>
272> **Context**: You will be given the project's architecture summary. Use it to understand the tech stack, HTTP client libraries in use, and any networking or webhook-related components.
273>
274> **What to search for — outbound request call sites**:
275>
276> You are looking for any code that opens a network connection or fetches a remote resource. Flag ANY call where a non-trivially-hardcoded URL, host, or address value is passed as an argument. You are not yet tracing whether that value is user-controlled; that is Phase 2's job.
277>
278> 1. **Python HTTP clients**:
279> - `requests.get(url)`, `requests.post(url)`, `requests.put(url)`, `requests.request(method, url)`, `requests.Session().get(url)`
280> - `urllib.request.urlopen(url)`, `urllib2.urlopen(url)`
281> - `httpx.get(url)`, `httpx.post(url)`, `httpx.AsyncClient().get(url)`
282> - `aiohttp.ClientSession().get(url)`, `aiohttp.ClientSession().post(url)`
283>
284> 2. **Python socket / DNS**:
285> - `socket.connect((host, port))`, `socket.create_connection((host, port))`
286> - `dns.resolver.resolve(name)`, `socket.getaddrinfo(host, ...)`
287>
288> 3. **Python file-fetching with remote schemes**:
289> - `urllib.request.urlopen(url)` where url may be http/https/ftp
290> - `open(url)` via `from urllib.request import urlopen` or similar (flag if url may be remote)
291>
292> 4. **Node.js / JavaScript HTTP clients**:
293> - `fetch(url)`, `node-fetch(url)`
294> - `axios.get(url)`, `axios.post(url)`, `axios.request({url})`
295> - `http.get(url)`, `https.get(url)`, `http.request(options)`, `https.request(options)`
296> - `got(url)`, `superagent.get(url)`, `needle.get(url)`, `undici.request(url)`
297> - `require('request')(options)`
298>
299> 5. **Node.js socket / DNS**:
300> - `net.createConnection({host, port})`, `net.connect(port, host)`
301> - `dns.lookup(hostname, ...)`, `dns.resolve(hostname, ...)`, `dns.resolve4(hostname)`
302>
303> 6. **Ruby HTTP clients**:
304> - `Net::HTTP.get(uri)`, `Net::HTTP.start(host, ...)`, `Net::HTTP.get_response(url)`
305> - `URI.open(url)`, `open(url)` (Kernel#open / OpenURI)
306> - `RestClient.get(url)`, `RestClient::Resource.new(url)`
307> - `Faraday.new(url).get(path)`, `HTTParty.get(url)`
308> - `Typhoeus::Request.new(url)`
309>
310> 7. **PHP HTTP clients and file functions**:
311> - `curl_setopt($ch, CURLOPT_URL, $url)` followed by `curl_exec($ch)`
312> - `file_get_contents($url)` — flag when `$url` may be an http/https/ftp URL
313> - `fopen($url, 'r')` with a remote URL scheme
314> - `Guzzle`: `$client->request('GET', $url)`, `$client->get($url)`
315> - `Symfony HttpClient`: `$client->request('GET', $url)`
316>
317> 8. **Java HTTP clients**:
318> - `new URL(url).openConnection()`, `new URL(url).openStream()`
319> - `HttpURLConnection` / `HttpsURLConnection` with a dynamic URL
320> - `OkHttpClient().newCall(new Request.Builder().url(url)...)`
321> - `RestTemplate.getForObject(url, ...)`, `RestTemplate.getForEntity(url, ...)`
322> - `WebClient.get().uri(url)`, `WebClient.create(url)`
323> - `Apache HttpClient`: `httpClient.execute(new HttpGet(url))`
324>
325> 9. **Go HTTP clients and network dials**:
326> - `http.Get(url)`, `http.Post(url, ...)`, `http.NewRequest("GET", url, ...)`
327> - `net.Dial("tcp", addr)`, `net.DialTCP(...)`, `net.DialTimeout("tcp", addr, ...)`
328> - `net.LookupHost(hostname)`, `net.LookupAddr(addr)`, `net.ResolveIPAddr(...)`
329> - `net.ResolveTCPAddr("tcp", addr)`
330>
331> 10. **C# / .NET HTTP clients**:
332> - `HttpClient.GetAsync(url)`, `HttpClient.PostAsync(url, ...)`, `HttpClient.SendAsync(request)`
333> - `WebRequest.Create(url)`, `WebClient.DownloadString(url)`, `WebClient.DownloadData(url)`
334> - `HttpWebRequest` with a dynamic URL
335>
336> 11. **Shell-out to network tools** (via subprocess, exec, system, etc.):
337> - `subprocess.run(["curl", url, ...])`, `subprocess.Popen(["wget", url, ...])`
338> - `os.system("curl " + url)`, `exec("wget " + url)`
339> - Any `curl`, `wget`, `nc`, `ncat`, `nmap` invocation where the target is a variable
340>
341> **What to skip** (these are safe — do not flag):
342> - Calls where the entire URL and hostname are fully hardcoded string literals with no dynamic parts: `requests.get("https://api.example.com/data")`
343> - Internal loopback connections to `localhost` or `127.0.0.1` that are clearly part of service-to-service architecture (e.g., connecting to a local queue) — flag these if the address is dynamic
344>
345> **Output format** — write to `sast/ssrf-recon.md`:
346>
347> ```markdown
348> # SSRF Recon: [Project Name]
349>
350> ## Summary
351> Found [N] outbound network call sites.
352>
353> ## Outbound Call Sites
354>
355> ### 1. [Descriptive name — e.g., "HTTP GET in webhook dispatcher"]
356> - **File**: `path/to/file.ext` (lines X-Y)
357> - **Function / endpoint**: [function name or route]
358> - **Call type**: [HTTP GET / HTTP POST / TCP dial / DNS lookup / subprocess curl / etc.]
359> - **Library / method**: [requests.get / fetch / http.Get / curl_exec / etc.]
360> - **Destination argument**: `var_name` or `url_expression` — [brief note, e.g., "assembled from query param" or "partially hardcoded path with variable host"]
361> - **Code snippet**:
362> ```
363> [the outbound call and the lines immediately before it that construct the destination]
364> ```
365>
366> [Repeat for each site]
367> ```
368
369### After Phase 1: Check for Candidates Before Proceeding
370
371After Phase 1 completes, read `sast/ssrf-recon.md`. If the recon found **zero outbound call sites** (the summary reports "Found 0" or the "Outbound Call Sites" section is empty or absent), **skip Phase 2 and Phase 3 entirely**. Instead, write the following content to `sast/ssrf-results.md` and stop:
372
373```markdown
374# SSRF Analysis Results
375
376No vulnerabilities found.
377```
378
379Only proceed to Phase 2 if Phase 1 found at least one outbound call site.
380
381### Phase 2: Verify — Trace User Input to Outbound Call Sites (Batched)
382
383After Phase 1 completes, read `sast/ssrf-recon.md` and split the outbound call sites into **batches of up to 3 sites each**. Launch **one subagent per batch in parallel**. Each subagent traces taint only for its assigned sites and writes results to its own batch file.
384
385**Batching procedure** (you, the orchestrator, do this — not a subagent):
386
3871. Read `sast/ssrf-recon.md` and count the numbered site sections (### 1., ### 2., etc.) under "Outbound Call Sites".
3882. Divide them into batches of up to 3. For example, 8 sites → 3 batches (1-3, 4-6, 7-8).
3893. For each batch, extract the full text of those site sections from the recon file.
3904. Launch all batch subagents **in parallel**, passing each one only its assigned sites.
3915. Each subagent writes to `sast/ssrf-batch-N.md` where N is the 1-based batch number.
3926. Identify the project's primary language/framework from `sast/architecture.md` and select **only the matching examples** from the "Vulnerable vs. Secure Examples" section above. For example, if the project uses Node.js with fetch/axios, include only the "Node.js — fetch / axios" and "Node.js — http.request" examples. Include these selected examples in each subagent's instructions where indicated by `[TECH-STACK EXAMPLES]` below.
393
394Give each batch subagent the following instructions (substitute the batch-specific values):
395
396> **Goal**: For each assigned outbound network call site, determine whether a user-supplied value controls or influences the destination (URL, host, path, port, or scheme). Our goal is to find SSRF vulnerabilities. Write results to `sast/ssrf-batch-[N].md`.
397>
398> **Your assigned outbound call sites** (from the recon phase):
399>
400> [Paste the full text of the assigned site sections here, preserving the original numbering]
401>
402> **Context**: You will be given the project's architecture summary. Use it to understand entry points, middleware, and how data flows through the application.
403>
404> **SSRF reference — what to look for**:
405>
406> SSRF occurs when user-controlled input reaches the destination argument of a server-side outbound network call without an effective allowlist on where the server may connect.
407>
408> **What SSRF is NOT** — do not flag these as SSRF:
409> - **Open redirects**: HTTP 302 to a user URL — client-side redirect, not a server-side request
410> - **XSS via URL**: User URL rendered in HTML without escaping — XSS
411> - **IDOR**: Object ID tampering — separate class
412> - **Fully hardcoded outbound URLs** with no user influence — not SSRF
413>
414> **For each outbound call site, trace the destination argument(s) backwards to their origin**:
415>
416> 1. **Direct user input** — the destination is assigned directly from a request source with no transformation:
417> - HTTP query params: `request.GET.get('url')`, `req.query.url`, `params[:url]`, `$_GET['url']`, `c.Query("url")`
418> - Request body / JSON fields: `request.json['webhook_url']`, `req.body.target`, `params[:source]`
419> - Path parameters: `req.params.host`, `params[:endpoint]`
420> - HTTP headers: `request.headers.get('X-Forwarded-For')`, `req.headers['destination']`
421> - Cookies: `req.cookies.redirect_url`
422>
423> 2. **Indirect / assembled destination** — the URL is built by concatenating a hardcoded prefix with a user-supplied suffix or path:
424> - `"https://example.com/" + user_path` — may still be exploitable via path traversal or scheme injection depending on the HTTP client
425> - `base_url + user_query` — user controls the query string, potentially injectable
426> - Flag these as Likely Vulnerable and note which portion is user-controlled
427>
428> 3. **User input stored and later fetched** — the destination was previously saved from user input (e.g., a stored webhook URL) and is now retrieved from the database to make a request:
429> - Find where the stored value was written — was it accepted from user input without allowlist validation at write time?
430> - Was any validation applied at read time before the request?
431>
432> 4. **Server-side / hardcoded value** — the destination comes from config, an environment variable, a hardcoded constant, or server-side logic with no user influence — this site is NOT exploitable.
433>
434> **For each call site, also check for mitigations**:
435> - **Strict allowlist of hosts/prefixes**: A hardcoded set of permitted hostnames or URL prefixes that the destination is validated against before the request is made — this is an effective mitigation. Mark as Not Vulnerable.
436> - **Scheme-only restriction** (e.g., only allow `https://`): Partial mitigation — reduces impact but does not prevent SSRF to arbitrary HTTPS hosts. Still flag as Likely Vulnerable.
437> - **Blocklist of private IP ranges / metadata endpoints**: `169.254.169.254`, `10.0.0.0/8`, `192.168.0.0/16`, etc. — **not** sufficient. Bypassable via DNS rebinding, alternate IP representations, and redirect chains. Flag as Likely Vulnerable.
438> - **DNS resolution + IP check** (resolve hostname first, then check resolved IP against blocklist): Stronger than a pure blocklist, but still susceptible to DNS rebinding between the check and the request (TOCTOU). Flag as Likely Vulnerable unless the same resolved IP is explicitly pinned for the request.
439>
440> **Vulnerable vs. secure examples for this project's tech stack**:
441>
442> [TECH-STACK EXAMPLES]
443>
444> **Classification**:
445> - **Vulnerable**: User input demonstrably reaches the outbound request destination with no effective mitigation (no allowlist or only a blocklist/scheme check).
446> - **Likely Vulnerable**: User input probably reaches the destination (indirect flow or partial construction), or only weak mitigation is present (blocklist, scheme-only check, partial URL prefix).
447> - **Not Vulnerable**: The destination is fully server-side, OR a strict host/prefix allowlist is enforced before the request.
448> - **Needs Manual Review**: Cannot determine the destination's origin with confidence (opaque helpers, complex conditional flows, or external libraries that resolve the URL).
449>
450> **Output format** — write to `sast/ssrf-batch-[N].md`:
451>
452> ```markdown
453> # SSRF Batch [N] Results
454>
455> ## Findings
456>
457> ### [VULNERABLE] Descriptive name
458> - **File**: `path/to/file.ext` (lines X-Y)
459> - **Endpoint / function**: [route or function name]
460> - **Issue**: [e.g., "HTTP query param `url` flows directly into requests.get()"]
461> - **Taint trace**: [Step-by-step from entry point to the call site — e.g., "request.args.get('url') → target_url → requests.get(target_url)"]
462> - **Impact**: [What an attacker can do — access cloud metadata at 169.254.169.254, pivot to internal services, port scan the internal network, exfiltrate data, bypass firewalls, etc.]
463> - **Mitigation present**: [None / Blocklist only / Scheme check only — explain why it's insufficient]
464> - **Remediation**: [Strict host allowlist, or remove user control over destination entirely]
465> - **Dynamic Test**:
466> ```
467> [curl command or payload to confirm the finding.
468> Show the parameter, payload, and what to look for.
469> Example: curl "https://app.example.com/fetch?url=http://169.254.169.254/latest/meta-data/"
470> or for internal pivot: curl "https://app.example.com/fetch?url=http://internal-db:5432/"]
471> ```
472>
473> ### [LIKELY VULNERABLE] Descriptive name
474> - **File**: `path/to/file.ext` (lines X-Y)
475> - **Endpoint / function**: [route or function name]
476> - **Issue**: [e.g., "User controls the path portion of a partially hardcoded URL" or "Stored webhook URL accepted without allowlist at write time"]
477> - **Taint trace**: [Best-effort trace with the uncertain or partial-control step identified]
478> - **Concern**: [Why it's still a risk — e.g., "Attacker may be able to redirect to an internal host via path traversal" or "Blocklist is bypassable via DNS rebinding"]
479> - **Remediation**: [Strict allowlist or remove user control]
480> - **Dynamic Test**:
481> ```
482> [payload to attempt — e.g., path traversal or DNS rebinding scenario]
483> ```
484>
485> ### [NOT VULNERABLE] Descriptive name
486> - **File**: `path/to/file.ext` (lines X-Y)
487> - **Endpoint / function**: [route or function name]
488> - **Reason**: [e.g., "URL is fully hardcoded" or "Strict host allowlist enforced before request"]
489>
490> ### [NEEDS MANUAL REVIEW] Descriptive name
491> - **File**: `path/to/file.ext` (lines X-Y)
492> - **Endpoint / function**: [route or function name]
493> - **Uncertainty**: [Why the destination's origin could not be determined]
494> - **Suggestion**: [What to trace manually — e.g., "Follow `resolve_target()` in helpers.py to check where the URL originates"]
495> ```
496
497### Phase 3: Merge — Consolidate Batch Results
498
499After **all** Phase 2 batch subagents complete, read every `sast/ssrf-batch-*.md` file and merge them into a single `sast/ssrf-results.md`. You (the orchestrator) do this directly — no subagent needed.
500
501**Merge procedure**:
502
5031. Read all `sast/ssrf-batch-1.md`, `sast/ssrf-batch-2.md`, ... files.
5042. Collect all findings from each batch file and combine them into one list, preserving the original classification and all detail fields.
5053. Count totals across all batches for the executive summary (total sites analyzed equals the number from recon / sum of assigned sites).
5064. Write the merged report to `sast/ssrf-results.md` using this format:
507
508```markdown
509# SSRF Analysis Results: [Project Name]
510
511## Executive Summary
512- Outbound call sites analyzed: [total across all batches]
513- Vulnerable: [N]
514- Likely Vulnerable: [N]
515- Not Vulnerable: [N]
516- Needs Manual Review: [N]
517
518## Findings
519
520[All findings from all batches, grouped by classification:
521 VULNERABLE first, then LIKELY VULNERABLE, then NEEDS MANUAL REVIEW, then NOT VULNERABLE.
522 Preserve every field from the batch results exactly as written.]
523```
524
5255. After writing `sast/ssrf-results.md`, **delete all intermediate batch files** (`sast/ssrf-batch-*.md`).
526
527---
528
529## Important Reminders
530
531- Read `sast/architecture.md` and pass its content to all subagents as context.
532- Phase 2 must run AFTER Phase 1 completes — it depends on the recon output.
533- Phase 3 must run AFTER all Phase 2 batches complete — it depends on all batch outputs.
534- Batch size is **3 outbound call sites per subagent**. If there are 1-3 sites total, use a single subagent. If there are 10, use 4 subagents (3+3+3+1).
535- Launch all batch subagents **in parallel** — do not run them sequentially.
536- Each batch subagent receives only its assigned sites' text from the recon file, not the entire recon file. This keeps each subagent's context small and focused.
537- **Phase 1 is purely structural**: flag any call site where the destination argument is dynamic (a variable, expression, or assembled string), regardless of whether user input flows there. Do not attempt to trace user input in Phase 1 — that is Phase 2's job.
538- **Phase 2 is purely taint analysis**: for each site in its batch, trace the destination argument back to its origin. If it comes from a user-controlled source without an effective allowlist, the site is a real vulnerability.
539- **Blocklists are not mitigations**: IP blocklists for private ranges and cloud metadata endpoints are easily bypassed. Always classify such sites as Vulnerable or Likely Vulnerable, not as safe.
540- **Partial URL control is still dangerous**: even if the attacker only controls the path or query string portion of the URL, flag it as Likely Vulnerable — depending on the HTTP client behavior, redirect following, and target service, partial control can be enough.
541- **Stored destinations are tainted**: if a URL or hostname was accepted from user input at write time and is later used for an outbound request, trace the write-time acceptance. Lack of allowlist validation at write time makes it SSRF.
542- **Subprocess curl/wget is SSRF too**: shell-outs that run `curl` or `wget` with a user-supplied URL are just as dangerous as HTTP client calls. Check for these, especially in image-processing, import, or download features.
543- When in doubt, classify as "Needs Manual Review" rather than "Not Vulnerable". False negatives are worse than false positives in security assessment.
544- DNS rebinding note: for findings where only a DNS-resolution-then-blocklist check is present, note the TOCTOU window explicitly in the finding — this is a known bypass technique.
545- Clean up intermediate files: delete `sast/ssrf-recon.md` and all `sast/ssrf-batch-*.md` files after the final `sast/ssrf-results.md` is written.