T09 · Insecure Skill Coding Practices
- Location
SKILL.md:75- Finding
Unsafe Execution of Environment File Contents
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 75–86
Vulnerability Type: Unsafe shell sourcing and excessive environment-variable exposure
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 Skill instructs the Agent to load
.env.localwith the shell dot command (. ./.env.local). This operation does not safely parse a data file; it executes the entire file as shell code under the Agent's current user account. Consequently, any command substitution, shell function, redirection, or other executable shell syntax in.env.localruns before the ServiceGraph request.The use of
set -aalso exports every variable defined by.env.localto thecurlchild process. The operation only needsSERVICEGRAPH_API_KEY, so making unrelated secrets available to the child process exceeds least privilege.The documented HTTPS transmission of
SERVICEGRAPH_API_KEYin the Authorization header to the declaredapi.servicegraph.coendpoint is necessary for the Skill's authenticated API functionality and is not, by itself, covert exfiltration. The vulnerability is the execution of the entire local environment file and the unnecessary inheritance of unrelated variables.Attack Path
- An attacker, compromised development tool, or malicious project dependency writes shell syntax into the workspace's
.env.local. - The user invokes this Skill for its declared directory-discovery functionality.
- The Agent follows the documented authentication procedure.
- The shell evaluates
. ./.env.local, executing the attacker-controlled syntax with the Agent process's operating-system privileges. - The payload can access files and credentials available to that account, invoke local programs, or i ...[truncated 687 chars]
- An attacker, compromised development tool, or malicious project dependency writes shell syntax into the workspace's
- Remediation
View remediation
Remediation Suggestions
- Do not source
.env.localor evaluate it as shell code. - Retrieve only
SERVICEGRAPH_API_KEYwith a non-evaluating configuration parser that rejects shell syntax, duplicate assignments, malformed lines, and unexpected keys. - Validate the extracted value against the expected
vk_token format before use. - Pass only the required credential to the HTTP client rather than exporting all variables.
- Prefer the documented OAuth-enabled ServiceGraph MCP integration, which keeps credentials outside the language-model context and avoids workspace environment-file execution.
- Ensure
.env.localhas restrictive filesystem permissions and is excluded from version control. - Retain HTTPS certificate verification and restrict authenticated requests to the declared
https://api.servicegraph.coorigin.
- Do not source
