T09 · Insecure Skill Coding Practices
- Location
SKILL.md:19- Finding
GitCode Access Token Retrieved from Persistent Memory and Exposed in Command-Line URLs
- Content
View full analysis
| gitcode auth login --with-token ``` ``` `SKILL.md:69-73`: ```markdown 2. If not authenticated, **prompt the user to run `gitcode auth login`** and stop the workflow 3. If the user prefers not to use the CLI for authentication, fall back to the GitCode API with an explicit token: ```bash curl -s "https://api.gitcode.com/api/v5/repos///issues/?access_token=" curl -s "https://api.gitcode.com/api/v5/repos///issues//comments?access_token=" ``` ``` `SKILL.md:351-353`: ```markdown ```bash curl -s -X POST "https://api.gitcode.com/api/v5/repos///pulls?access_token=" \ -H "Content-Type: application/json" \ ``` `references/gitcode-api.md:9-17`: ```markdown ## Authentication All requests require `access_token` as a query parameter: ``` ?access_token= ``` Token stored in MEMORY.md or provided by user at runtime. ``` `references/gitcode-api.md:50-52`: ```markdown ### Create Pull Request ``` POST /repos/{owner}/{repo}/pulls?access_token= ``` ``` `references/gitcode-api.md:81-83`: ```markdown ```bash curl -s -X POST "https://api.gitcode.com/api/v5/repos/Ascend/msinsight/pulls?access_token=" \ -H "Content-Type: application/json" \ -d @payload.json ``` ### Technical Analysis The Skill directs the Agent to obtain a GitCode ...[truncated 3236 chars]- Remediation
View remediation
` with an authorization header where the API supports it: ```bash curl --fail-with-body --silent --show-error \ -H "Authorization: Bearer ${GITCODE_TOKEN}" \ "https://api.gitcode.com/api/v5/repos///issues/" ``` - Apply the same change to issue comments and pull-request creation requests. - If a particular endpoint only supports query authentication, prefer the authenticated CLI. Clearly warn the user about URL logging and avoid displaying or retaining the generated command. 3. **Protect runtime secret handling** - Supply secrets through a protected environment or secret-injection mechanism rather than interpolating literal values into instructions. - Never print tokens in Agent responses, command previews, errors, design documents, payload files, or logs. - Avoid `echo ` examples containing literal credentials. Use an interactive prompt or secure standard-input mechanism that does not retain the value in history. - Ensure diagnostic output and execution telemetry redact `access_token`, `Authorization`, and equivalent fields. 4. **Enforce least privilege** - Document the minimum GitCode token scopes needed for issue reads, personal-fork pushes, and PR creation. - Use separate narrowly scoped credentials if read and write operations cannot be safely covered by one minimal token. - Do not require organization or upstream-repository write permission for a fork-based contribution workflow. 5. **Limit credential lifetime** ...[truncated 283 chars]
