T09 · Insecure Skill Coding Practices
- Location
SKILL.md:188- Finding
Credential Exposure Through Environment Variable Enumeration
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 188-194
Vulnerability Type: Credential exposure through unsafe environment inspection
Risk Level: MediumComplete Code Snippet
bash # 验证环境变量是否设置 echo "配置检查:" env | grep -E "API|KEY|TOKEN|SECRET" | sed "s/=.*/=***/" # Linux/macOS # 或 PowerShell # Get-ChildItem Env: | Where-Object {$_.Name -match "API|KEY|TOKEN"} | Format-TableTechnical Analysis
The configuration-verification instructions search the process environment for variables whose names contain
API,KEY,TOKEN, orSECRET.The Unix pipeline masks values with
sedbefore displaying them. However, the PowerShell alternative passes complete environment-variable objects toFormat-Table. Under normal PowerShell formatting, these objects expose both the variable name and its value. If an AI Agent follows this instruction, API keys, access tokens, or other credentials can consequently enter terminal output, the Agent context, conversation history, execution logs, or external telemetry.Enumerating all credential-like environment variables also exceeds what is necessary for configuration verification. A secure check should reference only the exact variable required by the Skill and report whether it is present, without reading or printing its value.
Attack Path
- A user loads the Skill and follows its environment setup procedure.
- On Windows, the Agent executes the documented PowerShell verification command.
- PowerShell selects every environment variable with a name matching
API,KEY, orTOKEN. Format-Tablerenders the selected environment-variable objects, including their values.- Credential values become visible in Agent-accessible command output.
- Those values may persist in conversation transcripts, terminal logs, model context, or platform telemetry and may then be accessible to unauthorized parties.
Impact Assessment
Successful exploitation does not directly grant additional ...[truncated 719 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove broad environment enumeration commands from the setup instructions.
- Check only explicitly required variable names and disclose only presence or absence.
- Replace the PowerShell command with a value-safe check such as:
powershell if (Test-Path Env:REQUIRED_API_KEY) { Write-Output "REQUIRED_API_KEY is configured" } else { Write-Output "REQUIRED_API_KEY is not configured" }- Use an equivalent targeted check on Unix-like systems:
bash if [ -n "${REQUIRED_API_KEY+x}" ]; then echo "REQUIRED_API_KEY is configured" else echo "REQUIRED_API_KEY is not configured" fi- Do not print, log, return, or otherwise place secret values in Agent context.
- Apply output redaction at the Agent or execution-platform boundary as defense in depth.
- If the unsafe PowerShell command has already been executed, review relevant transcripts and logs, delete exposed copies where possible, and rotate potentially disclosed credentials.
