T09 · Insecure Skill Coding Practices
- Location
setup.sh:55- Finding
Installation Path Injection Enables Arbitrary Code Execution
- Content
View full analysis
"$BIN_DIR/$SERVICE_NAME" << WRAPPER #!/usr/bin/env bash exec python3 "$SKILL_DIR/nex-keyring.py" "\$@" WRAPPER ``` ### Technical Analysis `SKILL_DIR` is derived from the directory containing `setup.sh`. The script directly interpolates this filesystem path into Python source code passed to `python -c`. A directory name containing a single quote can terminate the Python string supplied to `sys.path.insert`, after which additional Python statements can be injected. Shell quoting around the overall `-c` argument does not protect the generated Python source from syntax injection. The path is also inserted into a generated shell script through an expanding heredoc. If the installation path contains shell syntax such as command substitutions, quotes, or newlines, that syntax can become active when the generated `~/.local/bin/nex-keyring` wrapper is later executed. This is an exploitable coding flaw rather than intentional embedded malicious behavior. Exploitation requires influence over the path from which the user runs the setup script. ### Attack Path 1. An attacker distributes or places the project under a directory whose name contains crafted Python or shell syntax. 2. The user follows the documented installation instructions and runs `bash setup.sh`. 3. During database initialization, the crafted `SKILL_DIR` is inserted into the source passed to `python -c`. 4. A si ...[truncated 1012 chars]- Remediation
View remediation
