T09 · Insecure Skill Coding Practices
- Location
SKILL.md:74- Finding
Unsafe Execution of Project-Local Environment File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 74–76
Vulnerability Type: Unsafe shell sourcing and excessive environment export
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/product_directory/fields' )Technical Analysis
The documented authentication wrapper loads
.env.localwith the POSIX shell.command. This command does not treat the file as passive key-value configuration: it executes all shell syntax contained in the file with the invoking user's privileges.Because
.env.localis resolved relative to the current project directory, anyone able to create or alter that file can inject shell commands that execute when an agent follows the Skill's documented authentication procedure. This is unnecessary for the declared functionality, which only requires access toSERVICEGRAPH_API_KEY.Additionally,
set -aexports every variable created or modified while loading the file. As a result, all values in.env.local, rather than only the required API key, are inherited bycurl. Although the shown request sends onlySERVICEGRAPH_API_KEYin its HTTP header, exporting unrelated secrets to a child process exceeds least privilege.The subsequent transmission of
SERVICEGRAPH_API_KEYas a bearer token to the declared host,https://api.servicegraph.co, is consistent with the Skill's authenticated API functionality. The vulnerability is the executable loading mechanism, not the documented bearer-authentication request itself.Attack Path
- An attacker gains the ability to commit, generate, or modify
.env.localin the directory from which the Skill's command is run. - The attacker adds valid shell syntax, for example a command that reads credentials, modifies files, or initiates an external connection.
- The user or agent follows the Skill document ...[truncated 916 chars]
- An attacker gains the ability to commit, generate, or modify
- Remediation
View remediation
Remediation Suggestions
- Do not source
.env.localor any other project-controlled file as shell code. - Prefer the Skill's documented OAuth-enabled MCP integration, which keeps credentials in the harness sandbox and out of the model context.
- For REST usage, require
SERVICEGRAPH_API_KEYto be supplied by a trusted process environment or secret manager:bash : "${SERVICEGRAPH_API_KEY:?SERVICEGRAPH_API_KEY is not configured}" curl --fail-with-body --silent --show-error \ -H "Authorization: Bearer ${SERVICEGRAPH_API_KEY}" \ 'https://api.servicegraph.co/v1/datasets/product_directory/fields' - If loading a configuration file is unavoidable, use a non-executing parser that accepts only a strict
SERVICEGRAPH_API_KEY=<value>record. Reject command substitutions, shell metacharacters, duplicate keys, unexpected fields, and malformed token values. - Remove
set -a; pass only the required credential to the intended process. - Validate that the key matches the expected format without printing it, and ensure logs, shell tracing, and error output cannot disclose the authorization header.
- Pin outbound authenticated requests to the expected HTTPS origin and avoid following redirects that could forward the authorization header to an unintended host.
- Do not source
