Back to skill

Security audit

Serverless Template Generator

Security checks for vulnerabilities and agentic risk

Overview

The skill is not overtly malicious, but its generator is under-scoped and can overwrite files or run commands with crafted input, while its deployment guidance lacks safety checks.

Review this skill before installing or running it. Use it only in a disposable workspace, do not pass names or platform values from untrusted sources, inspect generated files before deploying, and manually confirm the active cloud account, site/project, environment, region, and billing impact before running any Vercel, Netlify, or Wrangler deploy command. Do not rely on the advertised AWS Lambda support without adding or verifying that implementation.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
serverless-template-generator.sh:83
Finding
Arbitrary Command Execution Through GNU sed Expression Injection<![CDATA[ ## Vulnerability Details **File Location**: `serverless-template-generator.sh:4, 64-84` **Vulnerability Type**: OS command injection through an attacker-controlled GNU sed expression **Risk Level**: High ### Vulnerable Code ```bash NAME="${1:-my-function}" ``` ```bash cloudflare) mkdir -p "$PLATFORM"/src cat > "$PLATFORM/src/index.js" << 'JS' export default { async fetch(request, env, ctx) { return new Response(JSON.stringify({ message: 'Hello from Cloudflare Workers!', platform: 'cloudflare' }), { headers: { 'content-type': 'application/json' } }); } }; JS cat > "$PLATFORM/wrangler.toml" << 'TOML' name = "WORKER_NAME" main = "src/index.js" compatibility_date = "2023-01-01" TOML sed -i "s/WORKER_NAME/$NAME/g" "$PLATFORM/wrangler.toml" ;; ``` ### Technical Analysis The first positional argument is assigned to `NAME` without validation and is inserted directly into a GNU sed substitution program: ```bash sed -i "s/WORKER_NAME/$NAME/g" "$PLATFORM/wrangler.toml" ``` Shell quoting prevents direct shell metacharacters in `NAME` from being interpreted by the invoking shell, but it does not make the resulting sed program safe. An attacker can inject the `/` delimiter, sed flags, additional commands, and comments. GNU sed supports the `e` substitution flag, which executes the substituted pattern-space contents as a shell command. For example, a name shaped like: ```text touch PWNED/e;# ``` produces a sed program equivalent to: ```sed s/WORKER_NAME/touch PWNED/e;#/g ``` The substitution produces `touch PWNED`, and the injected `e` flag asks GNU sed to execute it. The comment suppresses the remaining intended expression. More consequential commands can be supplied subject to sed delimiter handling. This vulnerability is reachable whenever the generator is invoked with the `cloudflare` platform and the attacker can control the project name. ### Attack Path 1. An attacker supplies a crafted fir ...[truncated 1636 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Enforce a strict allowlist for project names before using them: ```bash if [[ ! "$NAME" =~ ^[A-Za-z0-9][A-Za-z0-9_-]*$ ]]; then printf 'Error: invalid project name\n' >&2 exit 1 fi ``` 2. Avoid constructing a sed program from untrusted input. Use a mechanism that treats the replacement as data, such as passing the value to a small JSON/TOML-aware generator. 3. If sed must be retained, escape every character significant in a sed replacement, including the delimiter, backslash, and ampersand. Strict name validation should still be applied as defense in depth. 4. Generate the complete TOML file using a quoted template plus a validated value rather than creating a placeholder and subsequently replacing it. 5. Add regression tests using names containing `/`, `\`, `&`, semicolons, newlines, sed flags, and shell-command text. The script must reject all such names. 6. Run template generation with least privilege, especially in CI/CD environments, and do not expose generator arguments directly to untrusted users. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
serverless-template-generator.sh:23
Finding
Arbitrary File Overwrite and Generated-Content Injection Through Unvalidated Paths<![CDATA[ ## Vulnerability Details **File Location**: `serverless-template-generator.sh:4-5, 23-24, 45-46, 65-66, 88-100` **Vulnerability Type**: Path traversal, arbitrary file overwrite, and structured-content injection **Risk Level**: Medium ### Vulnerable Code ```bash NAME="${1:-my-function}" PLATFORM="${2:-vercel}" ``` ```bash vercel) mkdir -p "$PLATFORM"/api cat > "$PLATFORM/api/$NAME.js" << 'JS' ``` ```bash netlify) mkdir -p "$PLATFORM"/netlify/functions cat > "$PLATFORM/netlify/functions/$NAME.js" << 'JS' ``` ```bash cloudflare) mkdir -p "$PLATFORM"/src cat > "$PLATFORM/src/index.js" << 'JS' ``` ```bash # Generate package.json cat > "$PLATFORM/package.json" << JSON { "name": "$NAME-$PLATFORM", "version": "1.0.0", "scripts": { "dev": "$PLATFORM dev", "deploy": "$PLATFORM deploy --prod" } } JSON # Generate README cat > "$PLATFORM/README.md" << README # $NAME ``` ### Technical Analysis `NAME` and `PLATFORM` are used in filesystem paths without character validation, canonicalization, containment checks, or overwrite protection. For Vercel and Netlify, `NAME` forms part of a destination filename. Because `/` and `..` are accepted, a crafted name can traverse out of the intended function directory. The shell quotes preserve the argument as one word but do not neutralize filesystem path separators. The redirection operator truncates an existing target before writing the generated handler. `PLATFORM` is also used as the output directory after the `case` statement regardless of whether it matched a supported platform. If an attacker supplies the path of an existing directory, the `case` body performs no setup, but the unconditional `package.json` and `README.md` redirections can still overwrite files in that directory. The same variables are interpolated into unquoted heredocs used to generate JSON and Markdown. Quotes, backslashes, and newline characters in the arguments can corrupt or inject fields into ...[truncated 2599 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate `NAME` with a conservative allowlist that rejects path separators, traversal components, whitespace, control characters, quotes, and newlines: ```bash if [[ ! "$NAME" =~ ^[A-Za-z0-9][A-Za-z0-9_-]*$ ]]; then printf 'Error: invalid project name\n' >&2 exit 1 fi ``` 2. Allowlist supported platforms and terminate on every unsupported value: ```bash case "$PLATFORM" in vercel|netlify|cloudflare) ;; *) printf 'Error: unsupported platform\n' >&2 exit 1 ;; esac ``` 3. Introduce a dedicated output-root argument. Resolve the canonical destination and verify that every generated path remains beneath that root before writing. 4. Reject symbolic-link destinations and consider creating the output directory with restrictive permissions. Verify parent directories and files using operations resistant to symlink races when the script may run in an attacker-writable workspace. 5. Refuse to overwrite existing files by default. Require an explicit `--force` option and clearly list every file that would be replaced. 6. Use a JSON-aware tool or serializer to produce `package.json` so all string values are encoded correctly. 7. Generate Markdown and TOML only from validated values or escape those values for the relevant output format. 8. Enable strict shell behavior and explicit error handling: ```bash set -euo pipefail ``` 9. Add tests covering absolute paths, `../`, nested separators, symlinks, existing destination files, quotes, backslashes, and embedded newlines. ]]>
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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
Findings (6)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
代码的主要用途确实是生成 Serverless 脚手架,这一点与描述大体一致。但存在两个实质性偏差:第一,声明明确包含 AWS Lambda 支持,而实际 case 仅处理 vercel、netlify、cloudflare,完全没有 AWS Lambda 相关生成逻辑;第二,声明称支持“一键部署到云端”,但脚本并未调用任何云部署命令,也未自动安装依赖或触发部署,只是生成 package.json 和 README 并提示用户后续手动运行 npm run deploy。因此描述夸大了实际能力,属于描述与行为不完全一致的情况。

Lp3

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding
Without declared permissions the skill's intent is opaque and cannot be validated.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The skill advertises cloud deployment workflows without warning that running those commands can change remote infrastructure, publish code, and incur charges. In a serverless context, users may copy-paste commands into authenticated CLIs and unintentionally deploy to production or the wrong account.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The deployment section includes production-oriented commands such as 'netlify deploy --prod' and publish/deploy operations without any confirmation step or target verification guidance. This increases the risk of accidental modification of live environments, especially when users are already authenticated in a cloud CLI.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The manifest description is written entirely in Chinese ("生成 Serverless 脚手架") with no indication that the skill supports other languages or that it is intentionally limited to a Chinese-speaking audience. This can violate language/locale policy when a skill imposes a specific language without user choice or documented regional justification.

Natural-Language Policy Violations

Low
Confidence
84% confidence
Finding
SQP-3 applies to all file types and covers language/locale policy violations. The skill content consistently forces a specific language for user-facing documentation without opt-in or stating that the skill is intended only for a Chinese-speaking context.