Back to skill

Security audit

Incident Fupan (事故复盘) — Structured Root Cause Analysis

Security checks for vulnerabilities and agentic risk

Overview

This incident-review skill has a coherent purpose, but it gives agents under-scoped command execution and persistent behavior-changing instructions that need review before use.

Install only if you are comfortable reviewing every command before it runs and controlling where incident data is stored. Disable or require explicit approval for long-term memory writes and any AGENTS.md, TOOLS.md, or skill edits, and redact sensitive incident details before saving reports.

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
SKILL.md:32
Finding
Shell Command Injection Through Unquoted Placeholders## Vulnerability Details **File Location**: `SKILL.md`, lines 32–37 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```markdown **Required evidence (use tools to retrieve):** - Logs: `exec("grep -i 'error\|fatal\|exception' {logfile} | tail -50")` - Git state: `exec("git log --oneline -10")`, `exec("git diff HEAD~1 --stat")` - Service state: `exec("systemctl status {service}")`, `exec("ps aux | grep {process}")` - Data files: `read` any CSVs, configs, or state files involved ``` ### Technical Analysis The skill instructs the agent to place variable values such as `{logfile}`, `{service}`, and `{process}` directly into shell command strings. It does not require shell escaping, strict input validation, allowlisting, or argument-array execution. If any substituted value is influenced by an untrusted incident report, filename, service name, or process identifier, shell metacharacters such as `;`, `&&`, command substitutions, redirections, or newlines may be interpreted as additional shell operations. The piped `grep` command is especially exposed because `{logfile}` is unquoted. The Git commands shown here contain no variable substitutions and are not themselves the vulnerable portion, but they appear in the complete surrounding evidence-gathering block. ### Attack Path 1. An attacker creates or identifies an incident artifact with a crafted filename, or supplies a malicious service or process value. 2. The user requests an incident review involving that attacker-influenced value. 3. Following the skill, the agent substitutes the value into one of the documented `exec(...)` command strings. 4. The shell interprets embedded metacharacters rather than treating the full value as one inert argument. 5. The injected command runs with the same operating-system privileges and environment access as the agent's execution tool. ### Impact Assessment Successful exploitation could execute arbitrary commands under the agent's a ...[truncated 362 chars]
Remediation
## Remediation Suggestions - Replace shell command strings with structured process execution using fixed executables and argument arrays. - Canonicalize file paths and restrict evidence access to explicitly approved roots. - Validate service and process identifiers with strict allowlists, such as a narrowly defined character set and maximum length. - Do not use `grep` through a shell for attacker-influenced paths; pass the path as a discrete argument and use an end-of-options marker where supported. - If a shell is unavoidable, apply robust shell-specific quoting and reject all unexpected metacharacters before execution. - Require the agent to display the resolved command and obtain approval before executing commands derived from untrusted incident input. - Add automated tests covering filenames and identifiers containing spaces, option prefixes, semicolons, substitutions, redirections, and newlines.

T02 · Agent Memory Poisoning

Error
Location
SKILL.md:90
Finding
Unapproved Persistence of Incident-Derived Instructions## Vulnerability Details **File Location**: `SKILL.md`, lines 90–95 **Vulnerability Type**: Persistent agent-memory and instruction-file poisoning **Risk Level**: High ### Vulnerable Code ```markdown ## Step 6: Reply and Store 1. Save report file to `~/incidents/` 2. Reply to user with the full report 3. Store key lessons to long-term memory 4. If applicable: update AGENTS.md, TOOLS.md, or relevant skill with new rules ``` ### Technical Analysis The workflow instructs the agent to store inferred lessons in long-term memory and potentially update `AGENTS.md`, `TOOLS.md`, or another skill. It does not require explicit user authorization, a reviewable diff, provenance tracking, content sanitization, or separation between untrusted incident evidence and persistent agent instructions. Incident evidence can include attacker-controlled logs, messages, diagnostics, and files. Converting such material into persistent “lessons” creates an indirect prompt-injection path: hostile content can be reframed as a defensive rule and then retained across sessions. Updating agent or tool instruction files further increases the risk because those files may control later behavior whenever the agent or tool is initialized. Saving the postmortem itself under `~/incidents/` is consistent with the declared reporting function. The vulnerability is the unconditional long-term-memory operation and the permission to modify behavioral instruction files without a mandatory approval boundary. ### Attack Path 1. An attacker places manipulative instructions or misleading conclusions in incident evidence accessible to the agent. 2. A user invokes the incident-review skill for that evidence. 3. The agent interprets the malicious content as a key lesson or proposed defensive rule. 4. Under Step 6, the agent stores that lesson in long-term memory or inserts it into `AGENTS.md`, `TOOLS.md`, or another skill. 5. A later session loads or relies on the poisoned state. 6. The persistent instruct ...[truncated 628 chars]
Remediation
## Remediation Suggestions - Make all long-term-memory writes and behavioral instruction-file changes opt-in. - Require explicit user approval for each proposed persistent change after showing the exact content, destination, rationale, and diff. - Treat logs and all other incident evidence as untrusted data; never copy embedded instructions into memory or configuration. - Store incident conclusions in a quarantined report or proposal file rather than directly in active memory or agent instructions. - Record provenance for every retained rule, including the incident report, supporting evidence, author, approval event, and creation time. - Restrict writable destinations through an allowlist and prohibit automatic modification of `AGENTS.md`, `TOOLS.md`, and skill definitions. - Validate proposed rules against trusted policy and scan them for prompt-injection patterns before approval. - Provide rollback, version history, and periodic review for all retained rules.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Description-Behavior Mismatch

High
Confidence
97% confidence
Finding
Directing the agent to update AGENTS.md, TOOLS.md, or other skills expands the skill from analysis into modification of system behavior and policy. That creates a pathway for an incident report—potentially based on incomplete evidence—to cause persistent prompt, tooling, or workflow changes, which could be abused or could degrade security controls across future runs.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
Why 5: {process/design gap} → Because {root cause}
```

**Stop when you reach something you can change.** If you reach "the model hallucinated" — that's not actionable. Go deeper: why was the output trusted without verification? Why was there no checkpoint?

### Step 4: Write Report
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.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill tells the agent to create directories and save reports under ~/incidents/ without any user-facing confirmation. Writing files by default can expose sensitive incident data to disk, create unintended persistence, and violate user expectations in environments where incident details should remain ephemeral or require controlled storage locations.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The workflow describes storing key lessons to long-term memory without warning the user that incident details may be persisted beyond the session. Because postmortems commonly include confidential operational history, names, outages, and root causes, undisclosed retention increases privacy, compliance, and data leakage risk.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The skill instructs storing incident lessons to long-term memory even though its primary role is incident analysis and report generation. Incident postmortems often contain sensitive operational details, personal data, or security-relevant failure modes, so persisting them without explicit consent, minimization, or retention controls creates an unjustified data persistence risk.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
**Incident class**: Agent takes a production action (deploy, restart, send message) without human approval.

**Example**: An agent autonomously deployed untested code to production at 17:44, causing service crashes within 30 minutes. The deployment bypassed review, used unaudited code with a known error risk, and caused cross-service coupling that wiped accumulated profits.

**Rules born from this**:
| Rule | Enforcement |
Confidence
80% 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
**5 Whys pattern**:
```
Crash → unaudited code deployed → agent acted autonomously →
no approval gate existed → authority boundaries were implicit, not enforced
```

## Pattern 2: Fabricated Data Report
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.

Static analysis

No suspicious patterns detected.