T09 · Insecure Skill Coding Practices
- Location
references/verification-patterns.md:309- Finding
Environment Verification Commands Expose Plaintext Secrets
- Content
View full analysis
Vulnerability Details
File Location:
references/verification-patterns.md:309-319
Vulnerability Type: Plaintext sensitive-data disclosure
Risk Level: HighVulnerable Code:
bash # .env file exists [ -f ".env" ] || [ -f ".env.local" ] # Required variable is defined grep -E "^$VAR_NAME=" .env .env.local 2>/dev/nullbash # Variable has actual value (not placeholder) grep -E "^$VAR_NAME=.+" .env .env.local 2>/dev/null | grep -v "your-.*-here|xxx|placeholder|TODO" -iTechnical Analysis
The documented verification commands print the complete assignment for a selected environment variable rather than checking only whether the variable exists. When
$VAR_NAMEidentifies an API key, database URL, authentication token, webhook secret, or similar credential,grepreturns both the variable name and its plaintext value.Because these commands are intended for execution by an AI agent, their output can be copied into tool results, model context, conversation transcripts, execution logs, debugging records, and downstream agent prompts. The second command specifically filters out placeholder values, making it more likely that any returned output contains an operational credential.
Attack Path
- A project stores an operational credential such as
STRIPE_SECRET_KEY,DATABASE_URL, orOPENAI_API_KEYin.envor.env.local. - A verification workflow assigns the sensitive variable name to
$VAR_NAME. - The agent executes the documented
grepcommand. - The shell returns the complete
NAME=valueassignment. - The secret enters the agent's tool output and potentially persistent conversation or execution logs.
- Anyone with access to those records can recover and reuse the credential against the associated service.
Impact Assessment
Exposure is limited to credentials present in the inspected environment files and selected for verification, but the resulting priv ...[truncated 390 chars]
- A project stores an operational credential such as
- Remediation
View remediation
Remediation Suggestions
- Replace value-printing checks with commands that return only an exit status.
- Never include raw environment-variable values in verification output.
- Redact all credential-like output before returning it to agent context or logs.
- Validate type, format, and length locally without displaying the underlying value.
- Restrict checks to an explicit allowlist of required variable names.
- Add tests ensuring verification output cannot contain complete
.envassignments.
A safer existence and non-empty check is:
bash awk -F= -v key="$VAR_NAME" ' $1 == key { if (length(substr($0, index($0, "=") + 1)) > 0) { print key "=REDACTED" found=1 } } END { exit found ? 0 : 1 } ' .env .env.local 2>/dev/nullWhere possible, emit only a boolean result such as
configuredormissing, without returning even a redacted assignment.
