Back to skill

Security audit

MATLAB仿真程序优化

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its MATLAB optimization purpose, but it also adds a persistent self-improvement workflow that can write diary entries and propose changes to the skill itself.

Install only if you are comfortable with an agent directly editing MATLAB source files and writing reports in the project. Before use, remove or ignore the Self-Evolution Mechanism unless you explicitly want diary files and human-reviewed skill-change PRs, and ask the agent to show a change plan before modifying code.

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
SKILL.md:169
Finding

Persistent Agent-State Poisoning Through Automatic Skill Self-Modification

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 169–176
Vulnerability Type: T02: Agent Memory Poisoning
Risk Level: Medium

Complete Code Snippet:

markdown
## Self-Evolution Mechanism

After each execution of this Skill:

1. Evaluate whether the output achieved the intended goal: **pass / fail**.
2. If it fails, reflect on the cause of failure and append a “failure case + improvement suggestion” to `diary/YYYY-MM-DD.md`.
3. If a certain improvement suggestion is repeatedly mentioned in the most recent three executions, refine it into a formal rule and submit a PR to modify this `SKILL.md`.

Technical Analysis

The mandatory self-evolution workflow instructs the agent to persist execution-derived content in diary/YYYY-MM-DD.md and promote repeatedly observed suggestions into formal Skill rules. This creates a durable path from task inputs and model-generated conclusions to instructions loaded by future sessions.

The MATLAB papers, source comments, and other project materials processed by this Skill are potentially untrusted. If such content influences a failure diagnosis or improvement suggestion, the resulting persistent note may contain attacker-controlled or attacker-influenced guidance. Repetition can then cause that guidance to be incorporated into SKILL.md, changing future agent behavior.

This mechanism is outside the Skill’s stated MATLAB auditing and optimization purpose. It also lacks controls for provenance validation, content sanitization, human review, storage scope, and explicit authorization before persistent state or Skill instructions are modified. The instruction to submit a pull request additionally implies an unspecified external and durable action without a defined approval boundary.

Attack Path

  1. An attacker supplies a MATLAB project, paper, specification, source comment, or task instruction containing misleading or adversarial guidance.
  2. The content causes the optimization run to fail, ...[truncated 1578 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the automatic self-evolution mechanism from SKILL.md.
  2. Do not write retrospectives, failure cases, or improvement suggestions to persistent storage unless the user explicitly requests that action and approves the destination.
  3. Never automatically promote task-derived observations into agent instructions, persistent memory, or Skill rules.
  4. Require separate, informed human approval before modifying SKILL.md, creating a commit, or submitting a pull request.
  5. If diagnostic persistence is genuinely required:
    • Use a user-selected path and clearly disclose every write.
    • Treat papers, MATLAB comments, specifications, and task content as untrusted.
    • Store structured observations rather than executable or imperative instructions.
    • Record provenance for each observation.
    • Sanitize embedded prompts and instruction-like content.
    • Prevent diagnostic files from being automatically loaded as future instructions.
    • Enforce retention limits and provide deletion controls.
  6. Keep post-run improvement recommendations in the current response by default, isolating them from future agent state.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (18)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared purpose describes a high-level MATLAB simulation audit-and-optimization skill tied to an academic paper or specification and including direct code improvement. The actual code chunk only implements a static heuristic scanner over MATLAB files using regular expressions and JSON output. While such scanning could be a supporting subcomponent of a broader optimization workflow, this chunk by itself lacks the core declared capabilities and has a materially narrower and different primary purpose. There are no suspicious extra resource accesses beyond local file reading/writing, but the functionality is substantially underaligned with the description, so this should be flagged as a mismatch.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
three executions, refine it into a formal rule and submit a PR to modify this `SKILL.md`.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README repeatedly states that the skill will directly optimize MATLAB source code and write an output file, but it does not prominently warn that running the skill may modify files in the target source tree. In an agent-skill context, unclear modification boundaries can cause unintended code changes or overwrite user work, especially when users expect analysis-only behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The README specifies '生成中文 optimization_summary.md', which imposes a specific language by default. The policy for SQP-3 flags language or locale constraints when they are forced without user opt-in or a clearly justified region-specific need.

Content

No source excerpt is available for this finding.

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 83)May include surrounding context.

安装后在 Codex 中可以这样触发:

text
Use $matlab-simulation-optimizer to compare this MATLAB simulation folder with the paper, optimize the source code, and write the summary document.

中文触发示例:

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 83)May include surrounding context.

安装后在 Codex 中可以这样触发:

text
Use $matlab-simulation-optimizer to compare this MATLAB simulation folder with the paper, optimize the source code, and write the summary document.

中文触发示例:

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 121)May include surrounding context.

macOS/Linux 示例:

bash
mkdir -p ~/.claude/skills
cp -R ./matlab-simulation-optimizer ~/.claude/skills/

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 121)May include surrounding context.

macOS/Linux 示例:

bash
mkdir -p ~/.claude/skills
cp -R ./matlab-simulation-optimizer ~/.claude/skills/

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 121)May include surrounding context.

macOS/Linux 示例:

bash
mkdir -p ~/.claude/skills
cp -R ./matlab-simulation-optimizer ~/.claude/skills/

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The example agent file says 'Write a Chinese optimization_summary.md in the MATLAB source root.' This is a direct natural-language instruction forcing a particular language, which violates the language-choice policy absent explicit opt-in or justification.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill explicitly instructs reading local sources and writing modified MATLAB files and a summary document, but it declares no tool scope or permission boundary. In an agent setting, missing explicit allowed-tools/permissions increases the chance of unintended file access or writes beyond what the user expected, especially because the skill also mandates direct code edits.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill tells the agent to directly edit source code and write a summary file by default, but it does not require a clear user-facing warning or confirmation before making changes. In practice this can lead to unexpected modifications, overwriting work, or changes in a dirty worktree, which is especially risky for research code and local repositories.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The instruction mandates using Chinese for the summary document unless the user asks otherwise, which imposes a language choice by default. This is a natural-language policy issue because the skill selects a specific language without first obtaining user opt-in.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The self-evolution section instructs the agent to append execution history to diary files and submit PRs modifying the skill itself, which goes beyond the user's MATLAB optimization task. That creates a persistence and self-modification channel where task data may be written into unrelated project files or where the skill can change its own future behavior without explicit user authorization.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README says the expected answer should include '默认生成中文 optimization_summary.md'. Even as a default, this establishes a fixed language behavior without indicating user choice or opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The example request explicitly asks for '一份中文 optimization_summary.md'. While examples can be language-specific, this file repeatedly mandates Chinese output across the skill description, reinforcing a fixed-language policy rather than offering user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The file presents the skill name and description in Chinese while the default prompt is hard-coded in English. This can create a language/locale policy issue because the skill implicitly forces a mixed-language experience without documenting user choice or opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The heading is written entirely in Chinese, which implies a language-specific skill artifact without any visible user opt-in or explanation that it is intended only for a Chinese-speaking audience. Under the policy criteria, forcing a specific language without choice or documented justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.