Back to skill

Security audit

Query Wikidata using Natural Language

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly does what it advertises, but its HTML report template can place user and Wikidata content into a browser page without required escaping.

Review generated HTML handling before installing. Use non-sensitive prompts because queries are sent to Wikidata, and treat generated reports as untrusted unless the producing agent escapes all user and Wikidata values before writing the HTML.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
templates/html-template.html:179
Finding
Unescaped Dynamic Content in Generated HTML Reports<![CDATA[ ## Vulnerability Details **File Location**: `templates/html-template.html`, lines 179–207 **Vulnerability Type**: HTML injection and potential cross-site scripting through unescaped template placeholders **Risk Level**: Medium ### Vulnerable Code ```html <h1>{{TITLE}}</h1> <div class="subtitle">{{SUBTITLE}}</div> <div class="source-badge"> <span class="badge">📊 Data Source: <span class="wikidata-logo">Wikidata</span></span> </div> <div class="stats"> {{STATS}} </div> <div class="table-wrapper"> <table> <thead> <tr> {{TABLE_HEADERS}} </tr> </thead> <tbody> {{TABLE_ROWS}} </tbody> </table> </div> <div class="sparql-section"> <strong>SPARQL Query Executed</strong><br> Endpoint: <a href="https://query.wikidata.org/sparql" target="_blank">https://query.wikidata.org/sparql</a><br><br> <code>{{SPARQL_QUERY}}</code> </div> ``` The same issue also affects the document title at line 5: ```html <title>{{TITLE}} - Wikidata Query Results</title> ``` ### Technical Analysis The template places dynamic placeholders directly into HTML markup without specifying HTML encoding or sanitization. The affected values include: - `TITLE` and `SUBTITLE`, which can be derived from a user's natural-language request. - `STATS`, `TABLE_HEADERS`, and `TABLE_ROWS`, which can contain values returned from the community-editable Wikidata service. - `SPARQL_QUERY`, which can contain text derived from user input. The Skill documentation does not require context-sensitive output encoding, sanitization, or validation when replacing these placeholders. If an untrusted value contains HTML syntax, the browser may interpret it as markup rather than plain text. For example, an unsafe replacement for `SPARQL_QUERY` could terminate the existing element and introduce an event-handler payload: ```html </code><img src="x" onerror="alert(document.domain)"><code> ``` Escaping re ...[truncated 2087 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Encode all text values before insertion** - HTML-escape `&`, `<`, `>`, `"`, and `'` in titles, subtitles, labels, statistics, query text, and other plain-text fields. - Ensure `SPARQL_QUERY` is rendered exclusively as encoded text inside `<code>`. 2. **Use an auto-escaping template engine** - Replace unrestricted string substitution with a template system that escapes output by default. - Require an explicit, reviewed operation before any value can be rendered as trusted HTML. 3. **Construct tables from typed data** - Generate each table element using safe DOM APIs such as `textContent`, or use auto-escaped template expressions. - Do not accept complete HTML fragments for `TABLE_HEADERS`, `TABLE_ROWS`, or `STATS`. 4. **Validate generated links** - Parse URLs before rendering them. - Permit only expected HTTPS destinations, such as Wikidata entity URLs with validated `Q` identifiers. - Reject dangerous schemes including `javascript:`, `data:`, and `file:`. 5. **Add a restrictive Content Security Policy** - Add a policy such as: ```html <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src https: data:; connect-src 'none'; base-uri 'none'; form-action 'none';"> ``` - Adjust the policy only for resources that the report genuinely requires. - Avoid allowing inline scripts or remote scripts. 6. **Harden external links** - Add `rel="noopener noreferrer"` to links using `target="_blank"`. 7. **Document mandatory safe rendering** - Update `SKILL.md` to explicitly require context-sensitive encoding and URL validation for every generated HTML report. - State that Wikidata results and user prompts must always be treated as untrusted input. 8. **Add security tests** - Test titles, labels, and query text containing closing tags, quotation marks, event handlers, encoded payloads, and malicious URL schemes. - Verify that ...[truncated 95 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (12)

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The README instructs users to 'Always include' a label service clause with wikibase:language set to 'en', which hard-codes English output. This is a language policy concern because it enforces a specific locale rather than offering user choice or documenting why English is required.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The description states the skill queries Wikidata using plain English prompts, which signals an English-only interaction model. Because the file does not offer user opt-in or an alternative locale choice, this is a natural-language policy concern under the language/locale rule.

Natural-Language Policy Violations

Medium
Confidence
99% confidence
Finding
The query template forces `wikibase:language "en"`, and the same English-only setting is repeated throughout the document. This imposes a specific locale on output without offering the user a choice or documenting a justified region-specific limitation.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The scope explicitly says the skill does not handle non-English labels, which is a hard locale restriction. Because the file provides no opt-in language selection and no clear justification for the restriction, it violates the natural-language locale policy.

Missing User Warnings

Low
Confidence
82% confidence
Finding
The markdown usage example says the skill can 'save as HTML' and generate an HTML page, which implies creating or overwriting a local file. The README does not include any user warning about filesystem effects, output location, or potential overwrite behavior in this description.

Missing User Warnings

Low
Confidence
85% confidence
Finding
The README documents execution of queries against a remote endpoint but does not clearly disclose the resulting network access or that user prompts/query contents will be sent to Wikidata Query Service. This can create privacy and policy issues in constrained environments where users may not expect external transmission of potentially sensitive query content.

Natural-Language Policy Violations

Low
Confidence
90% confidence
Finding
The HTML template specifies `<html lang="en">`, which bakes in an English locale for generated output. Since the skill otherwise discusses multilingual data but does not ask the user for a preferred output language, this is a locale-policy issue.

Natural-Language Policy Violations

Low
Confidence
96% confidence
Finding
The embedded query specifies `wikibase:language "en"`, which forces English labels and reflects a language/locale constraint in natural language-facing output. The file does not offer a user opt-in for language selection or explain why English-only output is required.

Natural-Language Policy Violations

Low
Confidence
97% confidence
Finding
The query uses `wikibase:language "en"`, which hard-codes English for returned labels. Because this is a general example file rather than a clearly region-specific tool, forcing English without user opt-in can violate the language/locale policy.

Natural-Language Policy Violations

Low
Confidence
98% confidence
Finding
The example requires `"Albert Einstein"@en` and also requests English labels, which constrains usage to English. In a general-purpose sample query document, this is a natural-language locale restriction that is not explained or presented as optional.

Natural-Language Policy Violations

Low
Confidence
98% confidence
Finding
The query matches `"Microsoft"@en` and requests English labels only. This imposes an undocumented English-only locale assumption in a broadly applicable example.

Natural-Language Policy Violations

Low
Confidence
90% confidence
Finding
The template sets `<html lang="en">`, which forces an English locale in the rendered output. This is a natural-language policy concern because the file provides no user opt-in, language selection mechanism, or justification for restricting output to English.