T09 · Insecure Skill Coding Practices
- Location
SKILL.md:68- Finding
Unsafe Shell Sourcing of Environment File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 68–71
Vulnerability Type: Executable environment-file sourcing
Risk Level: MediumVulnerable Code:
bash ( set -a; [ -f .env.local ] && . ./.env.local; set +a; curl -sS -H "Authorization: Bearer $SERVICEGRAPH_API_KEY" \ 'https://api.servicegraph.co/v1/datasets/product_directory/fields' )Technical Analysis
The documented authentication wrapper loads
.env.localwith the POSIX shell.command. This interprets the entire file as shell code rather than parsing it strictly as key-value configuration. Consequently, command substitutions, redirections, functions, and arbitrary commands in.env.localexecute with the privileges of the user running the Skill.Executing an environment file is not required to retrieve
SERVICEGRAPH_API_KEYand exceeds the minimum privilege necessary for the declared API-querying functionality. Although the subsequent HTTPS request sends the bearer token only to the declared ServiceGraph host, the unsafe sourcing step creates an independent local command-execution risk.Attack Path
- An attacker, compromised dependency, or untrusted project gains the ability to create or modify
.env.localin the working directory. - The attacker inserts shell syntax into the file, such as a command substitution or standalone command, alongside or instead of the expected API-key assignment.
- The Agent follows the documented wrapper and executes
. ./.env.local. - The shell runs the attacker-controlled content before invoking
curl. - The malicious command can access resources available to the Agent user and may steal credentials, exfiltrate files, or alter the workspace.
Impact Assessment
Successful exploitation provides arbitrary command execution under the existing Agent user's identity. The attacker does not automatically gain operating-system privileges beyond that account, but can access ...[truncated 569 chars]
- An attacker, compromised dependency, or untrusted project gains the ability to create or modify
- Remediation
View remediation
Remediation Suggestions
- Do not source
.env.localwith.orsource. - Prefer credentials injected by the execution harness through an already established environment variable.
- If dotenv-file support is necessary, use a non-executing parser that accepts only a strict
KEY=VALUEgrammar and retrieves onlySERVICEGRAPH_API_KEY. - Validate that the key matches the expected
vk_token format, reject duplicate or malformed assignments, and never evaluate command substitutions or shell expansions. - Invoke the HTTP client with a minimal environment and ensure the authorization header is sent exclusively to the fixed HTTPS origin
https://api.servicegraph.co. - Keep the existing guidance not to paste credentials into chat or expose them to model context.
- Consider refusing to read credential files from untrusted project directories; use a harness-managed secret store or a user-owned configuration path with restrictive permissions instead.
- Do not source
