T09 · Insecure Skill Coding Practices
- Location
SKILL.md:271- Finding
API Token Disclosure Through Unsafe Troubleshooting Guidance
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:271
Vulnerability Type: Exposure of a sensitive environment variable through terminal output
Risk Level: MediumVulnerable Code Snippet
markdown > 自查:多半是 `GUAIKEI_API_TOKEN` 未通过校验(见 Q1)。运行前先 `echo $GUAIKEI_API_TOKEN` 确认变量已注入。The instruction tells users or an AI agent to run:
bash echo $GUAIKEI_API_TOKENTechnical Analysis
GUAIKEI_API_TOKENis the private credential used to authenticate requests to the external API service. Printing the variable exposes its complete value to standard output.In agent, CI/CD, support, or managed-terminal environments, standard output may be retained in execution transcripts, build logs, shell recordings, observability systems, or support artifacts. Verifying whether an environment variable is configured only requires testing whether it is non-empty; revealing its complete value is unnecessary and violates least-disclosure principles.
The application code otherwise sends the token only as an HTTPS request header to the fixed, documented API host. The vulnerability is therefore in the troubleshooting instruction rather than the normal request flow.
Attack Path
- A user experiences a startup or authentication failure.
- The user or AI agent follows the troubleshooting guidance in
SKILL.md. - The shell expands
$GUAIKEI_API_TOKENand prints the complete credential. - The terminal output is retained in an agent transcript, CI log, shell recording, or support artifact.
- A party with access to that retained output extracts the token.
- The exposed token can be replayed against the Guaikei API until it is revoked or expires.
No command injection or privilege escalation is required; exploitation depends on access to the captured output.
Impact Assessment
An attacker could obtain the same API authorization associated with the exposed token. This may permit unauthorized use of the victim's API account, consumption of quotas ...[truncated 309 chars]
- Remediation
View remediation
Remediation Suggestions
Replace the token-printing instruction with a non-disclosing presence check:
bash if [ -n "${GUAIKEI_API_TOKEN:-}" ]; then echo "GUAIKEI_API_TOKEN is configured" else echo "GUAIKEI_API_TOKEN is missing" fiFor a concise POSIX-compatible alternative:
bash test -n "${GUAIKEI_API_TOKEN:-}" && echo "configured" || echo "missing"Additional hardening measures:
- Explicitly instruct users never to print, paste, or share the complete token.
- If format inspection is necessary, validate length and allowed characters without displaying the value.
- If partial identification is unavoidable, expose only a short masked prefix or suffix.
- Redact
GUAIKEI_API_TOKENfrom agent transcripts, CI logs, telemetry, and support bundles. - Revoke and rotate any token that may already have appeared in captured output.
- Keep the existing practice of transmitting the token only over HTTPS to the fixed documented API endpoint.
