Back to skill

Security audit

Fortune Telling Bazi

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent local BaZi fortune-telling skill, with the main caution that it stores personal birth details locally in plaintext.

Before installing, understand that this skill saves names, exact birth dates and times, gender, and derived BaZi profiles in local JSON files. Use it only with consent from the people whose data is entered, avoid committing the data directory to a repository, and remove or deactivate profiles when they are no longer needed.

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
scripts/store.py:25
Finding

Personal Birth Data Stored in Plaintext Without Enforced File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py:67-74; scripts/store.py:25-29
Vulnerability Type: Plaintext sensitive-data storage with insufficient access-control hardening
Risk Level: Medium

Vulnerable Code

python
# scripts/main.py:67-74
users[name] = {
    "birth": {"year": int(year), "month": int(month), "day": int(day),
              "hour": int(hour), "minute": int(minute), "gender": gender},
    "bazi": fate_dict,
    "fetched_at": now_iso(),
}
save_users(users)
python
# scripts/store.py:25-29
def save_users(data):
    ensure_dir()
    with open(USERS_FILE, "w", encoding="utf-8") as f:
        json.dump(data, f, ensure_ascii=False, indent=2)

Technical Analysis

The application persistently records names, exact birth dates and times, gender, and derived BaZi profiles in the predictable data/users.json file. The data is serialized as human-readable plaintext.

The application does not explicitly set owner-only permissions on the data directory or file. Instead, the resulting permissions depend on the runtime environment's process umask and any preexisting filesystem permissions. In an environment with a permissive umask or shared project directory, other local accounts or processes may be able to read this personal information.

The same storage design is also used for active identities in data/active.json, although the complete sensitive birth profile is stored in users.json. No encryption, field minimization, retention control, or permission validation is implemented.

Attack Path

  1. A user or agent invokes the documented add command and supplies a person's name, exact birth date, birth time, and gender.
  2. cmd_add() constructs a record containing those identifiers and the derived profile.
  3. save_users() writes the complete record as plaintext to the predictable data/users.json path.
  4. File access permissions are inherited from the process umask rather than being explicitly restricted ...[truncated 1111 chars]
Remediation
View remediation

Remediation Suggestions

  1. Enforce owner-only filesystem permissions

    • Create the data directory with mode 0700.
    • Create data files with mode 0600 using os.open() with explicit flags and permissions.
    • Validate and correct permissions on preexisting files before reading or writing them.
  2. Use atomic, permission-preserving writes

    • Write to a temporary file in the protected data directory.
    • Flush and synchronize the file before replacing the destination with os.replace().
    • Ensure the temporary file is also created with mode 0600.
    • This also reduces the risk of corruption from interrupted writes.
  3. Minimize retained data

    • Store only fields required for later calculations and reports.
    • Avoid retaining redundant copies of names, birth details, and derived data.
    • Allow operation without persistent storage when users need only a one-time calculation.
  4. Provide privacy controls

    • Obtain clear consent before storing information about another person.
    • Add commands to enumerate, export, and permanently erase stored profiles.
    • Document retention behavior and warn that backups or repository history may preserve deleted records.
  5. Consider encryption where the threat model requires it

    • Encrypt sensitive records at rest with a key held outside the project directory.
    • Do not hardcode the encryption key in the Skill.
    • Note that encryption complements but does not replace restrictive filesystem permissions.
  6. Prevent accidental publication

    • Add data/users.json, data/active.json, temporary files, and backups to .gitignore.
    • Include a startup check that warns when sensitive data files are tracked by version control or are readable by group/other users.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The declared description presents a conversational skill with stateful user-management features: collecting birthdays interactively, storing multiple people’s BaZi profiles, reusing stored data across subsequent conversations, supporting joint analysis, and recognizing a stop command. The supplied code does not implement those skill-level behaviors. Instead, it is a pure computational backend for BaZi calculation and serialization around a single person's birth data. This is not malicious or resource-inconsistent—it does not access undeclared permissions or remote services—but it materially under-implements the declared user-facing functionality. Therefore the description does not accurately represent what this code chunk actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The description presents a conversational skill with stateful behavior: collecting a birthday initially, storing multiple users' Bazi profiles, reusing that information in future dialogue, and recognizing a stop command. The supplied code is only a computational library for lunar/Bazi calculations. It provides date conversion and astrological attribute derivation, which is consistent with fortune-telling support at a low level, but it does not implement the core declared product behavior around storage, conversation management, or triggers. Therefore the description materially overstates and mischaracterizes what this code chunk actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents an interactive fortune-telling skill with stateful conversation features and user-profile management. The actual code chunk is only a test file: it imports calculation/calendar modules, checks known Bazi outputs, and tests solar↔lunar conversion consistency. While the tested domain is related to Bazi calculation, the code shown does not implement the described skill behavior. Its primary purpose is quality assurance for underlying calculation logic, not the user-facing multi-person stored-analysis workflow described.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill collects and persists highly sensitive personal data including name, birth date, time, and gender, but the description does not provide a clear privacy notice, retention disclosure, or consent flow. Because this data is written to local files, users may unknowingly expose durable personal profile information that can later be read, reused, or leaked.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Automatically injecting saved BaZi summaries into every later reply risks repeated disclosure of sensitive personal data without renewed user intent or awareness. In multi-turn or shared-session contexts, this can leak identity, birth details, inferred attributes, and relationship analysis into unrelated conversations or to unintended viewers.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The phrase "我的八字" is ambiguous and can plausibly occur in normal discussion, so the skill may activate without clear user intent. Because the skill then collects and persists sensitive birth information and may automatically attach BaZi summaries in later replies, mistaken activation can expose private context beyond the initial interaction.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger phrase "算命" is very broad and likely to appear in ordinary conversation, which can cause unintended skill activation. In this skill, accidental activation is more sensitive than usual because it can prompt for and retain personal birth data, increasing privacy and consent risks.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The English section instructs users to start the skill by saying Chinese phrases, but it does not offer English alternatives or explain that the skill is intentionally Chinese-only. This creates a language/locale constraint without explicit user opt-in or documented justification.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
78% confidence
Finding

The skill documents file read/write behavior and persistent storage, but it does not declare any explicit tool scope such as allowed tools or permissions. That creates an authorization ambiguity where the runtime may grant broader capabilities than users or reviewers expect, increasing the chance of unintended filesystem access or misuse.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

A documented deletion command without confirmation guidance creates risk of accidental or malicious data loss, especially because names are simple identifiers and the skill supports multiple stored users. In a conversational interface, ambiguous or spoofed commands can easily trigger irreversible deletion of personal records.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger phrases are broad everyday expressions, which raises the chance of accidental activation and unintentional entry into a mode that collects or exposes sensitive personal data. In this skill's context, accidental triggering is more dangerous because activation can lead to persistence and automatic context injection of private birth-profile information.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code's natural-language documentation and output model are centered on Chinese-language labels and values such as '男/女', '桃花', '天乙贵人', and other Chinese-only strings, but the file does not document that the skill is region- or locale-specific or offer a user language choice. Under the locale policy rule, forcing a specific language without opt-in is a policy concern even when it appears in code comments, docstrings, and string literals.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code presents its usage instructions and command feedback entirely in Chinese, with no indication that the skill is region-specific or that users may select another language. That creates a natural-language locale policy concern because the skill enforces a specific language by default rather than offering opt-in or justification.

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 and all user-facing report labels are written exclusively in Chinese, and the code constructs report output only in Chinese. This indicates a fixed language behavior without any visible user language selection or documented locale justification, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 550)May include surrounding context.

python
"me":        f.day_stem,
        "detail": {
            p_key: {
                "gan":      getattr(f, f'{p_key}_pillar').stem,
                "zhi":      getattr(f, f'{p_key}_pillar').branch,
                "wuxing":   getattr(f, f'{p_key}_pillar').stem_el,
                "yinyang":  getattr(f, f'{p_key}_pillar').yinyang,

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 551)May include surrounding context.

python
"detail": {
            p_key: {
                "gan":      getattr(f, f'{p_key}_pillar').stem,
                "zhi":      getattr(f, f'{p_key}_pillar').branch,
                "wuxing":   getattr(f, f'{p_key}_pillar').stem_el,
                "yinyang":  getattr(f, f'{p_key}_pillar').yinyang,
                "shishen":  getattr(f, f'{p_key}_pillar').ten_god,

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 552)May include surrounding context.

python
p_key: {
                "gan":      getattr(f, f'{p_key}_pillar').stem,
                "zhi":      getattr(f, f'{p_key}_pillar').branch,
                "wuxing":   getattr(f, f'{p_key}_pillar').stem_el,
                "yinyang":  getattr(f, f'{p_key}_pillar').yinyang,
                "shishen":  getattr(f, f'{p_key}_pillar').ten_god,
                "nayin":    getattr(f, f'{p_key}_pillar').na_yin,

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 553)May include surrounding context.

python
"gan":      getattr(f, f'{p_key}_pillar').stem,
                "zhi":      getattr(f, f'{p_key}_pillar').branch,
                "wuxing":   getattr(f, f'{p_key}_pillar').stem_el,
                "yinyang":  getattr(f, f'{p_key}_pillar').yinyang,
                "shishen":  getattr(f, f'{p_key}_pillar').ten_god,
                "nayin":    getattr(f, f'{p_key}_pillar').na_yin,
                "canggan":  getattr(f, f'{p_key}_pillar').hidden,

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 554)May include surrounding context.

python
"zhi":      getattr(f, f'{p_key}_pillar').branch,
                "wuxing":   getattr(f, f'{p_key}_pillar').stem_el,
                "yinyang":  getattr(f, f'{p_key}_pillar').yinyang,
                "shishen":  getattr(f, f'{p_key}_pillar').ten_god,
                "nayin":    getattr(f, f'{p_key}_pillar').na_yin,
                "canggan":  getattr(f, f'{p_key}_pillar').hidden,
                "xunkong":  getattr(f, f'{p_key}_pillar').vacant,

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 555)May include surrounding context.

python
"wuxing":   getattr(f, f'{p_key}_pillar').stem_el,
                "yinyang":  getattr(f, f'{p_key}_pillar').yinyang,
                "shishen":  getattr(f, f'{p_key}_pillar').ten_god,
                "nayin":    getattr(f, f'{p_key}_pillar').na_yin,
                "canggan":  getattr(f, f'{p_key}_pillar').hidden,
                "xunkong":  getattr(f, f'{p_key}_pillar').vacant,
            }

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 556)May include surrounding context.

python
"yinyang":  getattr(f, f'{p_key}_pillar').yinyang,
                "shishen":  getattr(f, f'{p_key}_pillar').ten_god,
                "nayin":    getattr(f, f'{p_key}_pillar').na_yin,
                "canggan":  getattr(f, f'{p_key}_pillar').hidden,
                "xunkong":  getattr(f, f'{p_key}_pillar').vacant,
            }
            for p_key in ('year', 'month', 'day', 'hour')

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/calc.py (reported line 557)May include surrounding context.

python
"shishen":  getattr(f, f'{p_key}_pillar').ten_god,
                "nayin":    getattr(f, f'{p_key}_pillar').na_yin,
                "canggan":  getattr(f, f'{p_key}_pillar').hidden,
                "xunkong":  getattr(f, f'{p_key}_pillar').vacant,
            }
            for p_key in ('year', 'month', 'day', 'hour')
        },

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/report.py (reported line 28)May include surrounding context.

python
"""兼容 Fate dataclass 和 dict"""
    if isinstance(obj, dict):
        return obj.get(key, default)
    return getattr(obj, key, default)


def _get_pillar_detail(fate, pillar_key, is_fate=True):

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/report.py (reported line 38)May include surrounding context.

python
is_fate=False → dict(旧格式)
    """
    if is_fate:
        pillar = getattr(fate, f"{pillar_key}_pillar", None)
        if pillar is None:
            return {}
        return {

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/report.py (reported line 216)May include surrounding context.

python
def _get_branch(bazi, pillar_key, is_fate):
    """取某柱地支"""
    if is_fate:
        pillar = getattr(bazi, f"{pillar_key}_pillar", None)
        return pillar.branch if pillar else ''
    raw = bazi.get("bazi", {})
    if isinstance(raw, dict):