T09 · Insecure Skill Coding Practices
- Location
SKILL.md:35- Finding
Shell Command Injection Through Unquoted Trading Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 35–42
Vulnerability Type: Command injection through unsafe shell command construction
Risk Level: HighVulnerable Code
text python "{{KIS_TRADE_SCRIPT_PATH}}" price {{symbol}} ### execute_order 주식을 매수하거나 매도합니다. **반드시 사전에 사용자의 확답을 받으세요.** - `symbol` (string): 종목코드 - `qty` (number): 수량 - `price` (number): 주문 가격 - `side` (string): 'BUY' 또는 'SELL' **Command:** python "{{KIS_TRADE_SCRIPT_PATH}}" order {{symbol}} {{qty}} {{price}} {{side}}Technical Analysis
The
symbol,qty,price, andsideparameters are interpolated directly into command templates without shell-safe quoting. Although the documentation describes expected types and values, it does not define or enforce validation constraints.If the tool runner executes these templates through a shell, shell metacharacters contained in a parameter will be interpreted as command syntax rather than as a single argument. For example, a malicious
symbolcontaining a command separator could terminate the intended argument and append another operating-system command.Quoting
KIS_TRADE_SCRIPT_PATHdoes not protect the other interpolated parameters. The requirement to obtain user confirmation before an order also does not prevent injection through price lookups or through malicious values included in an approved order.Attack Path
- An attacker causes crafted text to be supplied as
symbol,qty,price, orside, directly or through untrusted content processed by the Agent. - The value includes shell syntax, such as a command separator followed by an operating-system command.
- The value is substituted directly into the documented command template.
- A shell-backed tool runner parses the injected syntax.
- The intended Python invocation runs, fails, or is bypassed, while the appended attacker-controlled command executes with the privileges of the Agent process.
A representative malicious
symbolwould ha ...[truncated 1054 chars]- An attacker causes crafted text to be supplied as
- Remediation
View remediation
Remediation Suggestions
- Do not execute interpolated command strings through a shell. Invoke Python with an argument-array API equivalent to:
text ["python", KIS_TRADE_SCRIPT_PATH, "order", symbol, qty, price, side]-
Apply strict allowlist validation before invocation:
- Require
symbolto match^[0-9]{6}$. - Require
qtyto be a positive integer within an explicitly configured maximum. - Require
priceto be a positive numeric value within appropriate market and account limits. - Require
sideto equal exactlyBUYorSELL. - Reject unexpected whitespace, control characters, shell metacharacters, and extra arguments.
- Require
-
Resolve and validate
KIS_TRADE_SCRIPT_PATHagainst an administrator-controlled allowlisted path. Verify that it points to a regular file with trusted ownership and is not writable by untrusted users. -
Preserve the existing explicit confirmation requirement, but display and confirm the normalized symbol, side, quantity, price, and estimated order value. Bind approval to those exact values and invalidate it if any value changes.
-
Run the trading process with least privilege, restrict its filesystem and network access, and expose brokerage credentials only to the process that requires them.
-
Add negative tests using command separators, substitutions, redirects, newlines, and argument-injection payloads to verify that malformed values are rejected and never interpreted by a shell.
