Back to skill

Security audit

semantic-km-creator

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent modeling workflow, but its generated HTML review report can execute script from hostile source data because model JSON is embedded without required HTML-safe escaping.

Review this before installing if you may process untrusted OpenAPI, CLI, DDL, CSV, or documentation inputs. The workflow itself is disclosed and task-focused, but the generated HTML report should be fixed to HTML-escape embedded JSON or load a separate JSON file before use on hostile or third-party contracts.

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

Error
Location
assets/review-template.html:141
Finding
Unsafe Model JSON Injection Allows Script Execution in Generated Review Reports<![CDATA[ ## Vulnerability Details **File Location**: `assets/review-template.html:141` and `assets/review-template.html:353`; the unsafe generation workflow is specified at `references/review.md:28` **Vulnerability Type**: Stored HTML injection / cross-site scripting through unsafe JSON embedding **Risk Level**: High ### Vulnerable Code `references/review.md:28`: ```text Generate compact model JSON and inject it into `assets/review-template.html`. ``` `assets/review-template.html:141`: ```html <script type="application/json" id="model">/*__MODEL_JSON__*/</script> ``` `assets/review-template.html:350-354`: ```html <script> function App(){ var model = JSON.parse(document.getElementById('model').textContent); ``` ### Technical Analysis The workflow instructs the agent to insert generated model JSON directly into a `script` element. It does not require context-aware serialization, escaping, or validation before replacement of the `/*__MODEL_JSON__*/` marker. Although the element uses the non-executable `application/json` MIME type, its contents are still parsed under HTML script-element parsing rules. An attacker-controlled string containing `</script>` can terminate the JSON container before `JSON.parse` runs. The remaining content is then interpreted as HTML and may introduce an executable `script` element or another active HTML construct. This is relevant because the model is derived from externally supplied REST/OpenAPI descriptions, CLI contracts, DDL, CSV metadata, evidence text, and related interface documentation. Those sources may contain attacker-controlled descriptions, names, examples, or other textual values that are copied into the review model. Normal JSON serialization alone is insufficient because JSON permits a literal `<` character in strings. The HTML parser recognizes the closing `</script>` sequence without considering whether it appears inside a JSON string. ### Attack Path 1. An attacker supplies or modifies an interface cont ...[truncated 1688 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Use HTML-safe JSON serialization.** Before embedding serialized JSON in a script element, escape characters that can affect HTML parsing: ```javascript const safeJson = JSON.stringify(model) .replace(/</g, '\\u003c') .replace(/>/g, '\\u003e') .replace(/&/g, '\\u0026') .replace(/\u2028/g, '\\u2028') .replace(/\u2029/g, '\\u2029'); ``` At minimum, ensure that no literal case-insensitive `</script` sequence can occur in the embedded content. 2. **Document the required serialization procedure.** Update `references/review.md` so agents must use a defined context-aware encoder rather than performing unrestricted string replacement. 3. **Prefer a safer data-loading design.** Store validated model JSON in a separate local `.json` file and load it through a controlled mechanism where deployment constraints permit. If a self-contained report is mandatory, use the HTML-safe serialization approach above. 4. **Validate generated reports.** After injection, verify that the document contains exactly the expected script elements and that the model element remains structurally intact. 5. **Add regression tests** using hostile values such as: ```text </script><script>alert(1)</script> </ScRiPt><img src=x onerror=alert(1)> ``` Confirm that these values are displayed as text and cannot create DOM elements or execute code. 6. **Add a restrictive Content Security Policy.** Refactor inline scripts to use an external local script or an approved hash, then apply a policy such as: ```http Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'none'; object-src 'none'; base-uri 'none' ``` CSP should be treated as defense in depth, not as a replacement for safe serialization. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (3)

Ae1

High
Category
analysis-evasion
Content
dimensions, measures, and routing. Inject model JSON into `assets/review-template.html`; record
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The document declares `lang="zh-CN"`, which hard-codes a specific language/locale for the skill UI. Under the policy, locale constraints should either be optional for the user or clearly justified as region-specific, and no such opt-in or justification appears in this file.

Whitespace Padding

Medium
Category
Prompt Injection
Content
Normalize supplied interfaces into one complete operation inventory before modeling.

| Source        | Extract                                                                                             | Grain clues                                                           |
| ------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| REST/OpenAPI  | path+method operation; parameters/requestBody inputs; 2xx schema outputs                            | array element is often one row; object is often one resource snapshot |
| CLI           | subcommand operation; flags inputs; JSON/example output; classify read/write from observed contract | list often yields detail facts; show/get often yields snapshots       |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Static analysis

No suspicious patterns detected.