T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:53
- Finding
- GitHub Token Exposure Through Authenticated Clone URL<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 53-64; related persistence guidance at line 153 **Vulnerability Type**: Credential exposure through command-line URL and Git configuration **Risk Level**: High ### Vulnerable Code ```bash if [ -d "$WORKDIR" ]; then cd "$WORKDIR" git fetch --all else mkdir -p "$(dirname "$WORKDIR")" # With token auth git clone "https://${GH_TOKEN}@github.com/${username}/${repo_name}.git" "$WORKDIR" # Or with SSH # git clone "git@github.com:${username}/${repo_name}.git" "$WORKDIR" cd "$WORKDIR" fi ``` The Skill also recommends long-term token persistence: ```markdown - Store GH_TOKEN in your shell profile for persistent auth across sessions. ``` ### Technical Analysis The clone command embeds `GH_TOKEN` directly in an HTTPS URL. Although the shell variable is quoted, its expanded value becomes part of the argument passed to Git. The credential may consequently be exposed through: - Process inspection while the command is running. - Agent, terminal, CI, or command-audit logs. - Git error and diagnostic output. - The repository's `.git/config`, because Git can retain the authenticated URL as the `origin` remote. - Shell configuration files if the recommendation to persist `GH_TOKEN` in a shell profile is followed. GitHub network access and authentication are necessary for private repository operations, but placing the raw token in a URL is not necessary. This behavior exceeds the minimum safe credential exposure required for the declared functionality. ### Attack Path 1. A user exports a GitHub token as `GH_TOKEN`. 2. The Skill expands the token into the `git clone` URL. 3. Git or the surrounding Agent environment records or exposes the resulting command or remote URL. 4. An attacker with access to process information, logs, terminal output, shell configuration, or the cloned repository's `.git/config` recovers the token. 5. The attacker uses the token against GitHub ...[truncated 705 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove token-in-URL authentication entirely. 2. Prefer GitHub CLI credential integration: ```bash gh auth status gh auth setup-git gh repo clone "${username}/${repo_name}" "$WORKDIR" ``` 3. Alternatively, use Git Credential Manager, an operating-system credential store, or SSH authentication. 4. Do not store `GH_TOKEN` in shell profiles. Use an ephemeral environment variable, credential helper, or secret manager only for the duration of the operation. 5. If environment-based authentication is unavoidable, ensure the token is never included in command arguments, URLs, logs, or remote configuration. 6. After cloning, verify that no credentials are present: ```bash git remote get-url origin git config --get remote.origin.url ``` 7. Recommend fine-grained, short-lived tokens restricted to the minimum repositories and permissions. 8. Revoke and rotate any token that may previously have been stored in logs, shell files, or `.git/config`. ]]>
