T09 · Insecure Skill Coding Practices
- Location
scripts/extract_article.py:8- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
dict: """获取网页并提取正文""" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" } resp = requests.get(url, headers=headers, timeout=30) resp.encoding = resp.apparent_encoding ``` ### Technical Analysis The `url` value is supplied through a command-line argument and passed directly to `requests.get`. The implementation does not validate: - The URL scheme - The destination hostname or port - The resolved IP address - Redirect destinations - Whether the destination belongs to a loopback, private, link-local, or reserved network - The maximum response size Consequently, an attacker who can cause the skill to process a URL can make the host running the agent issue requests to resources that are not directly accessible to the attacker. Redirect-based bypasses are also possible because `requests` follows redirects by default and the destination is not revalidated. ### Attack Path 1. An attacker asks the agent to process an article URL. 2. The URL points directly to an internal endpoint or redirects to one, such as a loopback service, private-network administration interface, or cloud metadata endpoint. 3. The agent invokes `extract_article.py` with the attacker-controlled URL. 4. `requests.get` sends the request from the agent's network context. 5. The response is parsed by Readability and BeautifulSoup. 6. Extracted content is returned in the script's JSON output, potentially exposing information from the internal resource. ### Impact Assessment Successful exploitation can provide access to HTTP services reachable from the agent host, including loopback and private-network services. Depending on the environment, this may expose internal application data, infrastructure meta ...[truncated 314 chars]- Remediation
View remediation
