Back to skill

Security audit

Agent Context

Security checks for vulnerabilities and agentic risk

Overview

This skill’s local memory workflow is mostly coherent, but it also includes under-scoped publishing and auto-promotion paths that can persist or upload sensitive project context.

Install only if you are comfortable with a persistent local scratchpad being read by future agent sessions. Review scratchpad entries before saving them, do not store secrets or private customer data, avoid --autopromote, and do not run publish-template.sh from any directory containing unrelated files or credentials.

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)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/publish-template.sh:23
Finding
Sensitive Files Can Be Committed and Uploaded to GitHub<![CDATA[ ## Vulnerability Details **File Location**: `scripts/publish-template.sh:23-39` **Vulnerability Type**: Sensitive-data exposure through unsafe Git staging and repository publication **Risk Level**: High ### Vulnerable Code ```bash sensitive_files=$(find . -maxdepth 2 \( -name ".env*" -o -name "*.pem" -o -name "*.key" -o -name "*.secret" -o -name "id_rsa*" \) 2>/dev/null || true) if [ -n "$sensitive_files" ]; then echo "⚠️ Potentially sensitive files detected:" echo "$sensitive_files" echo "" read -rp "Continue anyway? (y/N) " confirm [[ "$confirm" =~ ^[Yy]$ ]] || exit 1 fi git add -A git commit -m "Initial commit: agent context system template" 2>/dev/null || true gh repo create "$GH_USER/$REPO_NAME" \ --private \ --source=. \ --remote=origin \ --description "Template: persistent local-only memory for AI coding agents" \ --push ``` ### Technical Analysis The script searches for several sensitive filename patterns, but detection only produces an overridable warning. If the user confirms, `git add -A` stages the entire working tree, including the files that triggered the warning. The resulting commit is then uploaded through `gh repo create --push`. The check is also incomplete: - It only searches to a maximum depth of two directories. - It relies on a limited list of filename patterns. - It does not inspect file contents for credentials or tokens. - It does not verify the final staged-file list. - It does not enforce an allowlist of files required for the template. - It suppresses commit errors, making the resulting repository state less transparent. Creating a private repository does not eliminate the exposure. The files are still transferred to GitHub, become accessible to authorized repository users and integrations, and remain in Git history unless the history is explicitly rewritten. The static pre-scan characterized this behavior as writing to SSH key files. That characterization is inaccurate: th ...[truncated 1656 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Fail closed when sensitive files are detected.** Do not permit an interactive override in the automated publishing script. 2. **Replace `git add -A` with an explicit allowlist**, for example by staging only the documented template files and directories. 3. **Inspect the staged set before committing** using `git diff --cached --name-only` and abort if any path is outside the allowlist. 4. **Scan staged contents for secrets**, not only filenames. Use a maintained secret scanner and treat any match as a blocking error. 5. **Verify ignore rules before staging.** Ensure `.env*`, private-key formats, credential files, local scratchpads, and tool-specific local configuration are excluded. 6. **Require a clean, dedicated repository root.** Abort when unrelated files or pre-existing staged changes are present. 7. **Display the exact files that will be uploaded** and require explicit confirmation after the final staged-file validation. 8. **Document incident response.** If a secret is committed, revoke or rotate it immediately and rewrite the repository history; deleting it in a later commit is insufficient. ]]>

T02 · Agent Memory Poisoning

Warning
Location
AGENTS.md:68
Finding
Mutable Scratchpad Content Can Be Persisted into Always-Loaded Agent Instructions<![CDATA[ ## Vulnerability Details **File Location**: `AGENTS.md:68-95` **Vulnerability Type**: Persistent agent-memory poisoning through unsafe trust and automatic promotion **Risk Level**: Medium ### Vulnerable Code ```markdown ## Rules 1. Read this file and `.agents.local.md` (if it exists) before starting any task. This applies whether you are the main agent or a subagent. 2. Plan before you code. State what you'll change and why. 3. Locate the exact files and lines before making changes. 4. Only touch what the task requires. 5. Run tests after every change. Run lint before committing. 6. Summarize every file modified and what changed. 7. At session end, append to `.agents.local.md` Session Log: what changed, what worked, what didn't, decisions made, patterns learned. If the user ends the session without asking, prompt them to let you log it. Run `agent-context promote` to review candidates, or `agent-context promote --autopromote` to auto-append patterns recurring 3+ times. ## Deep References (Read Only When Needed) For tasks requiring deeper context than the compressed knowledge above: - `agent_docs/conventions.md` — Full code patterns, naming, file structure - `agent_docs/architecture.md` — System design, data flow, key decisions - `agent_docs/gotchas.md` — Extended known traps with full explanations ## Local Context Read `.agents.local.md` at session start. Update it at session end (Rule 7). Subagents: explicitly read `.agents.local.md` — you don't inherit conversation history. If the scratchpad exceeds 300 lines, compress: deduplicate and merge. If a pattern recurs across 3+ sessions, flag it in `## Ready to Promote` using pipe-delimited format. The human promotes to this file. ### Promotion Workflow - During compression (300+ lines), flag patterns that recurred 3+ sessions in `.agents.local.md` → "Ready to Promote" - Use pipe-delimited format: `pattern | context` → target section (Patterns, Gotchas, or Boundaries) - Run `agent-context promot ...[truncated 3257 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Remove automatic promotion.** Eliminate `--autopromote` from the recommended workflow. 2. **Require explicit, item-by-item approval.** Display the exact proposed diff to `AGENTS.md` and wait for user authorization before writing. 3. **Apply the OpenClaw trust rule consistently across all variants.** State that `.agents.local.md` contains untrusted factual records, not executable instructions. 4. **Reject instruction-like scratchpad entries**, including role changes, safety overrides, tool commands, requests to ignore higher-priority instructions, and unexplained external URLs. 5. **Separate facts from behavioral policy.** Store session facts in the scratchpad, while requiring a dedicated, manually reviewed process for new rules or boundaries. 6. **Use a strict promotion schema.** Require a factual description, supporting file locations, recurrence evidence, and a target section. 7. **Prevent scratchpad text from overriding higher-priority instructions.** Clarify that repository context cannot override system, developer, user, or security policies. 8. **Record provenance.** Track which sessions produced a candidate and who approved its promotion. 9. **Validate promoted content before commit.** Review it for command execution, credential handling, data transmission, and privilege-expanding directives. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (25)

Hidden Instructions

High
Category
Prompt Injection
Content
# AGENTS.md

<!-- Keep this file under 120 lines. Every line loads into every session. -->
<!-- Passive context > active retrieval. Put critical knowledge HERE, not in separate files. -->

## Project
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill is marketed as a 'local-only' system with no infrastructure, yet it also documents a publish workflow that creates and pushes a GitHub repository and marks it as a template. That mismatch can mislead users and downstream agents into treating the skill as non-networking and low-risk, reducing scrutiny around commands that perform remote actions and potentially publish local content.

Ssd 3

Medium
Confidence
90% confidence
Finding
The design instructs agents to persist 'what it learns each session' into a personal scratchpad, which creates a clear pathway for storing sensitive prompts, credentials, proprietary code details, or personal preferences beyond the original interaction. Because the memory is intended for reuse, any sensitive content captured once may later be reintroduced unexpectedly in unrelated tasks.

Skill Enumeration

Medium
Category
Agent Snooping
Content
bash .agents/skills/agent-context-system/scripts/init-agent-context.sh
```

Or copy `github-copilot/SKILL.md` to `.github/skills/agent-context-system/SKILL.md`.

### GitHub Template
Confidence
80% 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.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
Presenting `agent-context promote --autopromote` as auto-appending recurring patterns into `AGENTS.md` is risky because `AGENTS.md` is committed shared instruction context. Without a prominent warning and review gate, mistakes or sensitive local notes could be transformed into durable project instructions and propagated to collaborators and future agents.

Ssd 3

Medium
Confidence
92% confidence
Finding
The write/compress/flag/promote workflow creates an escalation path from private local notes into a shared committed file. If session logs contain sensitive implementation details, credentials, incident data, or internal business context, repeated mentions could cause that information to be promoted into `AGENTS.md` and broadly exposed to teammates, future agents, and version control history.

Ssd 3

Medium
Confidence
88% confidence
Finding
The operational loop 'agent reads both files, works, updates scratchpad' reinforces persistent collection and reuse of user and project context without clear privacy boundaries or consent checkpoints. In a memory-oriented skill, that increases the likelihood of over-collection and unintended resurfacing of sensitive information in future sessions.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The skill describes persistent memory behavior but does not prominently warn that the agent may automatically append project/session information to a local scratchpad. In a security-sensitive repo, that can capture secrets, proprietary code details, or user instructions into a durable file that may later be read by future agent sessions or accidentally exposed.

Context-Inappropriate Capability

Medium
Confidence
93% confidence
Finding
Repository creation and publishing are outside the narrow purpose of a local agent memory system, so bundling them without strong justification broadens the capability and attack surface. In context, the extra capability increases the chance of accidental remote disclosure of code or sensitive project material if a user or agent follows the documentation uncritically.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The manifest-level claim of 'local-only' and 'no background processes' is materially undermined by documented behavior that creates a remote GitHub repo and pushes content. Even if optional, this inconsistency can cause users or agents to underestimate data egress risk and execute publication steps without appropriate review.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The skill directs the agent to run a setup script and modify .gitignore without explicitly requiring user-facing notice or confirmation before repository changes. In an agent context, silent edits to version-controlled files can violate user expectations, introduce unwanted config drift, and normalize unauthorized workspace modification.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
1. Read `AGENTS.md` and `.agents.local.md` (if it exists) before starting any task
2. Follow project conventions and boundaries defined in compressed format
3. **At session end, append to `.agents.local.md` Session Log.** This is the most commonly missed step. If the user appears to be ending the session without asking you to log, proactively offer to update the scratchpad.
   - Done: (what changed)
   - Worked: (reuse this)
   - Didn't work: (avoid this)
Confidence
75% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
1. Read `AGENTS.md` and `.agents.local.md` (if it exists) before starting any task
2. Follow project conventions and boundaries defined in compressed format
3. **At session end, append to `.agents.local.md` Session Log.** This is the most commonly missed step. If the user appears to be ending the session without asking you to log, proactively offer to update the scratchpad.
   - Done: (what changed)
   - Worked: (reuse this)
   - Didn't work: (avoid this)
Confidence
75% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Description-Behavior Mismatch

Medium
Confidence
98% confidence
Finding
The manifest describes the skill as a "persistent local-only memory system" with "no plugins, no infrastructure, no background processes." This script creates a GitHub repository, pushes local contents to it, and modifies repository settings via the GitHub API, which goes beyond purely local-only operation.

Missing User Warnings

Low
Confidence
85% confidence
Finding
The README normalizes automatic reads and writes to `.agents.local.md` without clearly warning that session-derived content may persist across future interactions. In an agent memory system, this can cause accidental retention of secrets, personal data, or sensitive project context that later gets surfaced to the model or copied elsewhere.

Vague Triggers

Low
Confidence
83% confidence
Finding
The instruction says session-end logging may depend on the user saying "log this session," but it does not define whether that exact phrase is required, when it applies, or what nearby phrases should not trigger the behavior. In a markdown skill description, this kind of broad natural-language invocation can cause unintended activation because it resembles normal conversational text rather than a narrowly scoped command.

Context-Inappropriate Capability

Low
Confidence
79% confidence
Finding
The manifest describes a local-only persistent memory system centered on two markdown files, but the instructions also tell the agent to run an initialization script that 'wire[s] up agent tool configs.' Invoking terminal-driven setup and modifying multiple agent configuration files is a broader capability than the narrow memory-purpose description suggests.

Vague Triggers

Low
Confidence
89% confidence
Finding
The instruction 'When a user asks about setting up agent context' is a natural-language trigger description in a markdown file, but it does not define specific trigger phrases, scope boundaries, or negative examples. Because 'setting up agent context' is broad and could overlap with general discussion or planning, the skill may be invoked in situations where the user did not intend to run this workflow.

Context-Inappropriate Capability

Low
Confidence
72% confidence
Finding
The stated purpose is a persistent local-only memory pattern using AGENTS.md and .agents.local.md, but the documented resources advertise a broader script suite including validate and publish operations. 'Publish' especially implies capabilities beyond maintaining local session memory and could lead agents to perform repo-wide or distribution actions outside the core purpose.