T09 · Insecure Skill Coding Practices
- Location
monitor.py:49- Finding
Configuration-Controlled Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
monitor.py:49-54andmonitor.py:112-126
Vulnerability Type: Server-Side Request Forgery (SSRF)
Risk Level: HighVulnerable Code
python def fetch_text(url: str, timeout: int = 20) -> str: r = requests.get(url, timeout=timeout, headers={"User-Agent": "airdrop-monitor-cn/0.2"}) r.raise_for_status() text = r.text text = re.sub(r"\s+", " ", text) return text[:15000]The request destination is read directly from the configuration:
python results: List[SourceResult] = [] for proj in cfg["projects"]: pname = proj.get("name", "unknown") for src in proj.get("sources", []): sname = f"{pname}:{src.get('name', 'source')}" surl = src["url"] try: text = fetch_text(surl) except Exception as e: text = f"fetch_error: {e}" h = digest(text) old_h = state["sources"].get(surl, "") changed = old_h != "" and old_h != hTechnical Analysis
The application accepts source URLs from a JSON configuration and passes them directly to
requests.get()without validating the scheme, hostname, port, or resolved IP address. Therequestslibrary also follows HTTP redirects by default.Consequently, any party that can create, replace, or influence the monitor configuration can make the application issue requests to destinations reachable from the host, including:
- Loopback services such as
127.0.0.1orlocalhost - Private network services
- Link-local addresses and cloud metadata endpoints
- Services exposed on nonstandard ports
- Public endpoints that redirect to internal destinations
The checks in
detect_risks()do not mitigate this issue because they run only after the network request has already occurred. They also do not inspect resolved addresses or redirect targets.Attack Path
- An attacker obtains the abil ...[truncated 1346 chars]
- Loopback services such as
- Remediation
View remediation
Remediation Suggestions
- Parse each URL before making a request and allow only explicitly supported schemes, preferably HTTPS.
- Reject URLs containing embedded credentials, fragments, unexpected ports, or malformed hostnames.
- Resolve the hostname and reject every address that is loopback, private, link-local, multicast, reserved, unspecified, or otherwise nonpublic.
- Explicitly block known cloud metadata destinations, including link-local metadata addresses and provider-specific metadata hostnames.
- Disable automatic redirects with
allow_redirects=False, or validate the scheme, hostname, port, and resolved IP address of every redirect target before following it. - Consider an explicit allowlist of approved project domains when the monitored sources are known in advance.
- Apply outbound firewall or proxy controls so the process cannot reach internal networks or metadata services.
- Protect against DNS rebinding by validating resolved addresses and ensuring that the actual connection uses an approved address.
- Set response-size limits while streaming the body rather than downloading the full response before truncation.
