T09 · Insecure Skill Coding Practices
Warning
- Location
- .gitignore:1
- Finding
- GitHub token file is not excluded from version control## Vulnerability Details **File Location**: `.gitignore:1` **Vulnerability Type**: Sensitive credential exposure through insecure repository configuration **Risk Level**: Medium ### Vulnerable Code The complete `.gitignore` file contains only: ```gitignore /.idea/ ``` However, `README.md:61-73` instructs users to create a root `.env` file containing a GitHub token: ```text Token 只用于 GitHub API 认证。脚本会优先读取进程环境变量 `GITHUB_TOKEN`,然后读取当前工作目录或 skill 目录下的 `.env` 文件。 Copy-Item .env.example .env 编辑 `.env`: GITHUB_TOKEN=ghp_your_token_here 不要把真实 token 提交到 Git。`.env` 应加入 `.gitignore`。 ``` ### Technical Analysis The documented setup process creates `.env` in the project root and stores `GITHUB_TOKEN` there. The implementation then reads that file in `scripts/github_discovery.py:59-63`. Despite the documentation stating that `.env` should be ignored, the distributed `.gitignore` does not exclude it. Consequently, ordinary commands such as `git add .` can stage the credential file without warning. Git history is durable and may remain accessible even after the file is removed from a later commit. This is an insecure secret-management configuration rather than intentional exfiltration. The script transmits the token only as a Bearer authorization header to the fixed HTTPS endpoint `https://api.github.com`. That network use is disclosed and necessary for authenticated GitHub API access; the vulnerability is the risk of committing the local token. ### Attack Path 1. A user follows the README and copies `.env.example` to `.env`. 2. The user places a valid GitHub personal access token in `GITHUB_TOKEN`. 3. Because `.env` is not ignored, the user runs a routine command such as `git add .` and commits or pushes the file. 4. A collaborator, fork owner, repository visitor, CI artifact consumer, or source-history scanner obtains the token. 5. The recipient authenticates to GitHub using the exposed token until it expires ...[truncated 966 chars]
- Remediation
- ## Remediation Suggestions 1. Update `.gitignore` to exclude local environment files while retaining the example: ```gitignore /.idea/ /.env /.env.* !/.env.example ``` 2. Prefer process environment variables or an operating-system credential store over plaintext project-local token files. 3. Keep the recommendation for a fine-grained, read-only public-repository token and explicitly warn users not to supply broader scopes. 4. Add automated secret scanning or a pre-commit rule that rejects GitHub token patterns. 5. Add a regression test confirming that `.env` is ignored. 6. If a real token has ever been committed, revoke or rotate it immediately and remove it from repository history where appropriate; history rewriting does not replace revocation.
