T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/council-of-wisdom.sh:110
- Finding
- Workspace Path Traversal Through Unvalidated Project Names<![CDATA[ ## Vulnerability Details **File Location**: `scripts/council-of-wisdom.sh`, lines 110-117 and 263-268 **Vulnerability Type**: Path traversal and insufficient path-boundary validation **Risk Level**: Medium ### Vulnerable Code ```bash init_workspace() { local name="$1" if [[ -z "${name}" ]]; then error "Project name required. Usage: council-of-wisdom init <project-name>" fi if workspace_exists "${name}"; then error "Workspace '${name}' already exists." fi log "Initializing Council of Wisdom workspace: ${name}" local workspace="${WORKSPACE_ROOT}/${name}" # Create directory structure mkdir -p "${workspace}"/{workspace/{monitoring,testing,feedback,prompts/council,agents,logs,reports},.github/workflows} # ... log "Initializing git repository..." cd "${workspace}" git init git add . git commit -m "Initial commit: Council of Wisdom workspace - ${name}" } ``` ### Technical Analysis The project name is incorporated directly into a filesystem path without rejecting absolute paths, directory separators, `..` components, or symlink-based escapes. Shell quoting protects against shell metacharacter injection, but it does not guarantee that the resulting path remains beneath `WORKSPACE_ROOT`. For example, a project name such as `../../../tmp/external-project` causes the resolved workspace path to escape the intended Council of Wisdom workspace. The script subsequently creates directories, writes generated files, changes into that location, and initializes or modifies Git state. Symbolic links inside the workspace path could produce a similar boundary escape unless the canonical target is verified. ### Attack Path 1. An attacker or untrusted caller invokes: ```bash council-of-wisdom init ../../../tmp/external-project ``` 2. The script constructs: ```text ${WORKSPACE_ROOT}/../../../tmp/external-project ``` 3. `mkdir -p` creates directories outside the configured ...[truncated 827 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Restrict project names to a conservative allowlist: ```bash if [[ ! "$name" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then error "Invalid project name" fi ``` 2. Explicitly reject `/`, `\`, `..`, leading hyphens, control characters, and absolute paths. 3. Canonicalize both the workspace root and destination: ```bash root="$(realpath -m "$WORKSPACE_ROOT")" target="$(realpath -m "$root/$name")" case "$target" in "$root"/*) ;; *) error "Workspace path escapes configured root" ;; esac ``` 4. Reject symlink components or revalidate containment after directory creation. 5. Avoid running initialization as a privileged user. 6. Add tests covering absolute paths, traversal components, nested separators, symlinks, and Unicode path edge cases. ]]>
