Back to skill

Security audit

记忆秘书

Security checks for vulnerabilities and agentic risk

Overview

The skill's main memory-analysis behavior is mostly coherent, but its test suite can execute Python files outside the reviewed package and the runtime writes derived memory reports with limited disclosure.

Review this before installing if you plan to run its tests or use it in CI. Normal use is local and memory-focused, but avoid running the included test suite until the external script paths are fixed, and be aware that reports may be persisted under your workspace memory directory.

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
tests/test_core.py:52
Finding

Arbitrary External Python Code Execution Through Unsafe Test Paths

Content
View full analysis

Vulnerability Details

File Location: tests/test_core.py, lines 52-117
Vulnerability Type: Execution and import of Python files outside the project boundary
Risk Level: High

Vulnerable Code

python
def setUp(self):
    self.workspace_root = Path(__file__).parent.parent.parent
    self.script_path = self.workspace_root / 'scripts' / 'pilot_check_stage3.py'

def test_pilot_check_execution(self):
    import subprocess
    result = subprocess.run(
        ['python3', str(self.script_path), '测试任务'],
        capture_output=True,
        text=True,
        timeout=10
    )
python
def setUp(self):
    self.workspace_root = Path(__file__).parent.parent.parent
    self.script_path = self.workspace_root / 'scripts' / 'daily_memory_check.py'

def test_daily_check_execution(self):
    import subprocess
    result = subprocess.run(
        ['python3', str(self.script_path)],
        capture_output=True,
        text=True,
        timeout=30
    )
python
def setUp(self):
    self.workspace_root = Path(__file__).parent.parent.parent
    self.design_path = self.workspace_root / 'scripts' / 'smart_adaptive_mem0_design.py'

def test_smart_router_initialization(self):
    try:
        sys.path.insert(0, str(self.workspace_root / 'scripts'))
        from smart_adaptive_mem0_design import SmartRouter

        router = SmartRouter()
        self.assertIsNotNone(router, "The smart router should initialize successfully")

    except ImportError as e:
        self.skipTest(f"The adaptive module is not fully implemented: {e}")

Technical Analysis

test_core.py resides under <project>/tests/. Consequently, Path(__file__).parent.parent.parent resolves to the parent directory of the project rather than the project root. The resulting script directory is therefore <project-parent>/scripts/, outside the audited package.

The test suite ...[truncated 2124 chars]

Remediation
View remediation

Remediation Suggestions

  1. Resolve the actual project root instead of its parent:

    python
    project_root = Path(__file__).resolve().parent.parent
    scripts_dir = project_root / "scripts"
    
  2. Do not execute or import scripts that are absent from and outside this project. Remove these tests if they target unrelated workspace components.

  3. Before executing any path, resolve it and enforce project-root containment:

    python
    project_root = Path(__file__).resolve().parent.parent
    script_path = (project_root / "scripts" / "pilot_check_stage3.py").resolve()
    
    if not script_path.is_relative_to(project_root):
        raise RuntimeError("Refusing to execute a file outside the project root")
    
  4. Avoid modifying sys.path to include shared or parent workspace directories. Package the intended module normally and import it through the installed project package.

  5. Replace external process tests with direct unit tests of MemorySecretaryLite. Use tempfile.TemporaryDirectory to construct isolated workspace and memory fixtures.

  6. If subprocess testing is necessary, execute only a version-controlled fixture inside the repository and use a sanitized environment, isolated working directory, and least-privileged test account.

  7. Add a CI check that rejects test paths resolving outside the repository and verifies that every executed script is tracked by the project.

Vulnerability Patterns
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (13)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code file's docstrings and all visible user-facing messages are presented only in Chinese, with no option for the user to select another language. The policy explicitly calls out language or locale constraints as violations unless the skill offers opt-in or clearly documents a justified region-specific limitation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill creates a persistent directory under the workspace memory path and later writes multiple report files there without any explicit notice, consent, or retention controls. Because the tool scans user memory files and stores derived metadata such as quality reports, reminders, and success-case summaries, it can silently persist potentially sensitive local information and expand the privacy footprint of the workspace.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · tests/test_core.py (reported line 62)May include surrounding context.

python
def test_pilot_check_execution(self):
        """测试飞行员检查可执行"""
        import subprocess
        result = subprocess.run(
            ['python3', str(self.script_path), '测试任务'],
            capture_output=True,
            text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · tests/test_core.py (reported line 91)May include surrounding context.

python
def test_daily_check_execution(self):
        """测试每日检查可执行"""
        import subprocess
        result = subprocess.run(
            ['python3', str(self.script_path)],
            capture_output=True,
            text=True,

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The changelog heading and core explanatory text are written in Chinese, and the linked standards are specifically the zh-CN localized versions. This suggests a fixed language/locale presentation without any indication that users can choose another language or that the skill is intentionally limited to a Chinese-speaking context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill documentation is entirely in Chinese, including the title, description, usage guidance, and FAQ, with no indication that other languages are supported or that the language choice is intentional and limited to a specific audience. Under the policy, forcing a specific language without user opt-in is a natural-language locale concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
38% confidence
Finding

The README explicitly states the tool 'only reads memory files' and 'will not modify original files.' Elsewhere, it documents report generation and cron-based automated checks, which imply side effects beyond pure read-only analysis if outputs are persisted. This is a weak but notable documentation-level inconsistency because the text frames the tool as strictly non-modifying while also advertising generated artifacts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

This code file contains user-facing natural-language strings and docstrings exclusively in Chinese, including headings, status messages, and error text. Under the policy rule for language or locale constraints, forcing a single language without user opt-in can be a natural-language policy violation when no alternative or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring presents the skill name and description exclusively in Chinese, and there is no natural-language indication that users can choose another language or that the skill is intended only for a Chinese-language audience. This can conflict with language/locale policy expectations when a skill implicitly forces a language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The exported metadata fields use Chinese-only text and do not document any locale restriction or user opt-in for language selection. In the absence of a justified regional scope, this may represent an implicit language constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The module name and all user-facing strings, docstrings, and examples are written in Chinese, but the file does not state that it is intentionally limited to Chinese-speaking users or provide a language option. This can violate language/locale policy when a skill forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This Python test file uses Chinese-only natural-language descriptions in the module docstring and class docstrings, which imposes a specific language/locale in user-visible or maintainer-visible text. The policy allows locale constraints only when the skill offers opt-in choice or clearly documents a justified region-specific purpose, which is not present here.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The test is documented as checking the current day's memory file, and the inline comment says the file should exist or be creatable. However, the condition today_file.exists() or True is always true, so the test does not actually verify existence or creatability at all.

Content

No source excerpt is available for this finding.