Skip to content
Report library
Purpose / Writing

Workers Best Practices Skill Security Audit

What the author says it does (original text)

Cloudflare Workers best practices for production applications. Use when writing, reviewing, or configuring Workers.

Independent security check

Security risks found

Files checked
4
Risks found
1
Could it run dangerous commands?Looks for programs run straight after downloading, remote control of your computer, and hidden commands.No risks found
Could it expose your files or keys?Looks for uploads of files containing passwords or keys, and keys written directly in the code.Risks found: 1
Medium risk

Production logs and traces may capture sensitive request or error data by default

Source references: 5
What we found

The Skill directs production Workers to enable logs and traces and provides structured examples that record request paths and raw error messages. Paths can contain user or resource identifiers, while exception messages can expose inputs or internal-service details. It does not require redaction, access restrictions, or retention limits.

Why this matters

If an agent applies this guidance to a Worker handling sensitive traffic, Cloudflare's logging system and people with log access may receive data that should not be retained there. Full log sampling may also increase observability costs.

This is a legitimate production-observability recommendation, not a covert collection mechanism. However, the risk is plausible: the Skill directs users to enable production logs and traces and demonstrates logging request paths and raw exception messages. If a path contains user/resource identifiers, or an exception echoes input, tokens, or internal details, that data would enter Cloudflare logs. The shown guidance does not pair this with redaction, access-control, or retention requirements. Users can ask for explicit sensitive-field filtering, log-access controls, sampling, and retention rules.

SKILL.md:26In the instructionsOpen original file
## Enable ObservabilityEnable [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Traces](https://developers.cloudflare.com/workers/observability/traces/) when creating or preparing a Worker for production. Set `observability.enabled` and `observability.traces.enabled` to `true`; the top-level setting alone does not enable traces. Use structured JSON logging and configure sampling for the workload. During reviews, flag missing logs or traces. See the [configuration example](references/configuration.md#enable-workers-logs-and-traces).
Show 4 other places
references/configuration.md:111In the instructionsOpen original file
Enable Workers Logs and Traces in Wrangler config before deploying to production. Set `observability.enabled` and `observability.traces.enabled` to `true`; the top-level setting alone does not enable traces. Use `head_sampling_rate` to control volume and cost. Use structured JSON logging — `console.log(JSON.stringify({...}))` — so logs are searchable. Use `console.error` for errors (appears at error severity in the dashboard).**Check**: logs and traces are enabled in the target deployment environment, with neither disabled by an environment override. Check `observability.enabled`, `observability.logs.enabled`, and `observability.traces.enabled`, accounting for their defaults. Logging uses structured JSON, not string concatenation.
references/configuration.md:125In the instructionsOpen original file
```ts// Structured JSON — searchable and filterableconsole.log(JSON.stringify({ message: "incoming request", method: request.method, path: url.pathname }));// Error severityconsole.error(JSON.stringify({ message: "request failed", error: e instanceof Error ? e.message : String(e) }));```
references/configuration.md:117In the instructionsOpen original file
{  "observability": {    "enabled": true,    "logs": { "enabled": true, "head_sampling_rate": 1 },    "traces": { "enabled": true, "head_sampling_rate": 0.01 }  }}
references/runtime-patterns.md:301In the instructionsOpen original file
    return Response.json(result);  } catch (error) {    const message = error instanceof Error ? error.message : "Unknown error";    console.error(JSON.stringify({ message: "unhandled error", error: message, path: new URL(request.url).pathname }));    return Response.json({ error: "Internal server error" }, { status: 500 });  }
Could it delete files or keep running?Looks for broad file deletion, disk overwrites, and programs set to start automatically.No risks found
Could it bypass safety checks?Looks for skipped website security checks, excessive file access, or actions that skip your approval.No risks found
Could it mislead the AI or hide text?Checks the skill instructions for requests to ignore you, influence the report, or hide text in invisible characters.No risks found
Could it change links or payment recipients without asking?Looks for forced referral or payment changes combined with instructions to hide the change.No risks found

Inside this skill

6 instruction sections

This Skill supports writing or reviewing Cloudflare Workers. It uses the project's existing Wrangler configuration, generated types, and compatibility settings as the baseline, then consults Cloudflare documentation for uncertain API and runtime behavior.

View source
SKILL.md:6In the instructionsOpen original file
Your knowledge of Cloudflare Workers APIs, types, and configuration may be outdated. **Prefer retrieval over pre-training** when writing or reviewing Workers code.Use the project's installed versions, generated types, and Wrangler compatibility settings as the baseline for existing code. Retrieve relevant Cloudflare documentation to verify API, configuration, runtime behavior, and limit claims.

It calls for type checks and runtime tests covering affected behavior, while explicitly stating that a narrow change does not require a full Workers audit.

View source
SKILL.md:50In the instructionsOpen original file
## ValidationUse the project's existing checks for affected Workers behavior: type-check binding or handler contract changes, and run relevant runtime tests for behavior changes. Preserve required repository checks; a narrow edit does not require a full Workers audit.

The Skill recommends managing credentials through Wrangler secrets and checking source, configuration, and local environment files to prevent credentials from entering version control.

View source
references/configuration.md:63In the instructionsOpen original file
### Store secrets with wrangler secretSecrets must never appear in wrangler config or source code. Use `wrangler secret put` and access via `env` at runtime. Non-secret config goes in `vars`.**Check**: no string literals that look like API keys, tokens, or credentials. Verify `.env` is in `.gitignore` for local dev.

Network requests, tokens, and predictable-randomness snippets in the documents are explicitly presented as examples or anti-patterns, not as instructions to execute them or use placeholder credentials.

View source
references/runtime-patterns.md:103In the instructionsOpen original file
Anti-pattern:```ts// REST API from inside a Worker — unnecessary overheadconst response = await fetch(  "https://api.cloudflare.com/client/v4/accounts/.../r2/buckets/.../objects/my-file",  { headers: { Authorization: `Bearer ${env.CF_API_TOKEN}` } });```
Start here · InstructionsSKILL.md
workers-best-practices
Lines connect the instruction file to its sections, not an observed execution order. Select a section to read the source.

File reference map

References: 4
Files making referencesReferenced content
Lines show actual file references, not execution order. Select a node to highlight its connections and inspect the files and source locations. Dashed lines include files that still need locating.
Files and check records4 files

Coverage and gaps

Content covered in each file

These are the source ranges included in this check, not a guarantee that every issue has been resolved.

  • SKILL.mdFull text included
  • references/configuration.mdFull text included
  • references/platform-apis.mdFull text included
  • references/runtime-patterns.mdFull text included

This report is for the version above. We read the available code and instructions without running the skill or checking extra packages it installs. This is not a promise of safety: a different version or setup may behave differently.

  • SKILL.mdInstructions
  • references/configuration.mdSupporting file
  • references/platform-apis.mdSupporting file
  • references/runtime-patterns.mdSupporting file

Operations mentioned in code and instructions

Connect to websites
SKILL.md:20In the instructionsOpen original file
For missing evidence, consult [Workers best practices](https://developers.cloudflare.com/workers/best-practices/workers-best-practices/) or find the affected product in the [Cloudflare docs directory](https://developers.cloudflare.com/directory/). Use the installed Wrangler schema for config fields. A newer type package does not supersede the project's configured target.
SKILL.md:28In the instructionsOpen original file
Enable [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Traces](https://developers.cloudflare.com/workers/observability/traces/) when creating or preparing a Worker for production. Set `observability.enabled` and `observability.traces.enabled` to `true`; the top-level setting alone does not enable traces. Use structured JSON logging and configure sampling for the workload. During reviews, flag missing logs or traces. See the [configuration example](references/configuration.md#enable-workers-logs-and-traces).
SKILL.md:59In the instructionsOpen original file
- **Durable Objects**: load the `durable-objects` skill- **Workflows**: see [Rules of Workflows](https://developers.cloudflare.com/workflows/build/rules-of-workflows/)- **Wrangler CLI commands**: load the `wrangler` skill
Read keys or account settings
SKILL.md:35In the instructionsOpen original file
| `await response.text()` or similar buffering on unbounded data | Can exhaust Worker memory; [stream large or unbounded bodies](references/runtime-patterns.md#stream-request-and-response-bodies). || Hardcoded secrets in source or config | Leaks credentials through version control; use Wrangler secrets. || `Math.random()` for security-sensitive tokens or IDs | Predictable values; use `crypto.randomUUID()` or `crypto.getRandomValues()`. |
SKILL.md:46In the instructionsOpen original file
| `as unknown as T` to force a platform type match | Hides incompatibilities; fix the underlying contract. || `implements` used in place of extending a platform base class | Does not inherit runtime behavior, `this.ctx`, or `this.env`; use the appropriate base class. || Unbound `env.X` in a platform class method | Bindings are available through `this.env.X`; see [binding access patterns](references/platform-apis.md#binding-access--the-most-common-error). |
SKILL.md:47In the instructionsOpen original file
| `implements` used in place of extending a platform base class | Does not inherit runtime behavior, `this.ctx`, or `this.env`; use the appropriate base class. || Unbound `env.X` in a platform class method | Bindings are available through `this.env.X`; see [binding access patterns](references/platform-apis.md#binding-access--the-most-common-error). || Applying one serialization rule across Queues, Workflow steps, storage, and WebSockets | Can reject valid payloads or accept unsupported ones; check the [specific API and encoding](references/platform-apis.md#serialization-boundaries). |
Lines read
593
File checksum (to compare versions)
5a92d5c9b7644d34eb38779de22364b8524861f3c536a9d4329aae18e30f5b45