T09 · Insecure Skill Coding Practices
- Location
SKILL.md:39- Finding
Arbitrary Shell Execution Through Sourcing a User-Controlled Environment File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 39-65
Vulnerability Type: Unsafe execution of configuration as shell code
Risk Level: HighVulnerable Code
markdown If a variable is missing, read `~/.env` first, then ask the user. ### Network Connectivity Before any GitHub API call, **test connectivity first**: ```bash curl -s -m 5 https://api.github.com/repos/NousResearch/hermes-agent > /dev/null 2>&1 && echo "direct OK" || echo "direct FAIL"If direct access fails (common in restricted networks), load proxy from
~/.env:bash source ~/.env # ~/.env may contain (possibly commented-out): # https_proxy=http://192.168.28.92:7897 # http_proxy=http://192.168.28.92:7897 # Export the proxy ONLY if direct access failed: export https_proxy=http://192.168.28.92:7897 export http_proxy=http://192.168.28.92:7897 # Re-test with proxy: https_proxy=$https_proxy curl -s -m 10 https://api.github.com/ > /dev/null 2>&1 && echo "proxy OK" || echo "proxy FAIL"Fallback strategy (ordered by priority):
- Direct HTTPS access — works in unrestricted networks
- Proxy from
~/.env— readhttps_proxy/http_proxyvalues; if commented out, uncomment and export them for this session only
text ### Technical Analysis The skill instructs the agent to execute `source ~/.env`. Shell sourcing does not treat the file as passive configuration: every command, substitution, redirection, function definition, and shell expansion in the file is executed in the current shell. Environment files are frequently writable by the current user and may be created or modified by unrelated tools. If an attacker can influence this file, the instruction converts control over configuration data into arbitrary command execution. The automatic instruction to read credential-bearing variables also unnecessarily increases the amount of sensitive material brought into the agent's ex ...[truncated 1386 chars]- Remediation
View remediation
Remediation Suggestions
- Never execute an environment file with
source,.,eval, or equivalent shell evaluation. - Parse the file as data with a non-executing dotenv parser.
- Allowlist only the required keys, such as
GITHUB_TOKEN,GITHUB_USER,CLAWHUB_TOKEN,HTTPS_PROXY, andHTTP_PROXY. - Reject malformed entries, command substitutions, shell metacharacters, unexpected variable names, and duplicate definitions.
- Do not automatically uncomment or modify configuration entries.
- Ask for user approval before reading a credential-bearing file when its contents are not strictly required.
- Never print token values or include them in generated files, logs, prompts, command lines, or error messages.
- Prefer obtaining credentials directly from the process environment or a dedicated secret manager.
- Validate proxy schemes and destinations before use, and retain TLS certificate verification.
- Replace the unsafe example with a small parser that reads only exact
KEY=VALUEassignments without executing them.
- Never execute an environment file with
