T09 · Insecure Skill Coding Practices
- Location
SKILL.md:79- Finding
Arbitrary Command Execution Through Unsafe Dotenv Sourcing
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 79–81
Vulnerability Type: Unsafe shell execution of a dotenv file
Risk Level: HighVulnerable 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/pro_services/fields' )Technical Analysis
The Skill instructs the agent to dot-source
.env.localinto a shell before making an authenticated API request. Dot-sourcing does not parse the file as a passive collection of environment-variable assignments; it executes the file as shell code.Consequently, any command substitution, function invocation, redirection, or ordinary shell command in
.env.localexecutes with the privileges of the user running the agent. This exceeds the minimum privileges required for the declared functionality, which only needs access to theSERVICEGRAPH_API_KEYvalue.The use of a subshell limits persistence of exported environment variables, but it does not restrict filesystem access, network access, process execution, or other side effects produced by malicious commands. It also conflicts with the Skill's stated security objective of handling the token without reading or executing unrelated credential-file content.
Sending
SERVICEGRAPH_API_KEYin theAuthorizationheader to the declaredhttps://api.servicegraph.coendpoint is necessary for the advertised functionality and is not, by itself, an unrelated exfiltration path. The vulnerability is the execution of arbitrary dotenv contents before that request.Attack Path
- An attacker, compromised project, or untrusted repository places shell syntax in
.env.local. - The user asks the agent to invoke the ServiceGraph functionality.
- Following the Skill's first-call instructions, the agent launches the documented shell wrapper.
- The wrapper executes
. ./.env.local. - The ...[truncated 1258 chars]
- An attacker, compromised project, or untrusted repository places shell syntax in
- Remediation
View remediation
Remediation Suggestions
- Do not use
source,., or shell evaluation to load dotenv files. - Prefer requiring
SERVICEGRAPH_API_KEYto be exported by the user's environment or supplied through the OAuth-backed ServiceGraph MCP integration. - If
.env.localsupport is necessary, use a dedicated dotenv parser that treats all file content as data and retrieves only the exactSERVICEGRAPH_API_KEYfield. - Reject duplicate keys, malformed lines, command substitutions, shell metacharacters, embedded newlines, and unexpected variable names.
- Validate the extracted credential against the expected token format, such as a strict
vk_prefix and an appropriately constrained character set and length. - Pass the validated value directly to the HTTP client without invoking
evalor constructing a shell command dynamically. - Restrict credential-file permissions and avoid loading unrelated secrets from a shared dotenv file.
- Prefer an execution interface that passes arguments as an array rather than through a shell.
- Retain the existing instruction not to paste credentials into chat, and avoid logging request headers or token values.
- Do not use
