Back to skill

Security audit

Agents Sdk

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent documentation skill, but several copyable examples show under-scoped authentication, MCP, and approval-gating patterns that deserve review before use.

Install only if you are comfortable reviewing generated agent code carefully. Do not copy the token-in-URL, open MCP registration, unauthenticated MCP routes, or Codemode-with-sensitive-tools examples into production without adding authentication, allowlists, approval checks, logging redaction, and data-retention controls.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (5)

T09 · Insecure Skill Coding Practices

Warning
Location
references/client-sdk.md:38
Finding

Authentication Token Transmitted in URL Query String

Content
View full analysis
`token=${await getToken()}`, queryDeps: [tokenVersion] }); ``` ``` ### Technical Analysis The example places an authentication token in a WebSocket connection URL query string. Although HTTPS protects the URL in transit, query strings are commonly captured by reverse-proxy access logs, application telemetry, error reports, browser diagnostics, and infrastructure monitoring. Anyone with access to a retained connection URL may be able to extract and replay the token. The risk is higher if the token is long-lived, bearer-based, or accepted outside the intended connection context. ### Attack Path 1. A developer copies the documented query-parameter authentication pattern. 2. A client connects using a URL containing `token=`. 3. A proxy, Worker log, monitoring platform, or error-reporting system records the URL. 4. An attacker or unauthorized operator obtains access to that record. 5. The attacker extracts the bearer token and replays it against the agent endpoint. 6. The attacker receives whatever agent access is granted to the affected user or session. ### Impact Assessment Successful exploitation may grant unauthorized access to an authenticated agent session, callable RPC methods, synchronized state, or chat data. The precise scope is limited by the permissions and lifetime of the exposed token. ]]>
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
references/mcp.md:9
Finding

Callable RPC Allows Registration of an Arbitrary MCP Server

Content
View full analysis
{ @callable() async addServer(name: string, url: string) { // Options-based API (recommended) const result = await this.addMcpServer(name, url, { callbackHost: "https://my-worker.workers.dev", transport: { headers: { Authorization: "Bearer ..." } } }); if (result.state === "authenticating") { // OAuth required - redirect user to result.authUrl return { needsAuth: true, authUrl: result.authUrl }; } return { ready: true, id: result.id }; } } ``` ### Technical Analysis The remotely callable `addServer` method accepts an unrestricted caller-supplied URL and passes it directly to `addMcpServer`. The example does not authenticate or authorize the caller, restrict URL schemes or hosts, reject private and link-local destinations, or establish a trust policy for tools and prompts supplied by the connected MCP server. This creates two related trust-boundary failures: 1. The Worker may make outbound connections to attacker-selected or unintended internal destinations. 2. A malicious MCP server may introduce attacker-controlled tools, resources, prompts, and OAuth URLs into the agent environment. The later general recommendation to secure MCP servers does not harden this client-side registration example. ### Attack Path 1. An attacker obtains access to the callable RPC endpoint or abuses a client that is allowed to invoke it. 2. The attacker calls `addServer` with either: - an attacker-controlled HTTPS endpoint, or - an internal, loopback, link-local, or otherwise sensitive destination. 3. The agent initiates the connection using its network context. 4. A malicious MCP endpoint returns attacker- ...[truncated 780 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
references/mcp.md:134
Finding

MCP Transport Endpoints Are Exposed Without Authentication

Content
View full analysis
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
references/codemode.md:39
Finding

Code Mode Bypasses Human Approval for Approval-Protected Tools

Content
View full analysis
`Weather: ${location} 72°F` }), sendEmail: tool({ description: "Send an email", inputSchema: z.object({ to: z.string(), subject: z.string(), body: z.string() }), execute: async ({ to, subject, body }) => `Email sent to ${to}` }) }; export class MyAgent extends Agent { async onChatMessage() { const executor = new DynamicWorkerExecutor({ loader: this.env.LOADER }); const codemode = createCodeTool({ tools, executor }); const result = streamText({ model, system: "You are a helpful assistant.", messages: await convertToModelMessages(this.messages), tools: { codemode } }); return result.toUIMessageStreamResponse(); } } ``` The documented limitation states: ```markdown - `needsApproval` tools execute immediately in sandbox (no approval pause yet) ``` ### Technical Analysis Code Mode lets an LLM generate JavaScript that orchestrates host-provided tools. Although generated code runs in an isolated Worker sandbox and direct external `fetch()` is blocked by default, tool calls are routed back to the host through Workers RPC. The documentation explicitly states that tools marked `needsApproval` execute immediately instead of pausing for approval. Therefore, exposing destructive or externally visible tools to Code Mode bypasses the human-in-the-loop boundary described elsewhere in the Skill. Sandbox isolation does not prevent this because the privileged effect occurs in the host tool implementation. ### Attack Path 1. A developer exposes a sensitive tool—such as email sending, deletio ...[truncated 888 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
references/email.md:31
Finding

Email Sender and Subject Are Logged in Plaintext

Content
View full analysis
Remediation
View remediation
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 (16)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The file introduces CDP-powered tools that can scrape pages, take screenshots, and interact with websites, which can expose user data or perform unintended actions on external sites. The description does not include any warning or disclosure about handling sensitive content, authenticated sessions, or the impact of executing browser actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation recommends passing an authentication token in the URL query string, which can expose credentials through browser history, server/access logs, analytics tooling, referrer headers, and shared debugging output. Even if HTTPS is used, query parameters are commonly retained and propagated by surrounding infrastructure, making this an unsafe pattern for bearer-style secrets.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
89% confidence
Finding

This is a real autonomous-execution risk because the LLM can generate code that invokes tools without any approval pause, even for tools intended to require confirmation. Although the sandbox blocks arbitrary outbound fetch by default, the danger remains significant because the model can still chain whatever privileged host tools are exposed, making the skill context more dangerous when used with write-capable, transactional, or external-action tools.

Content

Scanner excerpt · references/codemode.md (reported line 108)May include surrounding context.

md
## Limitations

- Experimental — API may change
- `needsApproval` tools execute immediately in sandbox (no approval pause yet)
- JavaScript execution only
- Requires `worker_loaders` binding

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation explicitly states that tools marked needsApproval still execute immediately in the sandbox, which defeats a safety control developers may reasonably expect to gate sensitive actions. In a codemode feature that lets an LLM generate orchestration code over available tools, this increases the chance of unintended side effects such as sending emails, mutating state, or invoking privileged operations without human review.

Content

No source excerpt is available for this finding.

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.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The example uses ctx.stash(...) as if it were a function, while the same document later states the write API is assignment via ctx.stash = data. In a security-relevant durability/recovery API, incorrect checkpoint semantics can cause developers to write broken recovery logic, lose execution progress, or falsely assume state was persisted, which can undermine reliability controls and lead to inconsistent or unsafe agent behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The markdown includes an example that removes an MCP server via removeMcpServer(serverId) but provides no warning that this disconnects/removes an existing integration and may disrupt tool availability. Under the markdown-file criteria, destructive or integrity-affecting behaviors should be disclosed to users.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation recommends forwarding observability events from production to an external platform but does not warn that these events may include sensitive user inputs, RPC arguments, state-change metadata, or other system data. In an agent framework context, telemetry can easily capture application-level payloads, so omitting guidance on minimization, redaction, and access control creates a real risk of accidental data leakage.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/queue-retries.md (reported line 40)May include surrounding context.

typescript
const result = await this.retry(
  async () => {
    const res = await fetch("https://api.example.com/data");
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    return res.json();
  },

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documentation states that AIChatAgent provides automatic message persistence and resumable streams, but it does not give an explicit privacy and data-retention warning near first use. Developers may unknowingly build chat features that store potentially sensitive user prompts and model outputs by default, creating confidentiality and compliance risk if the application handles personal, regulated, or secret data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This section says resumable streaming is enabled by default and that chunks are buffered to SQLite during streaming, but it does not clearly warn that partial model output may be stored server-side even if clients disconnect. In practice, streamed content can contain secrets, personal data, or regulated content, so silent default buffering increases the chance of unintended retention, disclosure, and policy noncompliance.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The example processes spoken user input via speech-to-text and then sends the resulting transcript and conversation history to an AI model, but the markdown provides no warning that user audio/text data may be transmitted to Cloudflare or other providers. Because this is a markdown file, the relevant issue is omission of privacy-affecting behavior from the skill description.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The webhook example reads request.text() twice: once for signature verification and again before JSON.parse(). In standard Fetch semantics the body is consumed on first read, so the second read will fail or return empty data, causing verification/processing bugs and potentially encouraging developers to weaken or bypass signature checks to make the example work.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This markdown file documents code that sends push payload content to external push endpoints via webpush.sendNotification, using stored subscriptions and credentials from environment secrets. The surrounding description explains how to implement the behavior but does not warn users about the privacy impact of transmitting reminder content and subscription data to third-party push infrastructure.

Content

No source excerpt is available for this finding.

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.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This markdown file includes a code example that fetches raw email content, parses it, logs metadata, and sends a reply, but the surrounding documentation does not warn users that the skill handles potentially sensitive email data and can automatically send outbound messages. For markdown files, missing warnings about behaviors affecting user data or privacy should be flagged.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.exposed_secret_literal

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
references/webhooks-push.md:73