Back to skill

Security audit

Claude Memory Graph Audit

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a purpose-aligned memory graph audit tool, but it needs Review because it can read and bulk-edit persistent Claude memory and its README installs mutable executable code.

Install only a reviewed ClawHub package or a pinned, verified commit. Run the audit only on memory folders you are comfortable inspecting, and require a diff, backup, and explicit confirmation before applying any link repairs to Claude memory files.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/audit.sh:16
Finding

Untrusted Markdown filenames are passed to command-line tools as options

Content
View full analysis

Vulnerability Details

File Location: scripts/audit.sh, lines 16-69
Vulnerability Type: Command-line option injection and audit-result manipulation
Risk Level: Medium

Technical Analysis

The script expands *.md directly into arguments for ls and grep without terminating option parsing with -- or prefixing generated paths with ./.

Vulnerable code includes:

bash
NODES=$(ls *.md 2>/dev/null | grep -v "^MEMORY.md$" | wc -l | tr -d ' ')

for link in $(grep -h -oE '\[\[[a-z_-]+\]\]' *.md 2>/dev/null | sed 's/\[\[//;s/\]\]//' | sort -u); do
  if [ ! -f "${link}.md" ]; then
    echo "  ❌ [[$link]] referenced from: $(grep -l "\[\[$link\]\]" *.md | tr '\n' ' ')"
    broken=$((broken+1))
  fi
done

for f in *.md; do
  [ "$f" = "MEMORY.md" ] && continue
  base="${f%.md}"
  out=$(grep -oE '\[\[[a-z_-]+\]\]' "$f" 2>/dev/null | sort -u | wc -l | tr -d ' ')
  in=$(grep -l -E "\[\[$base\]\]" *.md 2>/dev/null | grep -v "^$f$" | wc -l | tr -d ' ')
done

TOTAL_EDGES=$(grep -h -oE '\[\[[a-z_-]+\]\]' *.md 2>/dev/null | wc -l | tr -d ' ')
UNIQ_EDGES=$(grep -h -oE '\[\[[a-z_-]+\]\]' *.md 2>/dev/null | sort -u | wc -l | tr -d ' ')

Unix filenames may begin with a hyphen. After shell expansion, a filename such as --exclude=*.md can therefore be interpreted by GNU grep as an option rather than as an input file. Short-option-like filenames can similarly change behavior or produce errors.

Additionally, base is inserted directly into an extended regular expression:

bash
in=$(grep -l -E "\[\[$base\]\]" *.md 2>/dev/null | grep -v "^$f$" | wc -l | tr -d ' ')

A filename containing regular-expression metacharacters can alter the intended link-matching expression and generate incorrect in-degree or orphan-page results.

Because the script does not enable pipefail, failures from commands at the beginning of pipelines can be hidden by a successful wc, grep, or tr at the end. Re ...[truncated 1715 chars]

Remediation
View remediation

Remediation Suggestions

  1. Stop using ls for file enumeration.
  2. Use find with null-delimited output or Bash arrays so filenames remain data rather than options.
  3. Insert -- before every file-list argument accepted by grep.
  4. Prefix glob expansions with ./ where practical.
  5. Treat filenames as fixed strings when matching references, or escape all regular-expression metacharacters before interpolation.
  6. Enable pipeline failure propagation with set -euo pipefail.
  7. Do not suppress all diagnostics during audit-critical operations; explicitly handle “no match” status separately from actual execution errors.

A hardened enumeration pattern is:

bash
set -euo pipefail
shopt -s nullglob

files=(./*.md)
nodes=()

for file in "${files[@]}"; do
  [[ ${file##*/} == "MEMORY.md" ]] && continue
  nodes+=("$file")
done

NODES=${#nodes[@]}

File-list calls should terminate option parsing:

bash
grep -h -oE -- '\[\[[a-z_-]+\]\]' "${files[@]}"

For incoming-link checks, avoid interpreting the filename as an arbitrary regular expression. Given the currently permitted wikilink alphabet, validate base before use:

bash
if [[ $base =~ ^[a-z_-]+$ ]]; then
  pattern="\\[\\[$base\\]\\]"
  grep -l -E -- "$pattern" "${files[@]}"
fi

Alternatively, extract wikilink targets once, compare them as fixed strings, and construct graph relationships without dynamically generating regular expressions.

T08 · Insecure Dependencies

Warning
Location
README.md:52
Finding

Installation instructions retrieve an unpinned mutable Git repository

Content
View full analysis

Vulnerability Details

File Location: README.md, lines 52-59
Vulnerability Type: Unpinned third-party source installation
Risk Level: Medium

Technical Analysis

The documented installation process clones the current default branch of a remote GitHub repository and copies its contents directly into the user's Claude skill directory:

bash
mkdir -p ~/.claude/skills/claude-memory-graph-audit
git clone https://github.com/heavenchenggong/claude-memory-graph-audit.git /tmp/cmga
cp -r /tmp/cmga/* ~/.claude/skills/claude-memory-graph-audit/
chmod +x ~/.claude/skills/claude-memory-graph-audit/scripts/audit.sh

No immutable commit hash or signed release tag is selected, and no checksum or signature is verified. Consequently, the installed content can differ from the version that was previously reviewed. The repository's default branch is a mutable dependency controlled by the upstream account and hosting platform.

The cloned script is then explicitly made executable inside a skill directory, where it is expected to be invoked later. This creates a supply-chain trust boundary: compromise of the upstream repository, maintainer credentials, or distribution path can replace the reviewed skill content with attacker-controlled instructions or scripts.

Attack Path

  1. An attacker compromises the upstream repository, a maintainer account, or another mechanism capable of modifying the repository's default branch.
  2. The attacker changes SKILL.md, scripts/audit.sh, or adds other malicious files.
  3. A user follows the README installation commands after the malicious change.
  4. git clone retrieves the attacker's current default-branch content because no reviewed commit is pinned.
  5. cp -r places that content into ~/.claude/skills/claude-memory-graph-audit/.
  6. The installation marks the supplied audit script executable.
  7. When the skill is loaded or its script is subsequently invoked, the substitut ...[truncated 1259 chars]
Remediation
View remediation

Remediation Suggestions

  1. Publish versioned releases and instruct users to install a specific immutable release artifact.
  2. Provide a SHA-256 checksum or a cryptographic signature for each release.
  3. If Git installation remains supported, pin an exact reviewed commit instead of relying on the default branch.
  4. Verify the checked-out commit before copying or executing any files.
  5. Use a unique temporary directory created with mktemp -d, and clean it with a trap.
  6. Review the exact checked-out content before granting executable permissions.

An improved Git-based example is:

bash
set -euo pipefail

readonly REPO='https://github.com/heavenchenggong/claude-memory-graph-audit.git'
readonly COMMIT='REPLACE_WITH_REVIEWED_FULL_COMMIT_SHA'
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT

git clone --no-checkout "$REPO" "$tmp_dir/repo"
git -C "$tmp_dir/repo" checkout --detach "$COMMIT"
test "$(git -C "$tmp_dir/repo" rev-parse HEAD)" = "$COMMIT"

install -d "$HOME/.claude/skills/claude-memory-graph-audit/scripts"
install -m 0644 "$tmp_dir/repo/SKILL.md" \
  "$HOME/.claude/skills/claude-memory-graph-audit/SKILL.md"
install -m 0755 "$tmp_dir/repo/scripts/audit.sh" \
  "$HOME/.claude/skills/claude-memory-graph-audit/scripts/audit.sh"

Replace the placeholder with a complete, reviewed commit hash and publish the expected hash through an independently authenticated release channel. A signed release archive with verified checksums is preferable for end-user installation.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

该代码与“审计 memory 图谱健康度”的总体方向一致,也确实检查了断链、孤立页以及某些中心节点候选,因此不是完全无关。但描述中包含若干更强或不同的能力:一是“修复/直接修复链接”,脚本没有写入操作;二是“稀疏聚类”未实现;三是“桥接节点”实际只是高出度页面,不等同于桥接节点分析。因此描述对实际能力有明显夸大,属于描述与行为不完全一致,应判定为 mismatch。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Core user-facing instructions, descriptions, and trigger phrases are written entirely in Chinese, and the trigger examples require Chinese phrasing for activation. This creates an implicit language policy constraint without opt-in or explanation, which can exclude users expecting language flexibility.

Content

No source excerpt is available for this finding.

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
85% confidence
Finding

Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Content

Scanner excerpt · README.md (reported line 55)May include surrounding context.

安装

bash
mkdir -p ~/.claude/skills/claude-memory-graph-audit
git clone https://github.com/heavenchenggong/claude-memory-graph-audit.git /tmp/cmga
cp -r /tmp/cmga/* ~/.claude/skills/claude-memory-graph-audit/
chmod +x ~/.claude/skills/claude-memory-graph-audit/scripts/audit.sh

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · README.md (reported line 55)May include surrounding context.

安装

bash
mkdir -p ~/.claude/skills/claude-memory-graph-audit
git clone https://github.com/heavenchenggong/claude-memory-graph-audit.git /tmp/cmga
cp -r /tmp/cmga/* ~/.claude/skills/claude-memory-graph-audit/
chmod +x ~/.claude/skills/claude-memory-graph-audit/scripts/audit.sh

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The README lists natural-language trigger phrases such as "memory 之间关联够不够" and "memory 库越来越散" without negative examples or clearer constraints on when the skill should not activate. These phrases could plausibly appear in general conversation about notes or knowledge management, making invocation scope ambiguous.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The operational description, trigger phrases, and instructions are entirely in Chinese, effectively constraining use to a specific language. There is no opt-in language choice or explanation that the skill is intentionally region- or language-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill includes direct in-place modification commands (sed -i) against memory files without requiring confirmation, preview, backup, or a dry-run. In this context, memory files are user knowledge artifacts, so an incorrect pattern or filename mismatch could silently corrupt, overwrite, or bulk-modify many records.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

For markdown files, warnings should disclose behaviors affecting user data or privacy. The README states that the skill audits ~/.claude/projects/<session>/memory/ and shows how to run the script, but it does not explicitly warn users that the tool scans local memory files whose contents may be sensitive.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The skill is designed to inspect files under ~/.claude/projects/<session-uuid>/memory/*.md, which can contain user-specific session knowledge. The markdown explains the technical purpose, but it does not explicitly warn users that the skill will read and analyze their local session-memory contents.

Content

No source excerpt is available for this finding.