T09 · Insecure Skill Coding Practices
- Location
scripts/search_recipe.py:29- Finding
Automatic Transmission of an Ambient GitHub Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search_recipe.py, lines 29-31
Vulnerability Type: Unnecessary credential exposure and violation of least privilege
Risk Level: MediumVulnerable Code
python # Add optional Github token if available in env to increase limits if os.environ.get('GITHUB_TOKEN'): req.add_header('Authorization', f"token {os.environ.get('GITHUB_TOKEN')}")Technical Analysis
The script automatically reads the ambient
GITHUB_TOKENenvironment variable and attaches it to a request sent tohttps://api.github.com. The declared recipe-search functionality only accesses a public repository and does not require authentication.Automatically consuming a general-purpose credential solely to increase rate limits exceeds the minimum privileges required by the Skill. The user is not asked to authorize use of the token, and the code does not verify that it is a dedicated, minimally scoped credential.
The request is sent over HTTPS to GitHub's official API, and no malicious exfiltration endpoint was identified. Nevertheless, the credential may become visible to trusted network intermediaries, debugging infrastructure, HTTP instrumentation, or a compromised certificate/proxy environment. Its effective exposure depends on the runtime's network configuration and the token's permissions.
Attack Path
- A user or hosting environment places a GitHub token in
GITHUB_TOKENfor an unrelated workflow. - The user invokes the recipe-search Skill.
- If the local cache is absent or older than 24 hours,
fetch_file_list()creates a GitHub API request. - The script silently reads the ambient token and inserts it into the
Authorizationheader. - The credential is transmitted even though the requested repository data is public.
- A compromised proxy, TLS trust configuration, diagnostic system, or request logger capable of observing headers could capture the credential.
...[truncated 676 chars]
- A user or hosting environment places a GitHub token in
- Remediation
View remediation
Remediation Suggestions
- Remove automatic use of
GITHUB_TOKEN; public repository metadata should be retrieved anonymously by default. - If authenticated access is necessary, require an explicit command-line option or a Skill-specific variable such as
COOKLIKEHOC_GITHUB_TOKEN. - Inform the user before transmitting a credential and document the exact destination and purpose.
- Require a fine-grained, read-only token restricted to the single public repository and metadata access.
- Read the environment variable once and avoid exposing it through exceptions or diagnostic output.
- Prefer relying on the bundled cache or a pinned local index to avoid unnecessary authenticated API requests.
- Ensure network proxies and request logging systems redact
Authorizationheaders.
- Remove automatic use of
