T09 · Insecure Skill Coding Practices
- Location
setup.js:30- Finding
Shell Command Injection Through YUKETANG_SECRET
- Content
View full analysis
Vulnerability Details
File Location:
setup.js, lines 30-39
Vulnerability Type: OS command injection through unsafe shell-string construction
Risk Level: HighVulnerable Code
javascript const authorization = `Bearer ${secret}`; let registered = false; try { execSync( `npx mcporter@0.8.1 config add yuketang-mcp --url "${MCP_URL}" --header "Authorization=${authorization}" --scope project`, { stdio: "inherit" } );Technical Analysis
The script reads
YUKETANG_SECRETfrom the environment and directly interpolates it into a command string passed tochild_process.execSync. Unlike argument-based process APIs,execSyncexecutes the supplied string through a shell.The double quotes surrounding the header do not make this safe. A crafted environment variable can contain quote characters, command substitutions, or other shell syntax that terminates or alters the intended argument. The shell can consequently interpret attacker-controlled content as commands.
This vulnerability is reachable whenever a user runs
node setup.jswith an untrusted or attacker-supplied Secret value.Attack Path
- An attacker supplies or recommends a specially crafted value as the user's Rain Classroom Secret.
- The user assigns that value to
YUKETANG_SECRET. - The user executes
node setup.jsas instructed by the Skill documentation. setup.jsembeds the value into the command string passed toexecSync.- The operating-system shell evaluates the injected shell syntax.
- Attacker-selected commands execute with the privileges of the user running the installer.
Impact Assessment
Successful exploitation provides arbitrary command execution under the current user's account. The attacker could read or alter files available to that user, steal environment variables and credentials, modify project configuration, install persistence within user-writable locations, or invok ...[truncated 129 chars]
- Remediation
View remediation
Remediation Suggestions
Replace shell-string execution with an argument-based API such as
execFileSyncorspawnSync, explicitly disabling shell processing:javascript const { execFileSync } = require("child_process"); execFileSync( "npx", [ "mcporter@0.8.1", "config", "add", "yuketang-mcp", "--url", MCP_URL, "--header", `Authorization=Bearer ${secret}`, "--scope", "project", ], { stdio: "inherit", shell: false, } );Additionally:
- Validate the Secret against its documented character set and expected length before use.
- Reject control characters, newlines, and unexpected whitespace.
- Do not attempt to secure this operation solely through manual quote escaping.
- Add automated tests using values containing quotes, command substitutions, semicolons, and newline characters.
- Avoid printing the Secret or the complete authorization header in errors or logs.
