Back to skill

Security audit

React Component Generator

Security checks for vulnerabilities and agentic risk

Overview

This is a simple React component generator, but it needs review because its shell script can overwrite files based on an unvalidated component name and the documentation overstates what it supports.

Install only if you are comfortable auditing or fixing the script first. At minimum, restrict component names to valid React identifiers, write only inside a chosen output directory, refuse accidental overwrites, and update the documentation so it matches the actual supported output.

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

T09 · Insecure Skill Coding Practices

Error
Location
react-component-generator.sh:2
Finding
Command Injection and Unrestricted File Overwrite Through Component Name## Vulnerability Details **File Location**: `react-component-generator.sh`, lines 2-14 **Vulnerability Type**: Shell command injection through dynamically constructed `sed` program and unrestricted output path **Risk Level**: High ```bash NAME="${1:-MyComponent}" TYPE="${2:-function}" cat > "$NAME.jsx" << 'JSX' export default function COMP_NAME(props) { return ( <div> <h1>COMP_NAME</h1> </div> ); } JSX sed -i "s/COMP_NAME/$NAME/g" "$NAME.jsx" ``` ### Technical Analysis The first positional argument is accepted as `NAME` without validation. Although the shell variables are quoted, quoting only prevents shell word splitting and pathname expansion. It does not make attacker-controlled data safe when that data is inserted into the source code of another interpreter. At line 14, `NAME` is embedded directly into a `sed` substitution expression: ```bash sed -i "s/COMP_NAME/$NAME/g" "$NAME.jsx" ``` Characters meaningful to `sed`, including the `/` delimiter, command separators, backslashes, newlines, and GNU `sed` flags such as `e`, can change the meaning of the generated program. Under GNU `sed`, a crafted replacement expression can reach the `e` functionality, which evaluates generated text through a shell. Successful exploitation may require constructing a matching path or directory because the same malicious value is also used as the output filename, but the script imposes no restriction preventing that setup. The same input is also used directly as a filesystem path in both the redirection and the `sed -i` target. Absolute paths, path separators, and traversal sequences such as `../` are accepted. Consequently, the script can create or truncate a writable file outside the expected working directory, provided its final path ends in `.jsx`. Existing files are overwritten without confirmation. The unused `TYPE` variable does not mitigate either issue. ### A ...[truncated 1675 chars]
Remediation
## Remediation Suggestions 1. Validate the component name before using it. Restrict it to a React-compatible identifier, for example: ```bash if [[ ! "$NAME" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then printf 'Error: invalid component name\n' >&2 exit 1 fi ``` 2. Explicitly reject path separators, traversal components, control characters, and `sed` metacharacters. A strict allowlist is preferable to trying to escape every dangerous character. 3. Write generated files only beneath a designated output directory. Resolve and verify the final path before writing to ensure it remains within that directory. 4. Refuse to overwrite existing files unless the caller explicitly supplies a trusted overwrite option: ```bash output="${OUTPUT_DIR}/${NAME}.jsx" if [[ -e "$output" ]]; then printf 'Error: output file already exists\n' >&2 exit 1 fi ``` 5. Avoid constructing executable `sed` source from user input. After strict identifier validation, generate the component directly with a here-document: ```bash cat > "$output" <<JSX export default function ${NAME}(props) { return ( <div> <h1>${NAME}</h1> </div> ); } JSX ``` 6. Run the generator with least privilege, particularly in CI or build environments, and add tests covering traversal strings, delimiters, newlines, shell syntax, and attempts to overwrite existing files.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (4)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared description promises a broader React component generator supporting multiple component styles and TypeScript. The supplied code only creates one simple .jsx function component template and does not implement class components, hooks variants, or TypeScript. Although generating a React component template is aligned at a high level, the claimed feature set is materially overstated, so the description does not accurately represent the actual behavior.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The natural-language content describing the skill's purpose and features is presented only in Chinese, which can impose a language requirement on users without opt-in. The policy allows language constraints only when the skill offers a choice or clearly documents a justified locale-specific scope, neither of which is present here.

Vague Triggers

Medium
Confidence
88% confidence
Finding
The description '生成 React 组件' is very broad and does not clearly constrain the situations in which the skill should be invoked. Overly broad metadata can cause the agent to select this skill in unintended frontend-related contexts, increasing the chance of inappropriate code generation or workflow interference, though it does not directly enable code execution or privilege escalation.

Natural-Language Policy Violations

Low
Confidence
72% confidence
Finding
The only user-facing description is written in Chinese, which may impose a language expectation without indicating that users can choose another language. The policy calls for flagging language or locale constraints unless they are optional or clearly justified.

Static analysis

No suspicious patterns detected.