Back to skill

Security audit

Add Pi Events D1

Security checks for vulnerabilities and agentic risk

Overview

The skill is purpose-aligned for managing site events, but it uses broad Cloudflare credentials and live database mutation commands in ways that need careful review.

Install only if you control the target Cloudflare account and are comfortable with an agent making live event database changes. Before use, pin Wrangler, use a dedicated least-privilege D1 token, avoid sourcing a shared env file, and require explicit confirmation before insert, update, or delete commands.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:43
Finding
Shell Command Injection Through User-Controlled Event Data<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 43-49 **Vulnerability Type**: Shell command injection caused by unsafe command construction **Risk Level**: High ### Vulnerable Code ```bash source ~/.env/.env cd /Users/viki/Projects/projects/marketing-bull/babenchuk-com CLOUDFLARE_API_TOKEN="$CF_API_TOKEN" \ CLOUDFLARE_ACCOUNT_ID="$CF_ACCOUNT_ID" \ npx wrangler d1 execute mb-events --remote \ --command "INSERT INTO events (name, address, date_start, date_end, location, rsvp_contact, rsvp_to, register_url, tags) VALUES ('...', ...);" ``` ### Technical Analysis The Skill instructs the Agent to incorporate event information received through messages, CSV files, or lists into a SQL statement embedded directly inside a double-quoted shell argument. The only documented escaping rule is to double SQL single quotes. That may address basic SQL string termination, but it does not address shell metacharacters interpreted while the generated command is parsed. If the Agent places an event field containing a double quote, command substitution, backticks, or other shell syntax directly into the command text, the value can escape the intended `--command` argument and cause arbitrary local commands to run. This is particularly dangerous because the command is executed in a process that has access to Cloudflare credentials loaded immediately beforehand. ### Attack Path 1. An attacker supplies a crafted event name, address, URL, or another event field through a message or CSV file. 2. The Agent follows the Skill and converts that value into an inline SQL statement. 3. The crafted value contains shell syntax that terminates or alters the double-quoted `--command` argument. 4. The shell evaluates the injected command when the generated Wrangler invocation is executed. 5. The injected process runs with the permissions of the Agent's operating-system account and may inherit or access the loaded Cloudflare credentials. 6. The attacker can consequently ...[truncated 582 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Do not construct shell commands by interpolating event data into command strings. - Generate SQL using a dedicated parser or serializer that safely handles every field. - Write bulk SQL to a securely created randomized temporary file with owner-only permissions. - Invoke Wrangler through an argument-array process API without an intermediate shell. - Apply allowlist validation appropriate to each field: - Parse and normalize dates using a date library. - Validate registration URLs against an explicit URL scheme policy. - Reject control characters from textual fields. - Enforce reasonable field-length limits. - Prefer parameterized database operations if supported by the selected Cloudflare interface. - Keep credentials out of the generated SQL and avoid logging complete commands containing sensitive environment data. - Add adversarial tests covering quotes, double quotes, backticks, command substitution syntax, newlines, and malformed CSV fields. ]]>

T08 · Insecure Dependencies

Warning
Location
SKILL.md:46
Finding
Unpinned Wrangler Dependency May Execute Mutable Third-Party Code<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 46-49 **Vulnerability Type**: Unpinned runtime dependency and unsafe package resolution **Risk Level**: Medium ### Vulnerable Code ```bash CLOUDFLARE_API_TOKEN="$CF_API_TOKEN" \ CLOUDFLARE_ACCOUNT_ID="$CF_ACCOUNT_ID" \ npx wrangler d1 execute mb-events --remote \ --command "INSERT INTO events (name, address, date_start, date_end, location, rsvp_contact, rsvp_to, register_url, tags) VALUES ('...', ...);" ``` The same unpinned `npx wrangler` invocation is also used for bulk insertion and verification elsewhere in the file. ### Technical Analysis The project contains only `SKILL.md`; it does not include a package manifest or lockfile that pins Wrangler to a reviewed version. Invoking `npx wrangler` can resolve or download executable package code at runtime when an appropriate local installation is unavailable. As a result, the code that runs is not fully determined by the audited Skill artifact. Its behavior may change according to the package registry, local package-resolution state, cached packages, or future dependency releases. Third-party CLI and dependency code executes while Cloudflare credentials are explicitly present in the command environment. Although the documented package name is the legitimate `wrangler` package and no deliberate malicious dependency is shown, runtime retrieval without a locked version creates avoidable supply-chain exposure. ### Attack Path 1. The Skill invokes `npx wrangler` on a system where a verified local Wrangler binary is unavailable. 2. `npx` resolves or retrieves the package and its dependencies at runtime. 3. A compromised package release, transitive dependency, registry response, or unsafe local resolution supplies altered executable code. 4. The retrieved code executes under the Agent user's account. 5. The process receives `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in its environment. 6. Malicious dependency code can access those ...[truncated 550 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Add an explicit package manifest and lockfile that pin a reviewed Wrangler version and all transitive dependencies. - Install dependencies through a frozen-lockfile or reproducible installation workflow. - Invoke a verified local binary, such as `./node_modules/.bin/wrangler`, rather than permitting `npx` to retrieve packages at runtime. - Disable automatic runtime installation and fail closed when the expected binary is absent. - Verify package integrity and review dependency changes before updating the lockfile. - Run Wrangler in a restricted environment with access only to the required repository files and narrowly scoped Cloudflare credentials. - Avoid exposing credentials to package installation or lifecycle-script processes. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:41
Finding
Broad Credential File Is Executed Instead of Minimally Scoped Credentials Being Loaded<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 41-42 **Vulnerability Type**: Overbroad credential access and execution of a shared environment file **Risk Level**: High Additional occurrences are present at lines 60-61. The credential path and expected variables are also declared at line 15. ### Vulnerable Code ```bash ### 1. Load credentials ```bash source ~/.env/.env # Provides: $CF_API_TOKEN, $CF_ACCOUNT_ID ``` ``` The file is sourced again before remote execution: ```bash source ~/.env/.env cd /Users/viki/Projects/projects/marketing-bull/babenchuk-com ``` ### Technical Analysis The `source` shell builtin does not parse the target as a passive environment-data file. It executes every shell statement in the file within the current shell context. It also imports all variables and functions defined there rather than limiting access to the two values required by the task. The Skill declares that the shared file contains or provides `CF_API_TOKEN`, `CF_ACCOUNT_ID`, and `CF_ZONE_BABENCHUK_COM`, while the documented database commands only require the token and account ID. The zone variable is not used. A shared `~/.env/.env` file may also contain unrelated credentials not identified by this project. This behavior therefore exceeds minimum privilege: the declared function only needs narrowly scoped authorization to operate on one D1 database, but the instructions execute an entire general-purpose credential file. The risk is amplified by the command-injection and runtime-dependency findings because injected or third-party code can run in the credential-bearing context. ### Attack Path 1. The Agent executes `source ~/.env/.env` as instructed. 2. Every shell command in that file runs with the Agent user's privileges. 3. All variables defined by the file become available in the current shell, including potentially unrelated secrets. 4. Wrangler and any other subsequently invoked or injected process execute in or near this credential-b ...[truncated 812 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Replace the shared `~/.env/.env` file with a dedicated configuration containing only the values required for this Skill. - Do not use `source` to load credential files. Parse an explicitly defined data format without executing its contents. - Restrict file permissions to the owning user and prevent modification by less-trusted users or processes. - Use a Cloudflare token scoped to: - The intended Cloudflare account. - The required D1 database or narrowest available resource scope. - Only the read and write operations necessary to manage events. - Do not load the unused `CF_ZONE_BABENCHUK_COM` value. - Load credentials only for the individual Wrangler process rather than exporting them into a broad interactive shell context. - Separate read-only verification credentials from write credentials where operationally feasible. - Require explicit confirmation for destructive operations such as deleting or broadly updating records. - Rotate the current token if it has previously been exposed to untrusted generated commands or runtime-installed dependencies. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (12)

Credential Access

High
Category
Privilege Escalation
Content
### 1. Load credentials
```bash
source ~/.env/.env
# Provides: $CF_API_TOKEN, $CF_ACCOUNT_ID
```
Confidence
94% confidence
Finding
The skill instructs the agent/operator to source `~/.env/.env`, directly accessing stored Cloudflare credentials. Exposing credential-loading steps inside an agent skill is dangerous because any misuse of the skill, prompt injection into downstream content, or accidental logging can lead to token disclosure and full remote access to production infrastructure.

Credential Access

High
Category
Privilege Escalation
Content
### 3. Execute against D1 (remote)
```bash
source ~/.env/.env
cd /Users/viki/Projects/projects/marketing-bull/babenchuk-com

CLOUDFLARE_API_TOKEN="$CF_API_TOKEN" \
Confidence
96% confidence
Finding
This step combines loading credentials from a local env file with immediate remote execution against Cloudflare D1. The context makes the issue more dangerous because the token is used in a production write path, so any compromise of the shell session, package toolchain, or injected command content can result in unauthorized database modification and credential theft.

Credential Access

High
Category
Privilege Escalation
Content
**List all upcoming events:**
```bash
source ~/.env/.env
CLOUDFLARE_API_TOKEN="$CF_API_TOKEN" CLOUDFLARE_ACCOUNT_ID="$CF_ACCOUNT_ID" \
npx wrangler d1 execute mb-events --remote --command "SELECT id, name, date_start FROM events WHERE date_start >= date('now') ORDER BY date_start ASC;"
```
Confidence
92% confidence
Finding
Although this example is read-oriented, it still instructs loading Cloudflare credentials from a local env file into a general shell session. That broadens secret exposure unnecessarily and can leak tokens through shell history, debugging, process inspection, or compromised helper tooling.

Vague Triggers

Medium
Confidence
87% confidence
Finding
The trigger phrase "Add an event to the site" is broad enough to match ordinary conversational requests that may not imply authorization to write directly to a live database. In this skill, activation leads to immediate production D1 modification, so ambiguous triggering increases the risk of unintended or socially engineered execution.

Vague Triggers

Medium
Confidence
86% confidence
Finding
The phrase "Update PI events" does not specify the system, data source, or whether the request is read-only or mutating. Because this skill performs live writes to Cloudflare D1, the ambiguity makes accidental invocation and unauthorized modification more likely in normal conversation.

Session Persistence

Medium
Category
Rogue Agent
Content
## Schema
```sql
CREATE TABLE events (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT NOT NULL,
  address TEXT,
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.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding
The skill invokes `npx wrangler` without pinning a specific package version, which can cause execution of whatever version npm resolves at runtime. In a privileged workflow that loads Cloudflare credentials and performs remote D1 writes, this creates a supply-chain risk where a compromised or incompatible wrangler release could execute with access to live infrastructure.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding
This instance again uses unpinned `npx wrangler` for remote database operations. Because the command is run with Cloudflare API credentials in environment variables, any malicious or unexpected package version could abuse those credentials or alter production data.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The verification step still depends on unpinned `npx wrangler`, preserving the same supply-chain exposure. Even read-oriented commands can leak credentials, query sensitive data, or execute arbitrary package lifecycle behavior when the tool version is not fixed.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding
This query command uses unpinned `npx wrangler` while loading Cloudflare credentials from the user's environment. The combination of dynamic package fetching plus privileged remote access increases the chance of supply-chain compromise leading to credential theft or unauthorized D1 actions.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding
The delete example uses unpinned `npx wrangler` for a destructive production action. If the fetched package is malicious or unexpectedly changed, it can both tamper with live data and misuse loaded credentials, making this more dangerous than a generic tooling reference.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding
This update workflow again relies on a dynamically resolved `npx wrangler` binary in a credentialed, production-facing context. That exposes the operator to package substitution, compromised releases, or breaking changes that could modify data or exfiltrate Cloudflare tokens.

Static analysis

No suspicious patterns detected.