Back to skill

Security audit

🔮 赛博易经大师 | Cyber I Ching Master

Security checks for vulnerabilities and agentic risk

Overview

This is a local Chinese I Ching and BaZi skill with no network or credential access, though some wording could mislead users about storage or connectivity.

Install only if you want a zh-CN divination and BaZi tool. Avoid entering birth details you consider sensitive unless needed, do not treat outputs as medical/legal/financial advice, and developers should be cautious with scripts/data/generate_hexagrams.py because importing it can attempt a file overwrite.

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

Note
Location
scripts/data/generate_hexagrams.py:113
Finding

Unconditional Import-Time File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/data/generate_hexagrams.py, lines 113–115
Vulnerability Type: Uncontrolled file overwrite caused by import-time side effects
Risk Level: Low

Vulnerable Code

python
# Write to file
with open('d:/cyber_iching_mastar/scripts/data/hexagrams.json', 'w', encoding='utf-8') as f:
    json.dump(data, f, ensure_ascii=False, indent=2)
print(f'Generated {len(data)} hexagrams')

Technical Analysis

The data-generation module performs a truncating file write at module scope. Consequently, importing or directly executing scripts.data.generate_hexagrams immediately opens the hardcoded destination in w mode, truncating any existing file before writing generated data.

The operation has no if __name__ == "__main__": guard, destination validation, overwrite confirmation, backup, or atomic replacement. The generated database also contains simplified placeholder line entries, so overwriting an existing complete database can cause data-integrity loss.

The hardcoded Windows-style path limits exploitability on typical non-Windows environments. However, where that path resolves and is writable, loading the module is sufficient to trigger the overwrite.

Attack Path

  1. An actor causes a user, plugin loader, test harness, or recursive module-discovery tool to import or execute scripts.data.generate_hexagrams.
  2. Python evaluates the module's top-level statements.
  3. Execution reaches open(..., 'w').
  4. If the hardcoded destination exists and is writable under the process identity, its existing contents are immediately truncated.
  5. The script replaces the destination with generated JSON containing simplified placeholder data.

No command execution, privilege escalation, or network access is required. Exploitation is limited to files writable by the current process.

Impact Assessment

The issue can overwrite and corrupt the hexagram database at the hardcoded destination. An attacker gains n ...[truncated 401 chars]

Remediation
View remediation

Remediation Suggestions

  1. Move generation and file writing into explicit functions rather than executing them at import time.
  2. Add an entry-point guard:
python
def generate_database(output_path):
    # Build and validate data here.
    # Write using an atomic replacement strategy.

if __name__ == "__main__":
    generate_database(requested_output_path)
  1. Accept the output path through a deliberate CLI argument instead of using a hardcoded absolute path.
  2. Resolve and validate the destination against an approved project directory.
  3. Refuse to overwrite an existing file unless the user supplies an explicit --force option.
  4. Write to a temporary file in the same directory, flush and synchronize it, and atomically replace the destination only after successful serialization.
  5. Create a backup before replacing valuable existing data.
  6. Add tests confirming that importing the module does not create, truncate, or modify files.
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (20)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The natural-language content of the skill is effectively restricted to Chinese, including headings, examples, commands context, and user interactions, with no indication that users may choose another language. This can violate the language/locale policy when a skill forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill explicitly processes birth date and hour data for BaZi analysis, which is personal data and can be sensitive in some contexts. Without a privacy notice, minimization guidance, or handling constraints, users may provide unnecessary personal information without understanding retention, logging, or downstream exposure risks.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill persona, instructions, and all exemplar utterances are written in Chinese throughout the file, indicating the skill is intended to operate in a single language. Under the policy, a language-specific constraint is a violation unless the skill offers user opt-in or clearly documents and justifies the locale restriction.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The closing message says '卦象已存入底层逻辑,随时可供回溯' ('the hexagram has been stored... available for recall'), which implies persistence or state retention. In reality, the code only builds an in-memory string and returns it; there is no file, database, or other storage operation anywhere in the render path or surrounding code.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The module docstring says it will generate a "complete hexagrams.json database". However, the yao entries are explicitly marked as simplified placeholders ("in real version would have full text") and use generic values like "爻辞一" through "爻辞六", so the generated output is not actually complete as documented.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language descriptions and output strings that force a specific language/locale experience. Under the policy, language constraints should either provide user choice or be clearly documented as a justified region-specific limitation, which is not present here.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest defines a broad divination skill but provides no activation conditions, trigger phrases, or scope constraints, which can cause the agent framework to invoke it in unintended contexts. In a skill ecosystem, overly broad invocation increases the chance of prompt/intent hijacking, accidental routing of unrelated user queries, or inappropriate handling of sensitive topics under the guise of this skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill hard-codes the locale to zh-CN without indicating user choice, negotiation, or fallback behavior. This can lead to consent and usability issues, and in some agent environments may cause the skill to respond in an unexpected language, increasing confusion and the risk of misinterpretation of generated advice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This test suite asserts that core outputs and method names must be specific Chinese strings such as "金钱卦" and "大衍之数". That creates a natural-language policy concern because it enforces a single language/locale in behavior without any visible user opt-in or documented locale choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The render test requires the exact Chinese phrase "善。吾已联网天地之气" to be present, which suggests the skill is expected to always respond in Chinese. Because no user language preference or opt-in is visible here, this appears to enforce a locale choice rather than offering one.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The test requires rendered output to include "八字排盘" and "日主", indicating the skill's presentation layer is expected to use Chinese terminology. In the absence of any visible opt-in or locale-selection mechanism, this may violate language/locale policy expectations.

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 instructions and descriptions exclusively in Chinese, including setup, usage, and safety notes. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale restriction is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This is an intent/documentation mismatch within the skill documentation itself: the example response implies networked behavior, while the rest of the file consistently documents an offline fortune-telling/calculation tool using local scripts and data files. The contradiction is about capability portrayal rather than an omitted implementation detail.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

This file contains mixed-language comments, with several operational descriptions written only in Chinese (for example the dependency list headings and notes). That can indicate a language/locale assumption without any visible opt-in or alternative, which falls under the language policy check for natural-language content.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The line '吾已联网天地之气' literally invokes being 'network-connected,' which suggests an external connectivity action. The implementation is entirely local: it uses random generation, optional local JSON loading, and formatting, with no network APIs or external communication.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code emits core user-facing text entirely in Chinese, including the main narrative output and cautionary messaging. The file does not provide any user opt-in, language selection, or documented reason that the skill must operate only in Chinese, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The file contains extensive Chinese-language text and labels as core output data, but there is no natural-language indication that the skill is intentionally Chinese-only or that users can opt into this locale. Under the stated policy, forcing a specific language without user choice or justification is a locale-policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This script performs a file write to a hard-coded path, which can overwrite existing data, but there is no confirmation prompt, warning comment, or docstring disclosure describing that behavior. Although the final print reports completion, it does not warn the user beforehand that a specific file on disk will be modified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

This JSON file contains user-facing natural-language text fields such as names, descriptions, and interpretations entirely in Chinese. Under the policy, forcing a specific language without user opt-in can be a locale-policy issue unless the constraint is explicitly documented and justified, which is not evident in this file.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

At L534 the generated report states '卦象已存入底层逻辑,随时可供回溯。' implying the interpretation or hexagram state has been saved. However, generate_full_interpretation only assembles and returns a string, and nowhere in the file is any storage, caching, or persistence performed.

Content

No source excerpt is available for this finding.