T09 · Insecure Skill Coding Practices
Error
- Location
- src/index.js:318
- Finding
- Blocked-content policy evaluates only the source path<![CDATA[ ## Vulnerability Details **File Location**: `src/index.js:318-325` **Vulnerability Type**: Policy enforcement bypass **Risk Level**: High ### Vulnerable Code ```js const blockedPattern = (policy.blockedPatterns || []).find((pattern) => { try { return new RegExp(pattern, 'i').test(sourcePath); } catch { return false; } }); ``` ### Technical Analysis The documented `blockedPatterns` policy is intended to reject candidates containing prohibited behavior. However, every configured regular expression is tested only against `sourcePath`, which is the candidate directory path. Candidate filenames and file contents are never evaluated by this policy control. For example, the documented pattern `curl\s*\|\s*sh` will not detect the command in `fixtures/avoid-skill/scripts/install.sh:2` unless the directory path itself happens to contain matching text. The separate ClawShield scan may classify this fixture as `Avoid`, but that does not make the content-blocking policy effective. An `Avoid` result can be installed with `--force`, whereas a genuine blocked-pattern match is rejected before the approval logic. This discrepancy undermines an administrator's expectation that explicitly prohibited content cannot be overridden. Invalid regular expressions are also silently ignored by the `catch` block, causing a malformed security rule to fail open. ### Attack Path 1. An administrator configures a blocked-content pattern such as `curl\s*\|\s*sh`. 2. An attacker supplies a skill containing that command inside a script while using an innocuous source-directory name. 3. The installer evaluates the pattern against only the source path. 4. The content rule does not match, so the dedicated blocked-pattern rejection is bypassed. 5. If the external scanner misses or suppresses the behavior, the candidate may be approved through another policy branch. If classified as `Avoid`, a user can still install it with `--force`. 6. The prohibited content is copied i ...[truncated 674 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Compile and validate all configured regular expressions when loading the policy. Reject the policy if any expression is invalid instead of silently ignoring it. 2. Apply blocked patterns to bounded textual content from every candidate file, not merely to the source path. 3. Define explicit handling for binary files, encodings, oversized files, and skipped directories so an attacker cannot evade inspection through unsupported content. 4. Apply rules to normalized relative filenames and relevant metadata in addition to file contents. 5. Treat blocked-pattern matches as non-overridable unless the policy explicitly defines a separate, auditable exception mechanism. 6. Preserve scanner checks as defense in depth rather than as a replacement for policy enforcement. 7. Add a regression test demonstrating that the pattern `curl\s*\|\s*sh` blocks `fixtures/avoid-skill/scripts/install.sh` independently of the scanner's risk classification. ]]>
