Back to skill

Security audit

Memory Sync Enhanced

Security checks for vulnerabilities and agentic risk

Overview

This skill is not malicious, but it documents memory search in a way that can silently create and modify a persistent local memory graph.

Review this before installing if you rely on CortexGraph memory state. Do not run python3 scripts/co_occurrence_tracker.py expecting a read-only search; it creates or updates ~/.config/cortexgraph/co_occurrence.db with demo relationships. Treat the package as an incomplete prototype unless the publisher adds explicit commands, dry-run/backup safeguards, and clearer documentation for any memory mutation or deletion behavior.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T02 · Agent Memory Poisoning

Warning
Location
scripts/co_occurrence_tracker.py:236
Finding

Documented Search Command Persistently Injects Synthetic Memory Relationships

Content
View full analysis

Vulnerability Details

File Location: README.md:18-23; scripts/co_occurrence_tracker.py:16-20, 236-245
Vulnerability Type: Persistent memory-state contamination
Risk Level: Medium

The README identifies direct execution of co_occurrence_tracker.py as an enhanced memory-search operation:

markdown
## Usage

```bash
# Synchronize memory
./scripts/sync-memory.sh

# Search memory (enhanced)
python3 scripts/co_occurrence_tracker.py
text

However, the tracker initializes a persistent database in the current user's home directory:

```python
def __init__(self, db_path: str = "~/.config/cortexgraph/co_occurrence.db"):
    self.db_path = Path(db_path).expanduser()
    self.db_path.parent.mkdir(parents=True, exist_ok=True)
    self._init_db()

Direct execution then records fixed demonstration identifiers rather than performing a read-only search:

python
if __name__ == "__main__":
    tracker = CoOccurrenceTracker()
    
    # Test
    test_memories = [
        "mem_001",
        "mem_002", 
        "mem_003"
    ]
    
    print("Recording co-occurrence...")
    tracker.record_co_occurrence(test_memories)

The called method creates every pairwise relationship and either inserts a new edge or increments the weight of an existing edge:

python
for i, mem_a in enumerate(memory_ids):
    for mem_b in memory_ids[i+1:]:
        if mem_a > mem_b:
            mem_a, mem_b = mem_b, mem_a

        c.execute('''
            SELECT weight FROM co_occurrence 
            WHERE memory_a = ? AND memory_b = ?
        ''', (mem_a, mem_b))

        row = c.fetchone()
        if row:
            new_weight = row[0] + 1.0
            c.execute('''
                UPDATE co_occurrence 
                SET weight = ?, last_updated = ?
                WHERE memory_a = ? AND memory_b = ?
            ''', (new_weight, now, mem_a, mem_b))
        else
...[truncated 2345 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove all demonstration writes from the default __main__ execution path.
  2. Move sample data and mutation checks into an isolated automated test that uses a temporary database.
  3. Implement explicit CLI subcommands such as search, record, stats, and demo.
  4. Make the documented search command read-only and ensure it never initializes or mutates persistent state unless necessary and clearly disclosed.
  5. Require an explicit --demo flag before inserting sample records.
  6. When a mutating command is selected, display the resolved database path and the records that will be changed.
  7. Allow callers to provide a database path so testing can be isolated from the production CortexGraph state.
  8. Add regression tests verifying that search and statistics operations do not alter database contents or timestamps.
  9. Correct the README to describe the actual behavior and remove references to unavailable scripts unless those scripts are included and audited.
  10. Provide a cleanup or migration procedure to remove existing mem_001, mem_002, and mem_003 demonstration edges without affecting legitimate records.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

代码与声明部分匹配于“Hebbian 共现图”这一部分:它会把同时出现的 memory_ids 记录为无向边,累加 weight,并在查询时按 30 天半衰期做衰减,这符合共现关联建模。但声明中的另一核心部分“Ebbinghaus 遗忘曲线”通常意味着针对单条记忆的遗忘概率、复习间隔、保留率或调度机制;本代码没有这类逻辑,只是对图边权重做通用时间衰减。此外,整体描述为“增强版记忆系统”,而代码文件仅实现共现跟踪组件,不是完整记忆系统。因此描述比实际能力更宽,存在实质性不匹配。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The README’s descriptive and instructional text is presented in Chinese, including core concepts and usage labels, with no indication that other languages are supported or that Chinese is required for a region-specific purpose. This can violate language/locale policy because it imposes a specific language on users without opt-in.

Content

No source excerpt is available for this finding.

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding

Suspicious Unicode normalization or mixed-script content

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documented ./scripts/gc.sh --threshold 0.1 command performs deletion of memories without any visible warning, dry-run mode, backup guidance, or confirmation step. In a memory-management skill, destructive operations directly threaten data integrity and could cause irreversible loss of user knowledge if run casually or automatically by an agent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The natural-language description and usage guidance are presented entirely in Chinese, which effectively forces a specific language for understanding and use. The file does not offer an alternative language, localization choice, or note that the skill is intentionally region- or language-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The package description is written entirely in Chinese ('增强版记忆系统') with no indication that language choice is optional or that the skill is region-specific. This can violate language/locale policy expectations when a skill implicitly enforces 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
89% confidence
Finding

The module docstrings and comments include user-facing natural language in Chinese (for example, the top-level description and class/docstring text) without any indication that language selection is configurable or optional. This can violate a language/locale policy when users are not given an explicit opt-in or alternative language.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.