T09 · Insecure Skill Coding Practices
- Location
templates/html-template.html:6- Finding
Unescaped Dynamic Content in Generated HTML
- Content
View full analysis
Vulnerability Details
File Location:
templates/html-template.html:6, 181-182, 188, 194, 201
Vulnerability Type: HTML injection and potential cross-site scripting in generated reports
Risk Level: MediumVulnerable Code
html <title>{{TITLE}} - DBpedia Query Results</title>html <h1>{{TITLE}}</h1> <div class="subtitle">{{SUBTITLE}}</div>html <div class="stats"> {{STATS}} </div>html <thead> <tr> {{TABLE_HEADERS}} </tr> </thead> <tbody> {{TABLE_ROWS}} </tbody>html <code>{{SPARQL_QUERY}}</code>Technical Analysis
The HTML template inserts multiple dynamic placeholders directly into HTML document contexts. The project does not include an implementation that applies contextual output encoding, and
SKILL.mddoes not require generated values to be escaped before substitution.The affected values may originate from a user's question, a generated SPARQL query, or data returned by the remote DBpedia endpoint. If the generation process performs literal string replacement, characters such as
<,>,&,", and'can be interpreted as HTML syntax instead of text.TITLE,SUBTITLE, andSPARQL_QUERYrequire HTML text-context encoding.STATS,TABLE_HEADERS, andTABLE_ROWSrepresent complete markup fragments and therefore require safe element construction with every embedded value encoded. Dynamically generated link destinations additionally require URI parsing and an explicit scheme allowlist.Attack Path
- An attacker supplies a crafted natural-language question or causes a malicious value to be present in remotely retrieved result data.
- The Skill incorporates that value into a title, subtitle, table cell, URI, statistics block, or displayed SPARQL query.
- The value is substituted into the template without contextual encoding or URI validation.
- The Skill saves the resulting document as an HTML report.
- A user opens that report in a browser.
- Inj ...[truncated 815 chars]
- Remediation
View remediation
Remediation Suggestions
- Apply contextual HTML encoding to every dynamic text value before insertion. At minimum, encode
&,<,>,", and'. - Do not construct
STATS,TABLE_HEADERS, orTABLE_ROWSthrough untrusted string concatenation. Use a vetted auto-escaping template engine or create elements with DOM APIs and assign untrusted data throughtextContent. - Parse dynamically generated hyperlinks as URLs and allow only explicitly approved
https:destinations. Reject schemes such asjavascript:,data:, andfile:. - Treat the displayed SPARQL query as text and escape it before placing it inside
<code>. - Add a restrictive Content Security Policy, for example one that blocks inline and external scripts unless explicitly required.
- Add
rel="noopener noreferrer"to links usingtarget="_blank". - Update
SKILL.mdto make contextual output encoding and URL validation mandatory parts of HTML generation. - Add tests using payloads such as HTML tags, event-handler attributes, closing-tag sequences, and unsafe URI schemes, verifying that they are displayed as inert text.
- Apply contextual HTML encoding to every dynamic text value before insertion. At minimum, encode
