Skip to main content

SKY-D216 · Security in code

Server-side request forgery (SSRF)

CriticalCWE-918

Python and Go findings are CRITICAL. In TypeScript and JavaScript, request data that chooses the URL of fetch, axios, got or a similar client in a route handler is HIGH, and a fetch() or axios call with any other variable URL is MEDIUM.

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

app/preview.py · PythonReported on line 11
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

app/preview.py · Python
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

src/server.ts · TypeScriptReported on line 7
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

src/server.ts · TypeScript
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

main.go · GoReported on line 9
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

main.go · Go
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

handler.go · Go
package app import "net/http" func handle(r *http.Request) {    retrieve(r.FormValue("resource"))}
retrieve.go · GoReported on line 6
package app import "net/http" func retrieve(endpoint string) {    http.Get(endpoint)}

Not flagged

handler.go · Go
package app import (    "net/http"    "net/url") func handle(r *http.Request) {    id := url.PathEscape(r.FormValue("resource"))    retrieve("https://catalog.example/items/" + id)}

retrieve.go: same as in the flagged example.

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

  1. In Python, finds HTTP calls: get, post, put, delete, head, options and request on a receiver that looks like an HTTP client (requests, httpx, aiohttp, urllib3, a session or client), and urllib.request.urlopen(). The URL is the url= keyword, the first argument of a verb, or the second argument of request(method, url).
  2. Skips in-process test clients (Flask test_client(), Django Client, Starlette TestClient and others) and receivers proven to be an SQLAlchemy session, whose get() and delete() are database calls.
  3. 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, or urljoin() with a fixed base and a relative target.
  4. 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) or url.startswith("https://api.example.com/").
  5. 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.
  6. TypeScript and JavaScript: request data in an Express, Fastify, Koa, NestJS or Next.js handler that reaches the URL of fetch, axios, got, undici or http(s).get is HIGH. Any other fetch() 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 in http.Get, http.Post, http.NewRequest, an http.Client call 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.
  7. Rust: the URL of reqwest::get, of get/post/.../request(method, url) on a reqwest, reqwest-middleware, awc, ureq, surf, isahc or hyper client, of the ureq/surf/isahc/attohttpc/minreq functions, or the target of webmention::Webmention::new, when request data is an actix-web or axum extractor (Path, Query, Json, Form, ...), a Rocket Json/Form/Data guard or text route parameter (#[get("/x/<name>")] with name: &str), or the data methods of an HttpRequest/Request (uri(), query_string(), headers(), ...). Only the part that chooses the host counts: a literal scheme://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.

app/preview.py · Python · the fix, against the flagged file
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 # noqa does 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 --baseline so only new ones are listed.

  • [tool.skylos] ignore = ["SKY-D216"] turns the rule off for the whole project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.