T09 · Insecure Skill Coding Practices
Error
- Location
- skill.py:96
- Finding
- Unrestricted RSS URLs Enable Server-Side Request Forgery## Vulnerability Details **File Location**: `skill.py:96-100`, with configuration data reaching the sink at `skill.py:164-170` **Vulnerability Type**: Server-Side Request Forgery **Risk Level**: High ### Vulnerable Code ```python def parse_rss(rss_url, source_name): try: # Download RSS headers = {'User-Agent': 'Mozilla/5.0'} response = requests.get(rss_url, headers=headers, timeout=15) ``` The request target originates directly from the configuration: ```python name = account['name'] rss_url = account.get('rss_url', '') report_content += f"## {name}\n\n" if rss_url == "待填写": report_content += "*该账号的 RSS URL 未配置*\n\n" continue articles = parse_rss(rss_url, name) ``` ### Technical Analysis The application sends a server-side HTTP request to a configuration-controlled URL without validating its scheme, hostname, resolved address, port, or redirect destination. The `requests` library also follows redirects by default. Consequently, an attacker who can influence `accounts.json` can direct the process to request loopback addresses, private network services, link-local resources, cloud metadata services, or an external redirector that forwards the request to such destinations. The request is made with the network access privileges of the user and host running the skill. Although the response must resemble RSS XML for structured extraction, connection behavior and error output can still facilitate internal service probing. Internal content formatted as qualifying RSS can be written into a report and printed to the console. ### Attack Path 1. The attacker obtains the ability to create or modify `~/.config/wechat-monitor/accounts.json`. 2. The attacker adds an enabled account whose `rss_url` references an internal service, metadata endpoint, loopback address, or attacker-controlled redirector. 3. A user or automated process executes `python skill.py`. 4. `requests. ...[truncated 919 chars]
- Remediation
- ## Remediation Suggestions - Allow only HTTPS URLs. - Maintain an explicit allowlist of approved RSS domains where operationally possible. - Resolve each hostname before connecting and reject loopback, private, link-local, multicast, reserved, and unspecified addresses for both IPv4 and IPv6. - Disable automatic redirects or validate the scheme, hostname, port, and resolved address of every redirect destination. - Protect against DNS rebinding by connecting only to the validated resolved address while preserving correct TLS hostname verification. - Reject URLs containing embedded credentials or unexpected ports. - Apply outbound firewall or proxy restrictions so the process cannot access metadata and internal management networks. - Treat the configuration file as security-sensitive and restrict its ownership and permissions.
