T09 · Insecure Skill Coding Practices
- Location
skill.py:49- Finding
Arbitrary Python Code Injection Through RSS Source URL
- Content
View full analysis
- Remediation
View remediation
List[Dict]: feed = feedparser.parse(source_url) return [ { "title": getattr(entry, "title", ""), "link": getattr(entry, "link", ""), "summary": getattr(entry, "summary", "")[:200], "published": getattr(entry, "published", ""), } for entry in feed.entries[:self.config["max_news_per_source"]] ] ``` Apply the following additional controls: 1. Parse URLs with `urllib.parse.urlparse()` and allow only `https`, or explicitly justified schemes. 2. If sources may be supplied by untrusted users, enforce an approved hostname allowlist. 3. Resolve destination addresses and reject loopback, private, link-local, multicast, and cloud metadata ranges to reduce SSRF exposure. 4. Enforce reasonable feed size, item-count, redirect, and network timeout limits. 5. Validate `max_news_per_source` as a bounded integer. 6. Add regression tests using quotes, semicolons, backslashes, newlines, and comment characters to verify that source values can never become executable code. ]]>
