Back to skill

Security audit

连续短剧剧情构建

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a disclosed Chinese story-generation workflow, but its graph storage code can access or delete JSON files outside its intended folder if given a crafted pipeline ID.

Review this skill before installing if you would run it in a workspace containing important JSON files. Its story workflow is understandable, but the graph manager should validate pipeline IDs and confine paths to its graph directory before it is trusted with write or delete access.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/graph_manager.py:41
Finding

Path Traversal Enables Unauthorized JSON File Access

Content
View full analysis
str: """获取图谱文件路径""" return os.path.join(self.storage_dir, f"{pipeline_id}.json") ``` The resulting path is used directly for reading, writing, and deleting files: ```python graph_path = self._get_graph_path(pipeline_id) if os.path.exists(graph_path): try: with open(graph_path, 'r', encoding='utf-8') as f: data = json.load(f) self.cache[pipeline_id] = data return data except (json.JSONDecodeError, Exception): pass ``` ```python def _save_graph(self, pipeline_id: str, data: Dict): """保存图谱数据""" graph_path = self._get_graph_path(pipeline_id) self.cache[pipeline_id] = data with open(graph_path, 'w', encoding='utf-8') as f: json.dump(data, f, ensure_ascii=False, indent=2) ``` ```python def delete_graph(self, pipeline_id: str) -> Dict: """删除图谱""" if pipeline_id in self.cache: del self.cache[pipeline_id] graph_path = self._get_graph_path(pipeline_id) if os.path.exists(graph_path): os.remove(graph_path) return {"success": True, "message": "图谱已删除"} return {"success": False, "error": "图谱不存在"} ``` ### Technical Analysis The application incorporates `pipeline_id` directly into a filesystem path without validating its format or confirming that the normalized path remains inside `data/graphs`. `os.path.join()` does not prevent traversal. A value containing parent-directory components such as `../pipeline_state` produces a path equivalent to: ```text data/graphs/../pipeline_state.json ``` After filesystem normalization, this refers to: ```text data/pipeline_state.json ``` The `.json` suffix limits the primitiv ...[truncated 1717 chars]
Remediation
View remediation
None: if not isinstance(pipeline_id, str) or not PIPELINE_ID_PATTERN.fullmatch(pipeline_id): raise ValueError("Invalid pipeline identifier") ``` 2. Resolve and verify canonical path containment: ```python def _get_graph_path(self, pipeline_id: str) -> str: self._validate_pipeline_id(pipeline_id) base = os.path.realpath(self.storage_dir) candidate = os.path.realpath(os.path.join(base, f"{pipeline_id}.json")) if os.path.commonpath([base, candidate]) != base: raise ValueError("Graph path escapes the storage directory") return candidate ``` 3. Explicitly reject: - `..` components. - `/` and `\` path separators. - Absolute paths. - Null bytes and unexpected Unicode separator variants. 4. Defend against symbolic-link attacks by ensuring the storage directory is trusted and, where supported, opening files with no-follow semantics. 5. Apply authorization checks so a caller may only access graph files belonging to its own pipeline or tenant. 6. Use atomic writes with restrictive permissions to reduce corruption and unintended disclosure. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/pipeline.py:256
Finding

Caller-Controlled AI Review Result Bypasses the Quality Gate

Content
View full analysis
Remediation
View remediation
= self.PASS_THRESHOLD ``` 2. Require all expected review dimensions and validate every individual score as numeric and within the range `0` through `10`. 3. Recompute the aggregate score locally from the configured weights instead of trusting a model-provided aggregate. 4. Reject inconsistent responses, such as: - `passed: true` with a score below the threshold. - Missing required checks. - Non-numeric, non-finite, or out-of-range scores. - Unexpected field types. 5. Bind review results to the submitted pipeline, episode number, and content hash so that a result generated for one episode cannot be replayed for another. 6. Restrict `process_ai_review()` to a trusted internal review service rather than exposing it as a caller-controlled workflow function. 7. Isolate episode and graph content as untrusted data in the model request. Use structured messages or clearly delimited data blocks and explicitly instruct the reviewer never to follow instructions contained in story content. 8. Preserve human approval as an independent control and display validation failures or inconsistent AI results prominently to the reviewer. ]]>
Vulnerability Patterns
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (21)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

声明描述的是一个较完整的剧情生成管道流系统,核心包括生成、连续剧集支持、图谱管理和AI+人工双控。实际代码块的主功能却是“AI审核器”子模块,而且还是框架性质:review_episode直接pass,真正审核依赖外部LLM;其余功能仅限于构造审核prompt、解析JSON、格式化输出。虽然代码涉及‘图谱数据’和‘钩子处理’作为审核维度,但这只是审核输入/评分项,不等于图谱管理或自动关系管理。因此该代码与声明的整体用途存在明显不匹配,实际能力远窄于声明。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

声明描述的是一个较完整的剧情生成管道,包含连续生成、图谱管理、质检与人工确认双控、关系自动管理等能力。实际代码的核心功能仅是生成不同剧集阶段的提示词模板,并提供一个非常简化的文本解析函数。虽然代码确实支持多剧集连续生成的部分场景(首集/下一集/终集)并能利用传入的图谱与钩子上下文,但它并不管理图谱、不执行任何AI质检或人工确认,也没有真正维护人物、场景、钩子的关联数据结构。因此,声明明显高于实际实现,存在能力描述与代码行为不一致。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The declared description describes a substantial narrative-generation pipeline with multiple concrete capabilities. However, the supplied code chunk does not perform any of these functions; it is effectively empty. This is a material mismatch because the actual code has no implemented behavior corresponding to the stated purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

该代码块的实际职责是“图谱存储与查询模块”,使用本地JSON和内存缓存保存/读取剧集、人物、钩子、场景数据。它与声明中的“图谱管理”部分部分一致,但声明将技能整体描述为剧情生成管道,并强调多剧集连续生成、AI质检+人工确认双控、自动管理关联关系。代码中没有任何生成模型调用、质检逻辑、人工审批状态控制、工作流编排或关系自动推断/更新实现;relationships字段仅在查询时返回,保存时并未维护。因此,描述显著超出了该代码块实际行为,应判定为不匹配。

Content

No source excerpt is available for this finding.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/ai_reviewer.py (reported line 162)May include surrounding context.

python
[描述本集的情绪起伏]
```
"""
        return prompt
    
    def generate_next_episode(
        self,

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/episode_generator.py (reported line 148)May include surrounding context.

python
[描述本集的情绪起伏]
```
"""
        return prompt
    
    def generate_next_episode(
        self,

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/episode_generator.py (reported line 234)May include surrounding context.

python
[描述本集的情绪起伏]
```
"""
        return prompt
    
    def generate_next_episode(
        self,

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/episode_generator.py (reported line 322)May include surrounding context.

python
[描述本集的情绪起伏]
```
"""
        return prompt
    
    def generate_next_episode(
        self,

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill describes capabilities that involve reading and writing local state (data/pipeline_state.json) but does not declare an explicit tool scope or permissions boundary. This creates an authorization ambiguity: an agent or reviewer may not realize the skill can access or modify files, increasing the risk of unintended data access, state tampering, or overly broad execution in environments that rely on manifest-declared permissions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file consistently instructs and exemplifies use only in Chinese, including the description, commands, and prompts. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JSON contains user-facing natural-language content and labels exclusively in Chinese, including theme, review comments, summaries, and generated episode content. Under the policy, forcing a specific language without documenting user choice or a justified locale constraint is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains user-facing docstrings, prompt text, and formatted output entirely in Chinese, including the review task and expected JSON commentary fields. Under the stated policy, forcing a specific language without opt-in is a natural-language policy violation unless the locale constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The docstring states this method performs episode review and returns a ReviewResult object, which aligns with the module's claimed AI quality-check purpose. In reality, the body is just pass, so the code contradicts the documented behavior rather than merely omitting minor details.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The prompt hardcodes Chinese review dimensions, instructions, and summary/comment fields, effectively constraining the LLM's response language and locale. Because no alternative language option or explicit justification is provided, this conflicts with the language/locale policy described in SQP-3.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code file contains natural-language descriptions and generated prompt content in Chinese, and there is no indication that users can opt into another language or that the skill is intentionally limited to a Chinese-language context. Under the policy, forcing a specific language without user choice is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

Natural-language strings throughout the file, including module docstrings and returned user-visible messages, are written only in Chinese. Under the language/locale policy, forcing a specific language without user opt-in or documented justification is a policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code deletes a local graph JSON file via os.remove, which is a destructive operation. Although the docstring says '删除图谱', there is no confirmation prompt, cautionary warning, or other user-facing disclosure indicating that data will be permanently removed.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring, comments, and user-facing return messages are written in Chinese, indicating the skill is designed to communicate in a fixed language. The file does not document that this is region-specific or provide any opt-in or alternative locale choice, which conflicts with the language/locale policy described in the audit criteria.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code writes pipeline state to a JSON file, and elsewhere that state includes theme, review metadata, and generated story content. Although there are docstrings describing functionality, there is no explicit user-facing disclosure that submitted content and workflow state will be persisted locally on disk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This markdown template is entirely written in Chinese and labels the review format in Chinese, which effectively imposes a specific language on skill output. The policy allows locale constraints only when they are clearly justified or when users are given a language choice, neither of which appears in this file.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code file contains natural-language text in Chinese alongside English, but does not indicate that the skill is intentionally region-specific or that users may choose their preferred language. Under the language/locale policy rule, forcing or implying a specific language without opt-in can be a policy concern.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.