T09 · Insecure Skill Coding Practices
Error
- Location
- foreman-cworker.sh:75
- Finding
- Credential-Bearing Autonomous Worker Has Unrestricted Network Egress<![CDATA[ ## Vulnerability Details **File Location**: `foreman-cworker.sh:75-85` **Vulnerability Type**: Credential exposure through insufficient container egress isolation **Risk Level**: High ### Vulnerable Code ```bash exec docker ${ctx[@]+"${ctx[@]}"} run --rm \ --memory 4g --cpus 2 --pids-limit 512 \ --cap-drop=ALL --security-opt no-new-privileges \ --read-only --tmpfs /tmp:rw,size=512m --tmpfs /home/worker:rw,mode=1777,size=256m \ --mount "type=bind,source=$WT,target=/work" \ --mount "type=bind,source=$PROMPT,target=/prompt.md,readonly" \ -e ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic \ -e ANTHROPIC_AUTH_TOKEN="$DEEPSEEK_API_KEY" \ -e ANTHROPIC_MODEL="$MODEL" \ "$IMAGE" \ -p "$(cat "$PROMPT")" --dangerously-skip-permissions --output-format text ``` ### Technical Analysis The container receives the live `DEEPSEEK_API_KEY` through the `ANTHROPIC_AUTH_TOKEN` environment variable. It also runs an autonomous agent with `--dangerously-skip-permissions`, has write access to the mounted task worktree, and retains Docker's default unrestricted outbound network access. The container hardening options—dropping capabilities, enabling `no-new-privileges`, imposing resource limits, and using a read-only root filesystem—reduce host compromise risk but do not constrain network destinations. Setting `ANTHROPIC_BASE_URL` controls the normal agent API endpoint; it is not an enforceable egress policy. Any code executed inside the container can read the credential from its environment and independently open a connection to another destination. Consequently, the statement in `foreman-cworker.sh:22-24` that the credential authenticates against “exactly one endpoint” is not technically enforced. ### Attack Path 1. An attacker introduces hostile repository content, prompt instructions, executable tooling, or a dependency lifecycle hook into a delegated worktree. 2. The caged worker is launched with permission confirmations disabled. 3. The wo ...[truncated 1141 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Place the worker behind an egress-filtering proxy or firewall that permits only the required DeepSeek API hostname and necessary DNS resolution. 2. Do not treat `ANTHROPIC_BASE_URL` as a security boundary; revise the documentation until endpoint restrictions are technically enforced. 3. Prefer an API broker outside the container so the worker never receives the raw provider credential. 4. If direct credential injection is unavoidable, use a dedicated, short-lived, narrowly scoped key with a strict spending limit and routine rotation. 5. Prevent unnecessary child processes from inheriting the credential. Where supported, pass credentials through a protected broker or descriptor rather than a general environment variable. 6. Disable package lifecycle scripts and arbitrary dependency installation during worker execution where practical. 7. Monitor the dedicated key for unexpected destinations, usage patterns, and spending, and revoke it automatically after each task. 8. Consider a default-deny network namespace or sandbox policy, with explicit opt-in for the provider endpoint. ]]>
