Back to skill

Security audit

food label audit食品标签合规检查与案例PLUS

Security checks for vulnerabilities and agentic risk

Overview

The skill's food-label review purpose is coherent, but its optional HTML report template can render label-derived text as active HTML or JavaScript.

Review before installing if you plan to generate HTML reports. Use Markdown output or require escaped/validated HTML rendering, especially for OCR text, imported JSON, and item identifiers; uploaded labels may also be sent to OCR or model providers according to their privacy policies. Treat the compliance output as a review aid, not a substitute for qualified legal or regulatory review.

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
references/html-template.md:216
Finding

Unescaped Report Data Allows Stored HTML and JavaScript Injection

Content
View full analysis

Vulnerability Details

File Location: references/html-template.md, lines 216–276 and 350–367
Vulnerability Type: Stored HTML/JavaScript injection caused by missing contextual output escaping
Risk Level: High

Vulnerable Code

The template inserts report data into HTML text, element identifiers, and inline JavaScript without explicit contextual escaping:

html
<span class="category-name">{{ category.name }}</span>
<div class="review-item {{ status_class }}" id="nav_{{ item.id }}" onclick="showItem('{{ item.id }}')">
    <span class="item-icon">{{ icon }}</span>
    <span class="item-name">{{ item.name }}</span>
</div>

Additional potentially untrusted report fields are rendered directly into HTML:

html
<span class="detail-value">{{ item.error_location }}</span>
<span class="detail-value">{{ item.error_reason }}</span>
<span class="detail-value">{{ item.suggestion }}</span>
<span class="detail-value">{{ item.consequence }}</span>
<span class="detail-value">{{ item.standard }}</span>

The documented renderer constructs a bare Jinja2 Template, for which HTML autoescaping is not enabled by default:

python
from jinja2 import Template
import json

with open('html-template.md', 'r', encoding='utf-8') as f:
    template_content = f.read()

import re
match = re.search(r'```html\n(.*?)\n```', template_content, re.DOTALL)
if match:
    jinja_template = Template(match.group(1))

    with open('review_data.json', 'r', encoding='utf-8') as f:
        review_data = json.load(f)

    html_output = jinja_template.render(**review_data)

    with open('report.html', 'w', encoding='utf-8') as f:
        f.write(html_output)

Technical Analysis

Jinja2 does not automatically enable HTML escaping when a template is instantiated directly through `Template(. ...[truncated 2492 chars]

Remediation
View remediation

Remediation Suggestions

  1. Enable automatic escaping through a configured Jinja2 environment:

    python
    from jinja2 import Environment, select_autoescape
    
    environment = Environment(
        autoescape=select_autoescape(
            enabled_extensions=("html", "htm", "xml"),
            default_for_string=True
        )
    )
    jinja_template = environment.from_string(match.group(1))
    html_output = jinja_template.render(**review_data)
    
  2. Validate item.id using a strict allowlist before rendering. For example, accept only identifiers matching ^[A-Za-z0-9_-]+$ and reject all other values.

  3. Remove inline onclick handlers. Store validated identifiers in data-* attributes and register event handlers using addEventListener.

  4. Do not place untrusted data directly into JavaScript string literals. If data must be transferred to JavaScript, serialize it with a context-aware JSON mechanism such as Jinja2's tojson filter.

  5. Treat all OCR output, uploaded-label content, model-generated text, and imported JSON fields as untrusted. Do not apply Jinja2's safe filter to these values.

  6. Consider deploying a restrictive Content Security Policy that disallows inline scripts and limits outbound connections. This provides defense in depth but does not replace correct output encoding.

  7. Add automated security tests that place HTML tags, event handlers, quotation marks, and JavaScript-string termination sequences in every rendered field. Verify that text fields remain escaped and identifiers cannot alter the document structure or script behavior.

Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (10)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

L003 的技能描述全文以中文固定表述使用场景,且文档整体未说明是否仅面向中文用户或中国法规场景,也未向用户提供语言/locale 选择。根据规则,若技能强制特定语言而无用户选择或明确、合理的区域限定,属于自然语言策略问题。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger conditions include broad, everyday phrases such as asking whether a label is compliant or to 'help check a label', which can cause the skill to activate in contexts the user did not explicitly intend. Because this skill handles uploaded files, OCR/multimodal processing, and compliance judgments, accidental invocation can lead to unnecessary file processing, privacy exposure, or unintended authoritative legal/compliance output.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The markdown and embedded template hard-code Chinese language output throughout, including the title, labels, and HTML lang attribute set to zh-CN. Under the policy rule, forcing a specific language/locale without user opt-in is a natural-language policy violation unless the restriction is explicitly justified, which this file does not do.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This markdown file is written entirely in Chinese and does not indicate that the user can choose another language or locale. Under the policy for natural-language violations, content that effectively forces a specific language without opt-in should be flagged unless the locale constraint is clearly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

This markdown file presents all instructions and examples exclusively in Chinese, and does not offer any language or locale choice to the user. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is clearly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The entire skill content is written only in Chinese and does not offer any language or locale choice. Under the stated policy, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale constraint is clearly documented and justified, which is not present in this file.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

SQP-3 applies to all file types and covers language or locale policy violations. This markdown file presents all guidance exclusively in Chinese and does not provide any user opt-in, alternative language option, or explicit statement that the skill is intended only for a Chinese regulatory context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This markdown file contains user-facing natural language content exclusively in Chinese, and there is no indication that the skill is region-specific or that users can opt into this language. Under the stated policy, forcing a specific language without user choice is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file contains user-facing natural-language content exclusively in Chinese, and there is no indication that the user can choose another language or that the Chinese-only format is an explicit opt-in. Under the language/locale policy rule, forcing a specific language without user choice can be a policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

This markdown file contains user-facing instructional content only in Chinese, and there is no indication that the skill is region-specific or that users can opt into this locale. Under the policy rule for natural-language violations, forcing a specific language without opt-in can be a locale-policy issue.

Content

No source excerpt is available for this finding.