T09 · Insecure Skill Coding Practices
- Location
SKILL.md:134- Finding
Python Code Injection Through Untrusted Report Export Values
- Content
View full analysis
>""" company_name = "<<企业名称>>" report_date = "<<报告日期>>" ``` The instructions later require these placeholders to be replaced with the actual report, company name, and report date before executing the generated script. ### Technical Analysis The export workflow constructs executable Python source by substituting data into Python string literals. Both `company_name` and portions of `report_md` can originate from user input or externally retrieved report material. No safe serialization boundary is defined. A value containing quotation marks, backslashes, newlines, or a triple-quote sequence can terminate the intended string literal and introduce additional Python statements. Escaping the content for HTML after the Python interpreter has started does not mitigate this issue because exploitation occurs while parsing the generated Python source. The vulnerability is especially significant for `report_md`, which may contain material derived from public web searches in addition to user-supplied data. ### Attack Path 1. An attacker supplies a company name or report-influencing input containing a Python string terminator and injected Python statements. 2. The Agent produces the Step 7 report using that input. 3. The report export workflow asks the user to approve HTML generation. 4. After approval, the Agent replaces the placeholders in the documented script with the actual values. 5. The Python tool parses the substituted text as executable source. 6. The injected statements execute with the permissions granted to the Python tool. ### Impact Assessment Successful exploitation can provide arbitrary Python code execution in the Skill runtime. Depending on the sandbox configuration, this may permit: - Reading files an ...[truncated 547 chars]- Remediation
View remediation
