T09 · Insecure Skill Coding Practices
- Location
SKILL.md:74- Finding
Executable Credential File Is Sourced as Shell Code
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 74–80
Vulnerability Type: Unsafe execution of local configuration
Risk Level: HighVulnerable Code
bash 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 flow uses the POSIX shell
.command to source.env.local. Sourcing does not treat the file as inert key-value configuration; it parses and executes its contents as shell code.As a result, any command substitution, redirection, function invocation, or ordinary shell command contained in
.env.localruns with the privileges of the account executing the Skill. This behavior is not required to obtainSERVICEGRAPH_API_KEYand violates least-privilege principles.The subshell limits changes to shell state, but it does not prevent filesystem access, network access, credential theft, process execution, or other side effects. The API request itself sends the bearer key only to the declared HTTPS service and is consistent with the Skill's functionality; the vulnerability is the execution of the entire local credential file.
Attack Path
- An attacker, compromised setup process, or untrusted project places executable shell syntax in
.env.local. - A user invokes the Skill for a cybersecurity-firm search.
- The Agent follows the documented REST authentication procedure.
- The shell evaluates
. ./.env.local. - The attacker's commands execute before
curlsends the legitimate API request. - Those commands can access resources available to the Agent's operating-system account and may conceal themselves by allowing the expected API call to continue.
For example, a malicious `.env. ...[truncated 894 chars]
- An attacker, compromised setup process, or untrusted project places executable shell syntax in
- Remediation
View remediation
Remediation Suggestions
- Remove the instruction to source
.env.local. - Prefer an API credential pre-exported by the execution harness or supplied through its secret-management facility:
bash : "${SERVICEGRAPH_API_KEY:?SERVICEGRAPH_API_KEY is not configured}" curl -sS \ -H "Authorization: Bearer ${SERVICEGRAPH_API_KEY}" \ 'https://api.servicegraph.co/v1/datasets/pro_services/fields' - If dotenv-file support is mandatory, use a strict dotenv parser that reads only the exact
SERVICEGRAPH_API_KEYentry without shell evaluation. Reject duplicate keys, malformed assignments, command substitutions, and unexpected fields. - Ensure the credential file is excluded from version control and readable only by the owning user, such as with mode
0600. - Continue preventing the token from entering model context, command tracing, logs, process diagnostics, and error output.
- Run network tooling in a constrained environment with only the filesystem and network permissions needed for the declared API operation.
- Add a security test containing shell metacharacters in a mock dotenv file and verify that no command or substitution is executed.
- Remove the instruction to source
