T09 · Insecure Skill Coding Practices
- Location
SKILL.md:72- Finding
Unsafe Shell Execution of .env.local
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 72–77
Vulnerability Type: Unsafe execution of a configuration file as shell code
Risk Level: HighVulnerable Code
bash 1. **Try the call first** through a shell wrapper that sources `.env.local`: ( 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 documented authentication procedure dot-sources
.env.localusing. ./.env.local. Dot-sourcing does not treat the file as a passive dotenv configuration file; it interprets its entire contents as shell commands in the current shell process.Consequently, an attacker who can create or modify
.env.localcan insert command substitutions, shell functions, redirections, pipelines, or arbitrary commands. Those instructions execute with the same operating-system identity and permissions as the agent or user following the Skill.The use of
set -afurther causes all subsequently assigned shell variables to be exported to child processes. This exceeds the minimum privilege required to make the API request, which needs onlySERVICEGRAPH_API_KEY.Sending
SERVICEGRAPH_API_KEYas an HTTPS bearer token to the declaredapi.servicegraph.coendpoint is consistent with the Skill's stated authenticated API functionality. The vulnerability is not the necessary API transmission itself, but the avoidable execution of an environment file before that request.Attack Path
- An attacker gains the ability to supply or modify
.env.localin the working directory, such as through a compromised repository, archive, setup process, or another local process. - The attacker adds shell syntax to the file, for example a command substitution or a separate command that reads credentials, modifies files, or performs an outbound request.
...[truncated 1275 chars]
- An attacker gains the ability to supply or modify
- Remediation
View remediation
Remediation Suggestions
-
Remove the instruction to source
.env.localas shell code. -
Prefer supplying
SERVICEGRAPH_API_KEYthrough the agent harness's secret manager or an already-populated process environment. -
Verify that the required variable exists without evaluating a file:
bash : "${SERVICEGRAPH_API_KEY:?SERVICEGRAPH_API_KEY is not set}" curl --fail-with-body --silent --show-error \ -H "Authorization: Bearer ${SERVICEGRAPH_API_KEY}" \ 'https://api.servicegraph.co/v1/datasets/pro_services/fields' -
If dotenv-file support is unavoidable, use a dedicated dotenv parser that:
- Reads only the exact
SERVICEGRAPH_API_KEYfield. - Does not evaluate shell syntax, substitutions, or commands.
- Rejects duplicate, malformed, or unexpected entries.
- Does not export unrelated configuration values.
- Reads only the exact
-
Run the API client in a restricted environment with minimal filesystem access, a minimal inherited environment, and network egress limited to
https://api.servicegraph.co. -
Keep the existing guidance not to paste or expose the API key in the model context, logs, command tracing, or error output.
-
Require explicit user confirmation before credit-consuming unlock operations, preserving the documented disclosure of the number of credits to be charged.
-
