T09 · Insecure Skill Coding Practices
Error
- Location
- preinstall-check.sh:16
- Finding
- Allowlist validation can be bypassed through skill-name impersonation or regular-expression injection<![CDATA[ ## Vulnerability Details **File Location**: `preinstall-check.sh`, lines 16-28 **Vulnerability Type**: Improper trust binding and unsafe regular-expression construction **Risk Level**: High ### Vulnerable Code ```bash SKILL_NAME=$(basename "$SKILL_PATH") # Check blocklist first if [ -f "$BLOCKLIST" ] && grep -q "^$SKILL_NAME:" "$BLOCKLIST"; then echo "⛔ BLOCKED: $SKILL_NAME is on the security blocklist" grep "^$SKILL_NAME:" "$BLOCKLIST" echo "" echo "Remove from blocklist to override: $BLOCKLIST" exit 2 fi # Check allowlist (skip audit if verified) if [ -f "$ALLOWLIST" ] && grep -q "^$SKILL_NAME:verified:" "$ALLOWLIST"; then echo "✅ ALLOWED: $SKILL_NAME is on the verified allowlist" grep "^$SKILL_NAME:" "$ALLOWLIST" exit 0 fi ``` ### Technical Analysis The script treats the basename of an untrusted skill directory as sufficient proof that the skill was previously reviewed. Approval is not bound to the skill's canonical path, publisher, or content digest. Any unrelated directory can therefore inherit an existing approval by reusing an allowlisted name. In addition, `SKILL_NAME` is interpolated directly into a `grep` regular expression. Filesystem-valid metacharacters such as `.*` are interpreted as regular-expression syntax rather than literal characters. This can cause a crafted name to match an unrelated allowlist entry. A successful allowlist match immediately exits with status zero and skips `audit.sh`, making this a direct bypass of the advertised pre-installation security control. ### Attack Path 1. Identify an existing allowlisted name, such as `himalaya`, or choose a regex-based name such as `.*`. 2. Create a malicious skill directory using that basename. 3. Invoke `preinstall-check.sh` with the malicious directory. 4. The script extracts only the basename and matches it against `allowlist.txt`. 5. The allowlist branch exits successfully without invoking `audit.sh`. 6. The malicious skill is reported as ...[truncated 506 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not use a directory basename as the identity of an approved skill. - Bind each approval to a canonical path and a cryptographic digest of the reviewed skill contents. - Recalculate and verify the digest before every installation or execution. - Parse allowlist records into fields and compare the name as a literal fixed string, for example with `grep -F`, rather than constructing a regular expression. - Validate skill names against a restrictive format such as `^[A-Za-z0-9._-]+$`. - Use exact field equality and reject duplicate or malformed allowlist records. - Consider removing the audit-skipping behavior entirely: an allowlist may suppress a warning after scanning, but it should not prevent changed contents from being scanned. ]]>
