T09 · Insecure Skill Coding Practices
- Location
SKILL.md:101- Finding
PowerShell Command Injection Through Unsafe Draft JSON Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 101
Vulnerability Type: PowerShell command injection
Risk Level: HighVulnerable Code:
powershell powershell -NoProfile -Command "$body = '<PASTE_DRAFT_JSON_HERE>'; irm -Method Post -Uri http://127.0.0.1:8000/order_confirm -ContentType 'application/json' -Body $body | ConvertTo-Json -Depth 50"Technical Analysis
The skill instructs the agent to paste the draft JSON directly into a single-quoted PowerShell string. The draft is derived from the local API response and may also incorporate user-supplied risk constraints. Because the JSON is embedded in executable PowerShell source without context-aware escaping, an apostrophe in a JSON value can terminate the string literal. Additional text can then be interpreted as PowerShell commands.
Binding the API to
127.0.0.1does not eliminate this risk. A malicious or compromised local service, or another process able to spoof the expected API, could return a crafted draft. The required user confirmation reduces automatic execution risk but does not neutralize the injection: the payload is executed when a user confirms an apparently valid displayed order.Attack Path
- An attacker compromises, replaces, or impersonates the service listening on
127.0.0.1:8000, or otherwise influences the draft data. - The
/order_draftendpoint returns syntactically plausible JSON containing an apostrophe followed by malicious PowerShell syntax in a field value. - The agent displays the draft and asks the user for the required exact confirmation.
- The user replies
CONFIRM ORDER, believing that only the displayed order will be submitted. - The agent substitutes the crafted JSON into the line 101 command.
- The apostrophe terminates the intended string, and PowerShell interprets the injected content as commands.
- Those commands execute with the privileges of the process running the agent.
Impa
...[truncated 485 chars]
- An attacker compromises, replaces, or impersonates the service listening on
- Remediation
View remediation
Remediation Suggestions
- Do not interpolate API responses or user-controlled data into PowerShell program text.
- Pass the JSON as data through a securely created temporary file, standard input, or a separately bound process argument.
- If transport through command text is unavoidable, encode the exact UTF-8 JSON outside the PowerShell source, pass only a strictly validated Base64 value, and decode it as data inside PowerShell.
- Parse and validate the draft against a strict schema. Reject unknown properties, unexpected data types, invalid symbols, and values outside permitted ranges.
- Canonically serialize the validated object immediately before submission rather than copying displayed text into a command.
- Cryptographically bind confirmation to the exact reviewed draft, such as by displaying and retaining a digest or server-issued single-use identifier, and verify that the submitted payload exactly matches it.
- Authenticate the local API and verify that the expected service owns the endpoint; do not treat localhost alone as a trust boundary.
- Run the agent and trading client with the minimum filesystem, credential, process, and network permissions required.
