T09 · Insecure Skill Coding Practices
- Location
scripts/gen.py:242- Finding
Stored HTML Injection in Generated Image Gallery
- Content
View full analysis
None: thumbs = "\n".join( [ f'\n' f'\n' f' {it["prompt"]}\n' f'' for it in items ] ) html = f""" gemini-image-gen ({engine}) :root {{ color-scheme: dark; }} body {{ margin: 24px; font: 14px/1.4 ui-sans-serif, system-ui; background: #0b0f14; color: #e8edf2; }} h1 {{ font-size: 18px; margin: 0 0 4px; }} .meta {{ color: #7a8a99; margin-bottom: 16px; font-size: 13px; }} .grid {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }} figure {{ margin: 0; padding: 12px; border: 1px solid #1e2a36; border-radius: 14px; background: #0f1620; transition: border-color .2s; }} figure:hover {{ border-color: #3b82f6; }} img {{ width: 100%; height: auto; border-radius: 10px; display: block; }} figcaption {{ margin-top: 10px; color: #b7c2cc; font-size: 13px; line-height: 1.4; }} a {{ color: inherit; text-decoration: none; }} .footer {{ margin-top: 24px; color: #4a5568; font-size: 12px; }}
gemini-image-gen
Engine: {engine} · {len(items)} images · {dt.datetime.now().strftime("%Y-%m-%d %H:%M")}
{thumbs}Generated with gemini-image-gen by @IISweetHeartII
""" (out_dir / "index.html").write_text(html, encoding="utf-8") ``` ### Technical Analysis The value of `it["prompt"]` originate ...[truncated 2025 chars]- Remediation
View remediation
None: safe_engine = html.escape(engine, quote=True) thumbs = "\n".join( f"""{html.escape(it["prompt"], quote=True)} """ for it in items ) ``` Additional hardening should include: 1. Escape all current and future dynamic HTML fields according to their output context. 2. Keep filename validation in place and avoid accepting arbitrary URLs for image sources. 3. Add a restrictive Content Security Policy, preferably disallowing scripts entirely: ```html ``` 4. Add regression tests using prompts containing HTML tags, quotes, event handlers, and encoded markup. 5. Verify that generated captions display attack strings literally rather than interpreting them as markup. ]]>
