T09 · Insecure Skill Coding Practices
Warning
- Location
- turkish-news/SKILL.md:127
- Finding
- Unsafe manual serialization of externally controlled RSS fields<![CDATA[ ## Vulnerability Details **File Location**: `turkish-news/SKILL.md`, lines 127–136 **Vulnerability Type**: Untrusted data handling and unsafe serialization **Risk Level**: Medium ### Vulnerable Code ```python result = terminal(f"curl -s -m 10 '{url}' | python3 -c \"\nimport sys, xml.etree.ElementTree as ET\ntry:\n tree = ET.parse(sys.stdin)\n for item in tree.findall('.//item')[:10]:\n title = item.findtext('title', '')\n link = item.findtext('link', '')\n desc = item.findtext('description', '')\n date = item.findtext('pubDate', '')\n print(f'{{\\\"title\\\": \\\"{title}\\\", \\\"link\\\": \\\"{link}\\\", \\\"source\\\": \\\"{name}\\\"}}')\nexcept: pass\n\"") # Parse results... ``` ### Technical Analysis The RSS `title` and `link` fields originate from external news servers and are inserted into a manually constructed JSON string without JSON encoding. Characters such as quotation marks, backslashes, line breaks, and control characters can corrupt the resulting record or create additional apparent fields or records. The URLs and source names in the documented implementation are fixed constants, so the reviewed code does not establish command injection through those values. The primary problem is unsafe output serialization and downstream content integrity, not execution of RSS content. The broad `except: pass` clause suppresses all parsing and serialization errors. This makes malformed or hostile feed content difficult to detect and can cause silent loss or manipulation of briefing data. ### Attack Path 1. An attacker compromises a configured RSS source, controls an upstream article title, or causes a source to return crafted RSS content. 2. The Skill downloads that RSS document using `curl`. 3. `ElementTree` extracts an attacker-controlled title or link. 4. The value is interpolated directly into JSON-like output without `json.dumps()`. 5. Embedded quotes, backslashes, or line breaks alter the downstrea ...[truncated 815 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the nested shell and inline Python construction. Fetch RSS using a Python HTTP client or a constrained platform network tool. 2. Store each item as a Python dictionary and serialize it with `json.dumps()`: ```python import json record = { "title": title, "link": link, "source": name, } print(json.dumps(record, ensure_ascii=False)) ``` 3. Validate links before presenting them: - Permit only `https`. - Restrict hosts to an explicit allowlist of configured news domains. - Reject embedded credentials and unexpected ports. 4. Normalize or reject control characters in titles and source names. 5. Replace `except: pass` with narrow exception handling and structured logging. 6. Treat fetched articles and RSS text as untrusted data, not Agent instructions. 7. Add tests containing quotes, backslashes, newlines, HTML, malformed XML, and oversized feed values. ]]>
