T09 · Insecure Skill Coding Practices
- Location
SKILL.md:91- Finding
Arbitrary JavaScript Execution Through Unsafe Campaign ID Substitution
- Content
View full analysis
{ ``` The complete command is executed as an inline, double-quoted `node -e` shell command. The instructions require replacing the placeholder inside a single-quoted JavaScript string with the activity ID supplied for the query. ### Technical Analysis The campaign ID is inserted directly into executable JavaScript source without escaping or validating it. Consequently, an attacker-controlled ID containing a single quote can terminate the `CAMPAIGN_ID` string literal. The attacker can then append arbitrary JavaScript statements that Node.js executes with the privileges of the process invoking the Skill. For example, a value structurally similar to the following could close the original string, execute attacker-selected Node.js code, and restore valid syntax: ```text '; ATTACKER_CONTROLLED_JAVASCRIPT; const placeholder=' ``` This is a source-code injection vulnerability rather than an API-level issue. JSON serialization inside `post()` does not mitigate it because execution occurs while Node.js parses the generated source, before the HTTP request is constructed. The risk is especially significant because Node.js provides direct access to the filesystem, environment variables, networking, and child-process APIs. ### Attack Path 1. An attacker asks the Agent to retrieve details for a maliciously crafted activity ID. 2. Following line 91, the Agent replaces the `CAMPAIGN_ID` placeholder in the inline command with the supplied value. 3. The malicious value terminates the JavaScript string literal at line 97 and introduces additional JavaScript statements. 4. The generated command is passe ...[truncated 1195 chars]- Remediation
View remediation
{ // Process the response. }); ``` 3. **Avoid shell-based execution** - Use an execution facility equivalent to `spawn` or `execFile` with separate arguments. - Do not construct commands through string concatenation. - Do not rely solely on quote escaping, as layered shell and JavaScript parsing makes escaping fragile. 4. **Reduce process privileges** - Run the Skill with the minimum filesystem, environment, process, and network permissions required for activity queries. - Do not expose unrelated credentials to the process. - Where supported, restrict outbound network access to the documented API host. ]]>
