T09 · Insecure Skill Coding Practices
- Location
eval-viewer/generate_review.py:258- Finding
Script-context injection in the evaluation review viewer
- Content
View full analysis
// ---- Embedded data (injected by generate_review.py) ---- /*__EMBEDDED_DATA__*/ ``` ### Technical Analysis The embedded structure can contain attacker-controlled evaluation prompts, grading evidence, feedback, and output-file contents. Although `json.dumps()` produces valid JSON, it does not make that JSON safe for direct placement inside an HTML `` terminates the script element even when it appears inside a JavaScript string literal. Consequently, a malicious output containing a payload such as: ```html ``` can break out of the embedded JSON and execute as JavaScript when the generated review page is opened. The viewer does not define a restrictive Content Security Policy. It also loads an external JavaScript dependency, so browser-side compromise can access all data embedded in the page and initiate outbound requests. ### Attack Path 1. A malicious or compromised Skill is evaluated. 2. The Skill writes a text output, prompt, or grading value containing a `` breakout payload. 3. `generate_review.py` reads the value and serializes it with `json.dumps()`. 4. Th ...[truncated 1109 chars]- Remediation
View remediation
SAFE_JSON ``` - Before embedding JSON into HTML, escape at least `<`, `>`, `&`, U+2028, and U+2029. For example, replace `<` with `\u003c`. - Prefer a well-tested HTML-safe JSON serialization routine instead of ad hoc string replacement. - Add a restrictive Content Security Policy that blocks inline and unauthorized external scripts. - Add regression tests using values containing ``, HTML event handlers, Unicode separators, and nested script elements. - Treat every field read from an evaluated workspace as untrusted, regardless of file extension. ]]>
