SKY-D216 · Security in code
Server-side request forgery (SSRF)
Server-side request forgery (SSRF) happens when outside text chooses where your server sends an HTTP request. Skylos reports SKY-D216 when request data, a route or tool argument, or input() can pick the host of a call such as requests.get(), httpx.post() or urlopen(). In Rails controllers, it checks whether request data selects an outbound HTTP destination.
- Languages
- Python, TypeScript/JavaScript, Go, Java, Kotlin, C#, PHP, Rust, Dart, Shell, Ruby
- Quality gate
- counted toward the gate limits; a CRITICAL finding fails the gate on its own (full and diff scans). The TypeScript and JavaScript findings are HIGH or MEDIUM and are only counted. A TypeScript or JavaScript call whose URL no request data reaches is a review signal that gates do not count.
- Finding type
- review
- Catalog name
- Server-side request forgery
- Go engine ID
- SKY-G216, reported as SKY-D216
Why it matters
The server can reach places a visitor cannot. A link-preview endpoint called with url=http://169.254.169.254/latest/meta-data/ reads the cloud metadata service and can hand back the machine's access keys. The same trick reaches admin panels and databases on the internal network.
What Skylos flags
import requests from flask import Flask, request app = Flask(__name__) @app.get("/preview")def preview(): url = request.args.get("url", "") page = requests.get(url, timeout=5) return {"status": page.status_code, "length": len(page.text)}What Skylos leaves alone
import requests from flask import Flask, request app = Flask(__name__) @app.get("/profile")def profile(): user = request.args.get("user", "") page = requests.get(f"https://api.github.com/users/{user}", timeout=5) return {"status": page.status_code, "length": len(page.text)}Why Skylos leaves it alone
The request data only fills the path. The literal prefix https://api.github.com/ already fixes the host, so the visitor can choose which user to look up but not which server is contacted.
More languages
TypeScript
Flagged
import express from "express"; const app = express(); app.get("/preview", async (req, res) => { const url = String(req.query.url ?? ""); const page = await fetch(url); res.json({ status: page.status });}); app.listen(3000);Not flagged
import express from "express"; const app = express(); app.get("/profile", async (req, res) => { const user = encodeURIComponent(String(req.query.user ?? "")); const page = await fetch(`https://api.github.com/users/${user}`); res.json({ status: page.status });}); app.listen(3000);Why Skylos leaves it alone
The template literal starts with a fixed scheme://host/ prefix, so the request data cannot change the host.
Go
Flagged
package main import ( "net/http") func preview(w http.ResponseWriter, r *http.Request) { target := r.URL.Query().Get("url") resp, err := http.Get(target) if err != nil { http.Error(w, "fetch failed", http.StatusBadGateway) return } defer resp.Body.Close() w.WriteHeader(resp.StatusCode)} func main() { http.HandleFunc("/preview", preview) http.ListenAndServe(":8080", nil)}Not flagged
package main import ( "net/http" "net/url") func profile(w http.ResponseWriter, r *http.Request) { user := url.PathEscape(r.URL.Query().Get("user")) resp, err := http.Get("https://api.github.com/users/" + user) if err != nil { http.Error(w, "fetch failed", http.StatusBadGateway) return } defer resp.Body.Close() w.WriteHeader(resp.StatusCode)} func main() { http.HandleFunc("/profile", profile) http.ListenAndServe(":8080", nil)}Why Skylos leaves it alone
The string before the request value is a full scheme://host/ prefix, so the Go engine treats the host as fixed.
Go
Flagged
package app import "net/http" func handle(r *http.Request) { retrieve(r.FormValue("resource"))}package app import "net/http" func retrieve(endpoint string) { http.Get(endpoint)}Not flagged
package app import ( "net/http" "net/url") func handle(r *http.Request) { id := url.PathEscape(r.FormValue("resource")) retrieve("https://catalog.example/items/" + id)}Why Skylos leaves it alone
The input only fills the path on the fixed catalog host. The Go engine follows the argument into the helper in the same package.
How Skylos decides
- In Python, finds HTTP calls:
get,post,put,delete,head,optionsandrequeston a receiver that looks like an HTTP client (requests,httpx,aiohttp,urllib3, asessionorclient), andurllib.request.urlopen(). The URL is theurl=keyword, the first argument of a verb, or the second argument ofrequest(method, url). - Skips in-process test clients (Flask
test_client(), DjangoClient, StarletteTestClientand others) and receivers proven to be an SQLAlchemy session, whoseget()anddelete()are database calls. - Skips a URL whose host is already fixed: a literal
scheme://host/prefix, a module setting that holds such a URL or comes from the environment, orurljoin()with a fixed base and a relative target. - Skips a URL checked before the call by a guard that always exits, such as
if urlparse(url).hostname not in ALLOWED_HOSTS: abort(400)orurl.startswith("https://api.example.com/"). - Reports CRITICAL only when a real untrusted source reaches the URL: a route, MCP tool or command-dispatch argument, request data,
input()or standard input. A URL whose only source is a command-line argument or an environment variable is the operator's choice and is not reported. - TypeScript and JavaScript: request data in an Express, Fastify, Koa, NestJS or Next.js handler that reaches the URL of
fetch, axios, got, undici orhttp(s).getis HIGH. Any otherfetch()or axios call with a URL that is not built from constants is MEDIUM and only a review signal: the destination comes from configuration, an admin setting, a constant or a caller the analysis cannot see, so the finding stays in the report but is not listed by default and does not fail a gate.await axios.get<T>(url)is recognised as an axios call. Go (reported by the Go engine as SKY-G216): request or network input inhttp.Get,http.Post,http.NewRequest, anhttp.Clientcall or a reverse proxy target, unless a literal prefix fixes the host. The Go engine can follow a directly resolved function call into another file in the same buildable package. Java, Kotlin, C#, PHP, Dart and shell scripts have their own checks with the same idea. - Rust: the URL of
reqwest::get, ofget/post/.../request(method, url)on a reqwest, reqwest-middleware, awc, ureq, surf, isahc or hyper client, of theureq/surf/isahc/attohttpc/minreqfunctions, or the target ofwebmention::Webmention::new, when request data is an actix-web or axum extractor (Path,Query,Json,Form, ...), a RocketJson/Form/Dataguard or text route parameter (#[get("/x/<name>")]withname: &str), or the data methods of anHttpRequest/Request(uri(),query_string(),headers(), ...). Only the part that chooses the host counts: a literalscheme://host/or a non-request base followed by/,?or#fixes it, and percent-encoding clears a value. Environment variables, arguments and stored rows (a query given a database pool or connection) are not request data. For reqwest and reqwest-middleware, the finding points to the blocking send, the await, or a known task executor that runs the request. Building and discarding a request stays quiet. Skylos follows builders returned by local helpers. A Cargo project scan also checks directly resolved helpers across one ordinary module boundary when it can read both source files.
How to fix it
Parse the URL and accept only hosts you chose in advance, with the https scheme. Reject everything else before the request is sent. If you must allow any public site, resolve the name and refuse private, loopback and link-local addresses as well.
Added: from urllib.parse import urlparseAdded: import requests Removed: from flask import Flask, requestAdded: from flask import Flask, abort, request app = Flask(__name__)Added: ALLOWED_HOSTS = {"example.com", "docs.example.com"} @app.get("/preview")def preview(): url = request.args.get("url", "")Added: if urlparse(url).hostname not in ALLOWED_HOSTS:Added: abort(400) page = requests.get(url, timeout=5) return {"status": page.status_code, "length": len(page.text)}When it can be wrong
- An allowlist check made inside another function, such as
ensure_allowed(url), is not seen: the URL is still reported. - In TypeScript and JavaScript, a
fetch()of a URL built from a function parameter is reported as MEDIUM even when every caller passes a fixed address. - An allowlist kept in a local variable or a module-level string is not accepted as a guard; use a literal set or a module-level collection.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Silence one line and say why. A bare
# noqadoes not hide HIGH or CRITICAL security findings.Python page = requests.get(url) # skylos: ignore[SKY-D216] url checked by ensure_allowed()Accept the findings you already have with
skylos baseline ., then scan with--baselineso only new ones are listed.[tool.skylos] ignore = ["SKY-D216"]turns the rule off for the whole project.