T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:26
- Finding
- PowerShell Command Injection Through Unescaped Parameter Interpolation<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 26-28 **Vulnerability Type**: PowerShell command injection **Risk Level**: Critical ### Vulnerable Code ```powershell $scanDir = "<scanDir>" $oldUrl = "<oldUrl>" $newUrl = "<newUrl>" ``` ### Technical Analysis The Skill instructs the agent to replace these placeholders directly with user-provided values before executing the PowerShell script. The values are inserted into double-quoted PowerShell string literals without escaping or validation. An attacker-controlled value can contain a double quote to terminate the intended string, followed by arbitrary PowerShell statements. Because the resulting content is treated as PowerShell source code, the injected statements execute with the privileges of the user or agent running the generated script. All three parameters—`scanDir`, `oldUrl`, and `newUrl`—are affected. Merely validating that a value resembles a path or URL is insufficient unless validation is strict and values are passed separately from executable source code. ### Attack Path 1. The Skill asks the user for a scan directory, old URL, and new URL. 2. An attacker supplies a value containing a closing quote and additional PowerShell syntax. 3. The agent substitutes the value directly into one of the assignments. 4. The user or agent executes the generated PowerShell script. 5. PowerShell parses the injected content as commands. 6. The attacker's commands run with the privileges of the process executing the script. ### Impact Assessment Successful exploitation provides arbitrary command execution under the current user's security context. Depending on that user's privileges, an attacker could read or modify files, access credentials available to the process, alter repositories beyond the requested scope, install software, or establish persistence. The Skill does not itself obtain elevated privileges, but exploitation inherits all permissions already held by the invoking process. ...[truncated 4 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not create executable PowerShell source by textually replacing placeholders. - Implement the script with a parameter block and pass values as arguments: ```powershell param( [Parameter(Mandatory = $true)] [string]$ScanDir, [Parameter(Mandatory = $true)] [string]$OldUrl, [Parameter(Mandatory = $true)] [string]$NewUrl ) ``` - Invoke the saved script using separately bound arguments rather than embedding values into its source. - Validate that `ScanDir` resolves to an explicitly approved directory. - Validate URLs using an appropriate URI parser and an allowlist of accepted schemes. - Reject control characters, including carriage returns, line feeds, and null bytes. - Display the resolved directory and proposed changes and obtain confirmation before modifying repositories. - Run with the minimum privileges required and avoid administrator execution. ]]>
