T09 · Insecure Skill Coding Practices
- Location
scripts/zhouyi.py:1076- Finding
Stored HTML and JavaScript Injection Through the Divination Question
- Content
View full analysis
🗺️ 决策参考
占问主题:{question_text}
``` The affected value originates from the command-line argument at line 1354: ```python parser.add_argument("--question", default="", help="占问问题") ``` It is passed to the HTML generator at line 1409 and written to disk at lines 1425-1426: ```python html = generate_divination_html(method_name, yaos, ben_gua, bian_gua, args.question) with open(output_path, "w", encoding="utf-8") as f: f.write(html) ``` ### Technical Analysis The `--question` argument is attacker-controlled input. The application interpolates this value directly into an HTML element without applying HTML entity encoding or contextual output escaping. Because the generated report is intended to be opened in a web browser, an attacker can terminate the existing paragraph and inject arbitrary HTML elements, event handlers, or script blocks. The resulting payload is stored in the generated report, making this a stored HTML/JavaScript injection vulnerability. For example, the following input would produce an executable script element in the report: ```text``` The vulnerability is especially relevant when an AI Agent invokes the script using question text obtained from an untrusted user. The user who supplied the question may influence a report that is subsequently opened or shared by another person. ### Attack Path 1. An attacker supplies a malicious value through `--question`, directly or through an Agent that maps an untrusted prompt to this argument. 2. `m ...[truncated 1575 chars]
- Remediation
View remediation
``` 5. Add regression tests confirming that the following inputs are rendered as literal text and never interpreted as markup: ```text" onmouseover="alert(1) ``` 6. Validate the final generated document with an HTML parser and verify that user input cannot introduce additional elements, attributes, or executable content. ]]>
