T09 · Insecure Skill Coding Practices
- Location
SKILL.md:77- Finding
Arbitrary Shell Command Execution Through Unsafe .env.local Sourcing
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:77-81
Vulnerability Type: Unsafe shell execution of a configuration file
Risk Level: Highbash 1. **Try the call first** through a shell wrapper that sources `.env.local`: ```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 documented authentication procedure uses the POSIX
.command to source.env.local. This treats the file as executable shell code rather than as a passive key-value configuration file. Consequently, shell commands, command substitutions, functions, expansions, redirections, and other shell syntax in.env.localexecute with the privileges of the user running the Skill.This behavior exceeds the minimum privilege required for the declared functionality. The Skill only needs to retrieve
SERVICEGRAPH_API_KEYand pass it to the declared ServiceGraph HTTPS endpoint. Executing all contents of a workspace-controlled configuration file is unnecessary.The surrounding
set -aalso causes every subsequently assigned shell variable to be exported. This unnecessarily broadens the environment inherited bycurl, rather than limiting it to the one credential required for authentication.The static pre-scan's sensitive network transmission is otherwise consistent with the Skill's declared purpose: the bearer token is sent in an
Authorizationheader tohttps://api.servicegraph.co, its declared API provider. The reviewed instructions do not direct the token or the contents of.env.localto any unrelated endpoint.Attack Path
- An attacker gains the ability to create or modify
.env.localin the workspace, such as through a malicious repository, compromised project archive, or prior workspace modification. - The attacker inserts shell syn ...[truncated 1159 chars]
- An attacker gains the ability to create or modify
- Remediation
View remediation
Remediation Suggestions
- Do not execute
.env.localwithsourceor the POSIX.command. - Prefer requiring
SERVICEGRAPH_API_KEYto be injected by the execution harness or exported by the user before the Skill runs. - If dotenv-file support is necessary, use a strict parser that:
- Reads only the
SERVICEGRAPH_API_KEYentry. - Treats the file as data rather than shell code.
- Rejects duplicate keys, command substitutions, expansions, redirections, and unsupported syntax.
- Validates the expected
vk_credential format.
- Reads only the
- Pass only the required credential to the HTTP client instead of using
set -a. - Preserve the existing guidance not to paste the key into chat, model context, command output, or logs.
- Use a hardened wrapper outside the model-generated shell command where possible, with a fixed destination host and TLS verification enabled.
- Replace the vulnerable example with a pattern equivalent to:
bash test -n "$SERVICEGRAPH_API_KEY" || { printf '%s\n' 'SERVICEGRAPH_API_KEY is not set' >&2 exit 1 } curl --fail-with-body --silent --show-error \ -H "Authorization: Bearer $SERVICEGRAPH_API_KEY" \ 'https://api.servicegraph.co/v1/datasets/pro_services/fields'
- Do not execute
