T09 · Insecure Skill Coding Practices
- Location
scripts/upgrade-plugin.sh:124- Finding
JavaScript Injection Through the Plugin Identifier
- Content
View full analysis
/dev/null || true)" ``` ### Technical Analysis `PLUGIN_ID` is supplied as a positional command-line argument and is interpolated directly into JavaScript source passed to `node -e`. Shell quoting does not protect the JavaScript string itself. An attacker-controlled plugin identifier containing quotes and JavaScript syntax can terminate the property-access expression and introduce arbitrary Node.js instructions. Node.js exposes operating-system APIs such as `child_process`, so successful JavaScript injection can be converted directly into arbitrary shell command execution. The surrounding `try/catch` does not prevent exploitation; it only suppresses errors produced while the injected program is evaluated. `CONFIG_FILE` is interpolated into the same JavaScript source and could present a similar problem if an attacker can influence the discovered configuration path. ### Attack Path 1. An attacker convinces the Agent or user to invoke the generic installer with a crafted `plugin-id`. 2. The script accepts the identifier without syntax validation. 3. The identifier is inserted into the program supplied to `node -e`. 4. The crafted value terminates the intended JavaScript string or expression and injects additional JavaScript. 5. The injected JavaScript imports `child_process` or uses another Node.js execution primitive. 6. Arbitrary operating-system commands execute with the privileges of the account running the Skill. ### Impact Assessment Successful exploitation provid ...[truncated 403 chars]- Remediation
View remediation
/dev/null || true)" ``` Additionally: 1. Validate `PLUGIN_ID` before using it. If plugin IDs are intended to be directory names, enforce a narrow allowlist such as `^[A-Za-z0-9._-]+$`. 2. Reject empty identifiers, path separators, control characters, quotes, and traversal components. 3. Apply the same argument-passing design to every `node -e` invocation involving dynamic paths. 4. Add tests using identifiers containing quotes, newlines, semicolons, backticks, and JavaScript syntax. ]]>
