T09 · Insecure Skill Coding Practices
- Location
installers/detect-shell.sh:3- Finding
Shell Command Injection Through Unescaped eval Output
- Content
View full analysis
set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" if command -v bash >/dev/null 2>&1 && [ "${OS:-}" != "Windows_NT" ] || [ -n "${WSL_DISTRO_NAME:-}" ]; then echo "export CHRONOS_SHELL=bash" echo "export CHRONOS_SETTINGS_FRAGMENT=$ROOT/installers/claude-code/settings.json" elif command -v pwsh >/dev/null 2>&1 || command -v powershell >/dev/null 2>&1; then echo "export CHRONOS_SHELL=powershell" echo "export CHRONOS_SETTINGS_FRAGMENT=$ROOT/installers/claude-code/settings.windows-ps.json" else echo "export CHRONOS_SHELL=bash" echo "export CHRONOS_SETTINGS_FRAGMENT=$ROOT/installers/claude-code/settings.json" fi ``` ### Technical Analysis The script explicitly recommends evaluating its output: ```bash eval "$(./installers/detect-shell.sh)" ``` It includes the repository path in generated shell assignments without shell escaping. Although `ROOT` is quoted while being calculated, its value is later embedded verbatim in a string that is intended to be parsed again by the shell. If the repository is located under a directory whose name contains shell metacharacters, command substitution, a semicolon, whitespace, or a newline, those characters can become active shell syntax during `eval`. Quoting at the time `ROOT` is calculated does not protect the value during this second parsing stage. ### Attack Path 1. An attacker supplies or recommends a repository archive or checkout located under a crafted directory name containing shell syntax. 2. The user follows the documented usage: ```bash ...[truncated 902 chars]- Remediation
View remediation
