T09 · Insecure Skill Coding Practices
- Location
SKILL.md:25- Finding
Repository-Controlled Filename Injection in Docker Compose Discovery
- Content
View full analysis
/dev/null | while read f; do echo "=== $f ===" # Extract service names python3 -c " import sys in_services = False indent = 0 for line in open('$f'): stripped = line.rstrip() if stripped == 'services:': in_services = True continue if in_services: if stripped and not stripped.startswith(' ') and not stripped.startswith('#'): break ``` ### Technical Analysis The value of `f` originates from repository filenames discovered by `find`. It is interpolated directly into dynamically generated Python source: ```python open('$f') ``` Shell quoting does not make this safe at the Python parsing layer. A filename containing a single quote and valid Python syntax can terminate the string literal and alter the program executed by `python3 -c`. Repository filenames must therefore be treated as attacker-controlled input when scanning cloned repositories or submitted source archives. The use of `while read f` without `read -r` or null-delimited records also mishandles backslashes, whitespace, and newline characters in filenames. ### Attack Path 1. An attacker creates a directory or Compose filename containing quote characters and Python syntax. 2. The crafted path is committed to a repository or included in a source archive. 3. A user or Agent runs the documented `discover` procedure against that repository. 4. `find` assigns the crafted path to `f`. 5. The shell interpolates `f` into the source passed to `python3 -c`. 6. Python parses the injected text as code and executes it with the privileges of the scanning process. ### Impact ...[truncated 473 chars]- Remediation
View remediation
