T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/rehash.sh:26
- Finding
- Integrity Verification Fails to Detect Unlisted or Non-Shell Dependency Files<![CDATA[ ## Vulnerability Details **File Location**: `scripts/rehash.sh:26-36`; verification logic in `scripts/deploy.sh:27-58` **Vulnerability Type**: Incomplete integrity validation **Risk Level**: High ### Vulnerable Code ```bash count=0 for skill in "${SUB_SKILLS[@]}"; do script_dir="$SKILLS_DIR/$skill/scripts" if [[ ! -d "$script_dir" ]]; then echo "WARNING: $skill/scripts not found, skipping" >&2 continue fi while IFS= read -r -d '' script; do rel_path="${script#"$SKILLS_DIR/"}" hash="$(sha256sum "$script" | awk '{print $1}')" echo "$hash $rel_path" >> "$CHECKSUMS" ((count++)) done < <(find "$script_dir" -type f -name '*.sh' -print0 | sort -z) done ``` The resulting manifest is verified as follows: ```bash while IFS= read -r line; do # skip comments and empty lines [[ "$line" =~ ^[[:space:]]*# ]] && continue [[ -z "${line// }" ]] && continue local expected_hash file_rel expected_hash="$(echo "$line" | awk '{print $1}')" file_rel="$(echo "$line" | awk '{print $2}')" local file_abs="$SKILLS_DIR/$file_rel" if [[ ! -f "$file_abs" ]]; then echo " MISSING: $file_rel" >&2 ((failed++)) continue fi local actual_hash actual_hash="$(sha256sum "$file_abs" | awk '{print $1}')" if [[ "$actual_hash" != "$expected_hash" ]]; then echo " MISMATCH: $file_rel" >&2 echo " expected: $expected_hash" >&2 echo " actual: $actual_hash" >&2 ((failed++)) else echo " OK: $file_rel" fi done < "$CHECKSUMS" ``` ### Technical Analysis The baseline-generation process includes only files ending in `.sh`. It does not cover Python, JavaScript, service definitions, configuration files, or other payloads that a downstream deployment script may execute, install, or copy. The generator also silently skips a dependency whose `scripts` directory is absent. The verifier only checks entries already present in the manifest; it does not compare the manifest against an authoritative list ...[truncated 1430 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Ship a reviewed, immutable checksum manifest with the Skill rather than relying solely on a locally generated baseline. - Define an authoritative inventory of every required downstream file. - Reject missing files, unexpected files, duplicate manifest entries, malformed hashes, and unsafe paths. - Hash all executable and deployment-consumed content, including Python, JavaScript, service units, hooks, templates, and configuration files. - Require all three downstream skills and their expected entry points to be represented in the manifest. - Verify each dependency immediately before executing it to reduce time-of-check/time-of-use exposure. - Prefer signed release manifests or publisher signatures tied to immutable package versions. - Treat `rehash.sh` only as an explicit trust-administration operation and clearly warn that it does not establish provenance by itself. ]]>
