T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/setup.sh:95
- Finding
- GitHub Authentication Token Exposed Through Credential-Bearing Clone URL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.sh:95-99` **Vulnerability Type**: GitHub token exposure through process arguments and Git remote configuration **Risk Level**: High ### Vulnerable Code ```bash GH_TOKEN=$(gh auth token) REPO_URL=$(echo "$VAULT_REPO" | sed "s|https://|https://${GH_TOKEN}@|") VAULT_DIR="/tmp/avenger-setup-$$" git clone --quiet "$REPO_URL" "$VAULT_DIR" cd "$VAULT_DIR" ``` ### Technical Analysis The setup script retrieves the authenticated user's GitHub token and embeds it directly into an HTTPS clone URL. This exposes the credential in several locations: - The command-line arguments of the active `git clone` process. - Process-monitoring, tracing, audit, and diagnostic output. - The cloned repository's `.git/config`, where Git commonly records the credential-bearing origin URL. - A residual temporary directory if the script terminates before its explicit cleanup step. The script uses `set -euo pipefail` but does not register an `EXIT` trap. Consequently, any error after cloning can leave `/tmp/avenger-setup-<PID>` and its credential-bearing Git configuration on disk. This behavior also conflicts with the project's security statement that the GitHub token is used through the GitHub CLI and is never stored by the Skill. ### Attack Path 1. A local attacker monitors process arguments while setup is running, or waits for setup to fail after cloning. 2. The attacker reads the token from the process command line or from `/tmp/avenger-setup-<PID>/.git/config`. 3. The attacker submits the recovered token to GitHub. 4. GitHub resources accessible under the token's scopes can then be enumerated, read, or modified. ### Impact Assessment An attacker may obtain the privileges granted to the user's GitHub CLI token. Depending on its scopes, this can include: - Reading private repositories. - Modifying or deleting repository content. - Injecting malicious content into backup vaults. - Accessing other organization or a ...[truncated 206 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not retrieve or interpolate the GitHub token into a URL. - Use the GitHub CLI authentication layer directly: ```bash VAULT_DIR=$(mktemp -d) trap 'rm -rf -- "$VAULT_DIR"' EXIT gh repo clone "$VAULT_REPO" "$VAULT_DIR" -- --quiet ``` - Set `umask 077` before creating temporary files or directories. - Use `mktemp -d` rather than a predictable PID-based path. - Register cleanup immediately after temporary directory creation. - Review logs and residual temporary directories for previously exposed credentials. - Revoke and rotate any token that may already have been exposed. ]]>
