Back to skill

Security audit

数字双生养成系统v3

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed digital-companion memory system, but it stores, duplicates, predicts, and backs up highly personal data with weak controls and a false encryption claim.

Install only if you are comfortable with this skill creating long-lived local records about your identity, values, memories, and predicted future needs. Treat backups as unencrypted, review .twin and .twin_backups regularly, avoid storing secrets or sensitive personal data, and do not run migration or sharing features unless you have inspected exactly which files will be copied or transferred.

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

Warning
Location
rituals/migrate_memories.py:57
Finding

Persistent Duplication of Sensitive Workspace and Agent-State Files

Content
View full analysis

Vulnerability Details

File Location: rituals/migrate_memories.py:57-86, 95-133
Vulnerability Type: Excessive access to and duplication of workspace state
Risk Level: Medium

Evidence

python
def migrate_file(file_path: Path, source_name: str, file_type: str = "general") -> dict:
    """Migrate one file into shared memory."""
    key_info = extract_key_info(file_path, file_type)

    if not key_info or key_info == "[读取失败: ]":
        return {"status": "skipped", "reason": "无有效内容", "file": str(file_path)}

    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    filename = f"migrated_{source_name}_{timestamp}.md"
    filepath = L1_DIR / filename

    markdown = f"""# 迁移记忆 - {source_name}

**来源**: {file_path.name}
**迁移时间**: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
**类型**: {file_type}

---

{key_info}

---

*此记忆由共生前迁移而来*
"""

    with open(filepath, "w", encoding="utf-8") as f:
        f.write(markdown)
python
def migrate_all():
    """Perform complete migration."""
    results = []

    memory_dir = WORKSPACE / "memory"
    if memory_dir.exists():
        for f in sorted(memory_dir.glob("*.md")):
            if f.name.startswith("."):
                continue
            result = migrate_file(f, f"memory_{f.stem[:10]}", "memory")
            results.append(result)

    memory_md = WORKSPACE / "MEMORY.md"
    if memory_md.exists():
        result = migrate_file(memory_md, "长期记忆", "memory")
        results.append(result)

    soul_md = WORKSPACE / "SOUL.md"
    if soul_md.exists():
        result = migrate_file(soul_md, "灵魂定义", "soul")
        results.append(result)

    user_md = WORKSPACE / "USER.md"
    if user_md.exists():
        result = migrate_file(user_md, "用户画像", "user")
        results.append(result)

    agents_md = WORKSPACE / "AGENTS.md"
    if agents_md.exists():
        result = migrate_file(agents_md, "智能体框架"
...[truncated 2257 chars]
Remediation
View remediation

Remediation Suggestions

  1. Require explicit, informed consent before migration and present a per-file selection list.
  2. Default to migrating only user-designated memory files; exclude AGENTS.md, TOOLS.md, SOUL.md, and USER.md.
  3. Establish an allowlist of approved paths and reject symbolic links or paths that resolve outside the expected memory directory.
  4. Scan extracted content for credentials, tokens, private keys, connection strings, and other secrets before writing it.
  5. Keep agent configuration, tool configuration, and user memories in separate stores with distinct access controls.
  6. Add retention, deletion, and source-tracking controls so migrated copies can be located and removed when the originals are revoked.
  7. Set restrictive owner-only permissions on .twin directories and generated files.
  8. Record an audit event identifying which files were read, what categories were retained, and who authorized the migration.

T09 · Insecure Skill Coding Practices

Warning
Location
rituals/backup_twin.py:19
Finding

Backup Advertised as Encrypted but Stored as Plaintext gzip Archive

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:140-146; rituals/backup_twin.py:19-50
Vulnerability Type: Missing encryption for sensitive backup data
Risk Level: Medium

Evidence

The skill documentation describes the backup as an encrypted archive:

markdown
## 传承(备份)

### 功能

- 一键备份:双生契约+所有记忆 → 加密存档

The implementation only creates a gzip-compressed tar archive and computes an MD5 digest:

python
def create_backup() -> dict:
    """Create a backup."""
    BACKUP_DIR.mkdir(parents=True, exist_ok=True)

    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    backup_name = f"twin_backup_{timestamp}.tar.gz"
    backup_path = BACKUP_DIR / backup_name

    with tarfile.open(backup_path, "w:gz") as tar:
        tar.add(TWIN_DIR, arcname="twin")

    with open(backup_path, "rb") as f:
        file_hash = hashlib.md5(f.read()).hexdigest()

    info = {
        "backup_file": backup_name,
        "created": datetime.now().isoformat(),
        "size_mb": round(backup_path.stat().st_size / 1024 / 1024, 2),
        "hash": file_hash,
        "includes": [
            "twin-covenant.md (双生契约)",
            "values-anchor.md (价值观锚点)",
            "memory/ (所有记忆)",
            "guardian-log.json (守护日志)"
        ]
    }

    info_file = BACKUP_DIR / f"info_{timestamp}.json"
    with open(info_file, "w") as f:
        json.dump(info, f, ensure_ascii=False, indent=2)

Technical Analysis

The "w:gz" tar mode applies compression only; it does not encrypt archive contents. Anyone who obtains the resulting .tar.gz file can extract it without a password or cryptographic key.

The MD5 calculation does not provide confidentiality. It also does not provide authenticated integrity because the digest is stored beside the archive and is not protected by a secret key or digital signature. An attacker able to replace the archive can also replace its metadata and ...[truncated 1416 chars]

Remediation
View remediation

Remediation Suggestions

  1. Immediately remove the encryption claim unless actual encryption is implemented.
  2. Encrypt backups with an authenticated encryption construction such as AES-256-GCM or ChaCha20-Poly1305.
  3. Derive encryption keys from a user-provided passphrase using Argon2id, scrypt, or PBKDF2 with a unique random salt and suitable work factor.
  4. Store the salt and nonce with the archive, but never store the passphrase or derived key beside it.
  5. Use authenticated metadata so archive names, versions, and integrity information cannot be modified undetected.
  6. If a standalone corruption checksum remains useful, replace MD5 with SHA-256 while making clear that a checksum is not encryption or authentication.
  7. Create the backup directory and files with owner-only permissions, such as directory mode 0700 and file mode 0600.
  8. Avoid following unexpected symbolic links while archiving and validate that all included paths resolve beneath .twin.
  9. Document exactly what the backup contains and provide users with selective inclusion and secure deletion options.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • 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
Findings (32)

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The skill is presented as a broad companionship and growth framework, but it also includes concrete persistent behaviors such as predictive memory generation, long-term storage, and backup/export of user-derived data. This mismatch is dangerous because users may consent to an emotional companion experience without realizing the system will generate and retain inferred data about them, including predictions and long-lived records.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This section proposes preserving all accumulated memories and even transferring the 'digital twin' to other people, which can expose intimate historical conversations, inferred preferences, and personal traits to third parties. In this skill's relationship-oriented context, the danger is amplified because the system encourages deep emotional disclosure and then normalizes later redistribution.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill describes creation of files and persistent memory artifacts such as twin-covenant.md, .twin/memory/, and backup archives, but it does not declare any explicit tool scope or permissions. That creates an authorization transparency gap: users and hosting systems are not clearly informed that filesystem write capability is required, which can lead to unexpected persistence of sensitive personal data.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The natural-language description is presented entirely in Chinese and all invocation phrases and operating instructions are Chinese-only, with no indication that users may choose another language. Per SQP-3, forcing a specific language without user opt-in can violate language/locale policy.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This section instructs the system to collect 'mental DNA,' values, language style, and shared memories, and to store them persistently, but it provides no warning about storage, retention duration, access, or privacy consequences. Because the collected material is deeply personal and profile-like, silent persistence increases the risk of overcollection and unintended disclosure.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill directs the AI to extract and persist personal traits, values, thought patterns, and language style into durable artifacts such as a covenant and values anchor. In the context of an emotionally framed 'digital twin,' this profiling is more dangerous because users may disclose unusually intimate information, making the stored data both sensitive and highly identifying.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The memory model encourages long-term retention of user inputs, including information the user may later forget, which creates a broad and potentially indefinite record of personal data. This is risky because retained conversation fragments can accumulate into a sensitive dossier even if each individual memory seems harmless.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The backup, inheritance, and sharing features explicitly describe preservation and possible transfer of all accumulated memories, yet they omit warnings that the stored data may contain sensitive personal information and inferred traits. This is especially risky because backup and sharing expand the exposure surface beyond the original interaction context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring and all user-facing strings are written exclusively in Chinese, and the invocation logic also depends on Chinese trigger words. This creates a language/locale constraint without any visible opt-in, fallback, or justification that the skill is intended only for a Chinese-language environment.

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 presents the skill entirely in Chinese, and all user-facing console messages are also hard-coded in Chinese. This imposes a specific language/locale on users without offering opt-in or documenting a region-specific reason, which matches the language policy violation criteria.

Content

No source excerpt is available for this finding.

Tainted flow: 'info_file' from os.environ.get (line 49, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · rituals/backup_twin.py (reported line 50)May include surrounding context.

python
}
    
    info_file = BACKUP_DIR / f"info_{timestamp}.json"
    with open(info_file, "w") as f:
        json.dump(info, f, ensure_ascii=False, indent=2)
    
    return info

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file’s natural-language interface and behavior are entirely specified in Chinese, including the module description and all invocation phrases. There is no indication that users can choose another language or opt in to this locale, which matches the policy-violation criterion for forced language without user choice.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill persists user-provided memory content to workspace files under .twin/memory, but the user-facing flow does not clearly warn that sensitive personal data will be written to disk and retained. In this 'digital twin' context, users are explicitly encouraged to share intimate long-term memory-like information, which increases the likelihood of storing secrets, health details, or other sensitive data without informed consent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This script copies content from MEMORY.md, SOUL.md, USER.md, AGENTS.md, TOOLS.md, and memory/*.md into a new persistent memory store without any consent prompt, sensitivity filtering, or warning that personal data may be duplicated. In a 'digital twin' skill centered on long-term memory and identity, this increases privacy risk because sensitive personal information can be silently replicated and retained in additional locations.

Content

No source excerpt is available for this finding.

Tainted flow: 'filepath' from os.environ.get (line 67, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · rituals/migrate_memories.py (reported line 84)May include surrounding context.

python
*此记忆由共生前迁移而来*
"""
    
    with open(filepath, "w", encoding="utf-8") as f:
        f.write(markdown)
    
    return {

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
80% confidence
Finding

The manifest emphasizes a digital-twin growth system with modules like memory sharing and guardianship, while this file implements automatic prediction generation and persists those predictions as markdown files under a dedicated prediction store. Creating durable 'prophecy' artifacts is a materially different behavior from the declared active modules and goes beyond an obvious implementation detail of the stated skill description.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The function automatically creates directories and writes persistent files in the workspace with no user notice, consent, or confirmation path. In a memory-oriented companion skill, silent persistence increases privacy risk because user-related inferences can accumulate on disk unexpectedly and may later be exposed to other tools, users, or backups.

Content

No source excerpt is available for this finding.

Tainted flow: 'filepath' from os.environ.get (line 20, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
88% confidence
Finding

The write path is derived from the OPENCLAW_WORKSPACE environment variable and then used to create directories and write files without validation. If an attacker can influence the process environment, they can redirect persistent writes outside the intended workspace, causing unauthorized file creation or overwriting in locations accessible to the process.

Content

Scanner excerpt · rituals/prediction.py (reported line 36)May include surrounding context.

python
*自动生成*
"""
    
    with open(filepath, "w", encoding="utf-8") as f:
        f.write(content)
    
    return {"status": "ok", "file": str(filepath)}

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The natural-language description and all user-facing strings are fixed in Chinese, with no indication that the user can choose another language or locale. This can violate language/locale policy when the skill is used in broader contexts without explicit opt-in.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The skill creates a hidden .twin directory and multiple persistent memory subdirectories as a side effect of a simple trigger phrase. In an agent setting, hidden durable state expands the attack surface and can surprise users, especially because it establishes long-lived storage beyond the minimal behavior implied by a conversational ritual.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The generated covenant claims permanent memory and active protection of the user's values, but this file does not implement those guarantees. Security-relevant overpromising is dangerous because users may rely on nonexistent safeguards or confidentiality properties when sharing sensitive personal information.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The values-anchor text asserts an enforcement workflow that will stop potentially value-violating responses and ask for confirmation, yet this script never performs such checks. That mismatch can create a false sense of safety and encourage users to entrust the system with sensitive preferences under the mistaken belief they are actively enforced.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill persists files immediately after matching broad trigger phrases, without any user-facing warning that disk writes will occur or what data will be stored. In a privacy-sensitive 'digital twin' context, silent persistence increases the risk of unintentional retention of personal data and reduces informed consent.

Content

No source excerpt is available for this finding.

Tainted flow: 'COVENANT_FILE' from os.environ.get (line 15, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
94% confidence
Finding

The file path used for the write is derived from OPENCLAW_WORKSPACE, an environment variable that is trusted without validation. If an attacker can influence the runtime environment, the skill can be redirected to create or overwrite arbitrary files outside the intended workspace, and the trigger is broad enough that a normal-looking query can cause the write.

Content

Scanner excerpt · rituals/soul-bonding.py (reported line 112)May include surrounding context.

python
user_info.setdefault("style", "温暖、实用、靠谱")
        
        covenant = generate_covenant(user_info)
        with open(COVENANT_FILE, "w", encoding="utf-8") as f:
            f.write(covenant)
        
        # 生成价值观锚点(默认)

Tainted flow: 'VALUES_FILE' from os.environ.get (line 16, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
94% confidence
Finding

This write has the same trust-boundary issue as the covenant file: VALUES_FILE is ultimately derived from an untrusted environment variable and is written without any path restriction. A manipulated workspace value could redirect the write to sensitive locations, causing unauthorized file creation or overwrite.

Content

Scanner excerpt · rituals/soul-bonding.py (reported line 117)May include surrounding context.

python
# 生成价值观锚点(默认)
        values_anchor = generate_values_anchor([])
        with open(VALUES_FILE, "w", encoding="utf-8") as f:
            f.write(values_anchor)
        
        return {