T09 · Insecure Skill Coding Practices
- Location
- SKILL.md:518
- Finding
- Unrestricted Execution of Repository-Controlled Shell Commands<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:518-526` **Vulnerability Type**: Arbitrary shell-command execution without technical isolation **Risk Level**: High ### Vulnerable Code ```markdown ## Prerequisites and security **Runtime requirements**: git is required. The check commands in your improve.md determine what else is needed (go, python, npm, docker, kubectl, psql, etc.). Verify these are installed before starting. **Credentials**: The agent runs arbitrary shell commands from your improve.md. It inherits whatever credentials are available to the process (AWS keys, DB creds, kubeconfigs, API tokens). Run autoimprove with least-privilege credentials. Strip environment variables you don't want the agent to access. **First run**: Always interactive. The readiness check (Step 1) confirms scope, reviews generated tests, and establishes a baseline before the loop starts. Don't run headless until you've verified one interactive run works correctly. **Backup**: Before headless runs, the readiness check creates a backup branch automatically. The loop uses git commits and resets for rollback, but the backup branch protects against edge cases. **Scope enforcement**: The rules below (NEVER modify files outside scope) are policy constraints, not technical enforcement. The agent follows them in practice, but there is no sandbox preventing out-of-scope edits. For sensitive repos, run in a cloned fork or container where damage is reversible. ``` The corresponding exported protocol also directs the agent to execute repository-supplied commands in `references/protocol.md:43-45`: ```markdown 4. **Test**: If `Check.test` is specified, run it. If tests fail: `git reset --hard HEAD~1`, log as "test_failed", continue to next iteration. 5. **Evaluate**: Run the score command (`Check.run`). If it times out, kill it and treat as failure. ``` ### Technical Analysis The skill treats `Check.test` and `Check.run` values from `improve.md` as executable she ...[truncated 2380 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Display the exact resolved test and scoring commands and require explicit user approval before their first execution. 2. Disable shell interpretation by default. Parse commands into executable and argument arrays and invoke them without `sh -c`, `bash -c`, or equivalent shell expansion. 3. Reject command substitution, pipelines, redirections, control operators, and multiline commands unless the user explicitly enables an advanced unsafe mode. 4. Execute all repository-controlled commands inside an ephemeral container or virtual machine with: - A minimal environment containing no inherited secrets. - A writable mount limited to an isolated repository worktree. - Read-only system and dependency mounts. - Network access disabled by default. - CPU, memory, process, and execution-time limits. - No Docker socket, SSH agent, cloud metadata endpoint, or host credential mounts. 5. Add a configurable executable allowlist and require separate approval for sensitive tools such as `kubectl`, `psql`, `docker`, cloud CLIs, and package managers. 6. Treat repositories and their `improve.md` files as untrusted input in both interactive and headless modes. 7. Refuse unattended operation until command validation and isolation have been successfully verified. ]]>
