Back to skill

Security audit

Memory Compress

Security checks for vulnerabilities and agentic risk

Overview

This local memory-compression skill is purpose-aligned, but it needs review because it can carry untrusted log text into long-term agent memory and uses an unsafe default temporary output path.

Install only if you are comfortable reviewing compressed output before it is added to long-term agent memory. Avoid the default /tmp/compressed-memory.md output path; pass an explicit output file in a trusted directory, and treat source logs as untrusted data rather than instructions.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • 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 (2)

T02 · Agent Memory Poisoning

Warning
Location
scripts/memory-compress.js:288
Finding

Untrusted Log Content Can Poison Persistent Agent Memory

Content
View full analysis
> MEMORY.md ``` The maintenance instructions recommend the same persistent write: ```markdown ## Memory Maintenance (every 2-3 days) 1. Run: node scripts/memory-compress.js memory/YYYY-MM-DD.md /tmp/compressed.md 2. Review for accuracy 3. Append: cat /tmp/compressed.md >> MEMORY.md 4. Timestamp: date +%s > .last-memory-maintenance ``` Matched list items are copied verbatim: ```javascript if (item.length > 5 && item.length < 300) { results.push(item); } ``` Fallback extraction also copies content verbatim: ```javascript if (item.length > 3) { results.push(` ${item}`); count++; } ``` ### Technical Analysis The compressor treats source Markdown as trusted content. It copies selected headings and list items into the generated summary without: - Separating instructions from quoted data. - Escaping or neutralizing instruction-like text. - Recording the provenance or trust level of extracted entries. - Detecting attempts to alter future agent behavior. - Preventing the generated summary from being loaded as authoritative memory. Although the documented maintenance procedure includes a manual review step, the quick-start workflow also presents direct appending to `MEMORY.md`. If a source log contains attacker-controlled text such as instructions to ignore safety constraints, reveal secrets, or run commands, that text can be retained by the compressor and subsequently stored in long-term agent memory. This is a content-level vulnerability rath ...[truncated 1410 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/memory-compress.js:39
Finding

Predictable Shared Temporary Output Allows Symlink-Based File Overwrite

Content
View full analysis
!a.startsWith('-')); const OUTPUT = args.filter(a => !a.startsWith('-'))[1] || '/tmp/compressed-memory.md'; ``` It then writes to that path without checking whether it is a symbolic link: ```javascript try { fs.writeFileSync(path.resolve(OUTPUT), compressed, 'utf-8'); } catch (err) { console.error(`错误:写入输出文件失败 - ${err.message}`); process.exit(1); } ``` ### Technical Analysis `/tmp/compressed-memory.md` is predictable and resides in a shared temporary directory. Node.js `fs.writeFileSync()` follows symbolic links and, under its default behavior, creates or truncates the resolved target. The implementation does not: - Create a private temporary directory. - Use exclusive file creation. - Reject pre-existing symbolic links. - Verify ownership of an existing output file. - Use operating-system no-follow protections. - Atomically create and replace an output owned by the current user. A local attacker can pre-create the predictable path as a symbolic link to another file. When the victim runs the script using its default output, the linked target is truncated and replaced if it is writable by the victim process. ### Attack Path 1. The attacker has local access to the same system and observes that the Skill uses `/tmp/compressed-memory.md`. 2. Before the victim runs the Skill, the attacker creates that path as a symbolic link to a target file writable by the victim. 3. The victim invokes the script without specifying a custom output path. 4. `fs.writeFileSync()` follows the symbolic link. 5. The target file is truncated and replaced with the compressed Ma ...[truncated 518 chars]
Remediation
View remediation
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (11)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 53)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 56)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 59)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 114)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 124)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 144)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 145)May include surrounding context.

md
node scripts/memory-compress.js memory/2026-03-14.md

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script's help text, usage guidance, warnings, and status messages are written entirely in Chinese, which imposes a specific language on users. There is no opt-in, fallback language, or documented justification that this skill is intended only for a Chinese-speaking context.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code parses only '#', '##', '###' headings and dash-prefixed list items, then truncates results to selected matches, first 3 items per subsection, 10 matched items, or 30 fallback items. That behavior is inherently lossy and format-limited, which conflicts with claims of zero information loss and support for any markdown format.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The manifest presents this as a local markdown memory compressor with no dependencies, focused on transforming provided logs into summaries. Accessing environment variables is not inherent to compression itself; here it is used to discover filesystem locations outside the explicit input argument, which is broader than the core text-processing purpose.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.