T09 · Insecure Skill Coding Practices
- Location
references/cashier-payment.md:191- Finding
Shell Command Injection Through an Insufficiently Validated Payment URL
- Content
View full analysis
Vulnerability Details
File Location:
references/cashier-payment.md:191-206
Vulnerability Type: Shell command injection through user-controlled URL interpolation
Risk Level: HighVulnerable Code
bash AIPAY_SESSION_ID=<sessionId> AIPAY_FRAMEWORK=openclaw alipay-bot submit-payment --payment-link '<cashier-payment-link>' --session-id <sessionId>The preceding validation requires an existing HTTPS URL, an Alipay cashier hostname, a path, and complete query parameters. It does not explicitly reject embedded single quotes, control characters, shell operators, or other characters capable of escaping the shell argument.
Technical Analysis
The payment link originates from the conversation context and is inserted directly into a shell command. Although the value is surrounded by single quotes, single-quote wrapping is not safe when the input itself may contain a single quote.
An attacker can supply a crafted value that begins like an accepted Alipay cashier URL but contains a single quote followed by shell syntax. If validation is implemented as the documented prefix and hostname checks rather than strict URL parsing and argument-safe process execution, the quote closes the intended argument and the remaining text is interpreted by the shell.
Domain validation alone does not prevent this issue. The input must either be passed directly as a process argument without invoking a shell or be subjected to strict URL parsing and robust shell escaping.
Attack Path
- An attacker supplies a payment link that appears to use an allowed Alipay cashier hostname.
- The crafted link includes a single quote and shell operators after the hostname or path.
- The documented validation accepts the value because it starts with HTTPS and contains an expected cashier hostname.
- The Skill substitutes the value into the single-quoted
--payment-linkargument. - The embedded quote terminates the ...[truncated 826 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct a shell command string. Invoke
alipay-botthrough a process API that accepts an argument array, passing the payment URL as one literal argument. - Parse the URL with a standards-compliant URL parser and reject parsing failures.
- Require the
httpsscheme and compare the normalized hostname against an explicit allowlist or a suffix rule with a dot-boundary check. - Reject user-info components, control characters, whitespace, quotes, backticks, line breaks, and shell metacharacters.
- Do not rely on manual single-quote wrapping. If shell execution is unavoidable, use a proven escaping library independently for every dynamic argument.
- Add tests covering embedded quotes, semicolons, command substitutions, newlines, encoded delimiters, malformed hostnames, and deceptive hostname suffixes.
- Run the payment process under a dedicated least-privileged account with restricted filesystem and network access.
- Do not construct a shell command string. Invoke
