T09 · Insecure Skill Coding Practices
- Location
scripts/send_otc_email.sh:33- Finding
Arbitrary Python Code Execution Through Operation and Session Inputs
- Content
View full analysis
/dev/null || \ python3 -c "import sys; sys.exit(0 if any('\u4e00' <= c <= '\u9fff' for c in '''$OPERATION$SESSION''') else 1)" 2>/dev/null; then LANG_PREF="zh" else LANG_PREF="en" fi fi ``` ### Technical Analysis `OPERATION` and `SESSION` are caller-controlled arguments interpolated directly into source code passed to `python3 -c`. Enclosing the values in Python triple quotes does not safely escape triple quotes, backslashes, or other Python syntax present in the input. An attacker who can influence either argument can terminate the embedded string and introduce additional Python statements. The injected statements execute during language detection, before the one-time confirmation email is sent or verified. Shell quoting does not prevent this vulnerability because the shell first constructs one argument containing the attacker-influenced Python program, which the Python interpreter then evaluates as code. ### Attack Path 1. An attacker supplies or induces an Agent to process a malicious operation description or session identifier. 2. The Agent invokes `send_otc_email.sh` with that text and leaves the language preference at its default value of `auto`. 3. The malicious value closes the Python triple-quoted string and appends Python statements. 4. `python3 -c` parses and executes the injected statements. 5. The injected code runs with the same operating-system identity, environment variables, filesystem permissions, and network access as the Agent process. ### Impact Assessment Successful exploitation provides arbitrary local code execution under the Agent's account. Depending on the Agent's privileges, this may exp ...[truncated 317 chars]- Remediation
View remediation
