T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/fetch_news.py:78
- Finding
- TLS Certificate Verification Disabled for Official RSS Retrieval<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fetch_news.py:42, 78, 279-280` **Vulnerability Type**: Improper certificate validation and use of unencrypted HTTP **Risk Level**: Medium ### Vulnerable Code ```python RSS_FEEDS = [ {"name": "中国政府网·政策", "url": "https://www.gov.cn/zhengce/zuixin/ezine.xml", "icon": "🏛️", "category": "政策"}, {"name": "新华网·财经", "url": "http://www.news.cn/fortune/feed.xml", "icon": "📰", "category": "综合"}, ] ``` ```python resp = requests.get(feed["url"], headers=HEADERS, timeout=10, verify=False) ``` ```python if __name__ == "__main__": import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) ``` ### Technical Analysis The RSS retrieval function explicitly passes `verify=False` to `requests.get`. This disables validation of the remote server's TLS certificate, including certificate authority, hostname, and validity checks. Suppressing `InsecureRequestWarning` further prevents the operator from seeing that server authentication has been disabled. In addition, the Xinhua RSS endpoint is configured with plain HTTP. HTTP provides no cryptographic authentication or integrity protection. Consequently, both configurations permit a network-positioned attacker to alter an RSS response without possessing a valid certificate for the official domain. The parser trusts the returned XML and associates every parsed item with the configured official source: ```python articles.append({ "title": (title_el.text or "").strip(), "url": (link_el.text or "").strip(), "date": (pub_el.text or "").strip() if pub_el is not None else "", "source": feed["name"], "icon": feed["icon"], "category": feed["category"], }) ``` Although this does not provide direct local code execution, it breaks the authenticity guarantee claimed by the Skill and can cause attacker-controlled content to be presented as official economic news. ### Attack Path 1. A victim runs the fallb ...[truncated 1387 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `verify=False` and rely on the default certificate verification behavior: ```python resp = requests.get(feed["url"], headers=HEADERS, timeout=10) resp.raise_for_status() ``` 2. Replace the plain HTTP Xinhua feed with a verified HTTPS endpoint. If no HTTPS endpoint is available, do not treat that source as authenticated official content. 3. Remove global suppression of `InsecureRequestWarning` so that accidental insecure TLS use remains visible. 4. Validate the final response URL after redirects and require HTTPS: ```python from urllib.parse import urlsplit resp = requests.get(feed["url"], headers=HEADERS, timeout=10) resp.raise_for_status() final_url = urlsplit(resp.url) if final_url.scheme != "https": raise ValueError("RSS feed redirected to a non-HTTPS URL") ``` 5. Apply strict hostname allowlisting to both the configured feed URL and the final redirected URL. 6. Consider setting a maximum response size before XML parsing to reduce exposure to unexpectedly large network responses. ]]>
