T09 · Insecure Skill Coding Practices
- Location
scripts/ontology_bootstrap.py:98- Finding
Unrestricted Ontology URL Retrieval Enables SSRF and Local File Copying
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ontology_bootstrap.py:98-105
Vulnerability Type: Unrestricted URL retrieval
Risk Level: Mediumpython def download_ontology(url: str, outdir: Path) -> Path: outdir.mkdir(parents=True, exist_ok=True) parsed = urlparse(url) filename = Path(parsed.path).name or 'downloaded_ontology.owl' destination = outdir / filename urllib.request.urlretrieve(url, destination) return destinationThe vulnerable function is invoked with user-controlled input at
scripts/ontology_bootstrap.py:118-121:python if args.download_url: downloaded = download_ontology(args.download_url, outdir) print(f'downloaded: {downloaded}')Technical Analysis
The
--download-urlargument is passed directly tourllib.request.urlretrievewithout validating the URL scheme, resolved destination, redirects, response size, or returned content. Consequently, an attacker who can influence this argument may cause the process to request resources using the host's network position.Possible exploitation methods include:
- Supplying an HTTP or HTTPS URL that resolves to a loopback, private, link-local, or otherwise internal address, resulting in server-side request forgery.
- Supplying a
file://URI to copy a local file readable by the process into the selected output directory. - Supplying an endpoint that returns an excessively large or non-terminating response, consuming disk space or blocking execution.
- Using redirects or DNS resolution changes to bypass superficial hostname checks if incomplete validation is later added.
The URL-derived filename is reduced to a basename, which limits direct path traversal through the URL path. The downloaded content is stored rather than executed, so the finding does not constitute remote payload execution by itself.
Attack Path
- An attacker provides or induces use of a crafted
--download-url. - The agent or user invokes the documented on ...[truncated 1365 chars]
- Remediation
View remediation
Remediation Suggestions
- Permit only HTTPS URLs and reject
file:,ftp:,data:, and all other schemes. - Reject URLs containing embedded credentials or malformed host components.
- Resolve the hostname before connecting and reject loopback, private, link-local, multicast, unspecified, and reserved IP addresses for both IPv4 and IPv6.
- Apply the same validation to every redirect target. Prefer disabling automatic redirects and following only validated redirects.
- Use an allowlist of trusted institutional or official ontology repositories where practical.
- Replace
urlretrievewith bounded streaming retrieval that enforces connection and read timeouts, a maximum response size, and a maximum redirect count. - Validate the response content type and parse the result as an expected ontology format before retaining it.
- Generate a controlled destination filename rather than relying on a URL-derived name, and refuse overwrites unless explicitly requested.
- Download to a securely created temporary file and atomically move it into the output directory only after validation succeeds.
- Require explicit user confirmation before network retrieval when the skill is operating through an agent.
- Permit only HTTPS URLs and reject
