T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/publish_to_clawhub.js:42
- Finding
- Unfiltered Recursive Upload Can Disclose Sensitive Files## Vulnerability Details **File Location**: `scripts/publish_to_clawhub.js`, lines 42-50, 63, and 74-77 **Vulnerability Type**: Unrestricted file collection and sensitive-data exposure **Risk Level**: High ### Vulnerable Code ```js function listFiles(dir, base = dir) { let out = []; for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { const p = path.join(dir, entry.name); if (entry.isDirectory()) out = out.concat(listFiles(p, base)); else out.push({ abs: p, rel: path.relative(base, p) }); } return out; } const files = listFiles(skillPath); for (const f of files) { const buf = fs.readFileSync(f.abs); form.append('files', new Blob([buf]), f.rel); } ``` ### Technical Analysis The publisher recursively enumerates and uploads every regular file under the user-supplied `--skill-path`. It does not use an allowlist, package manifest, ignore rules, automated secret detection, file-size limits, or exclusions for sensitive and machine-specific artifacts. Consequently, files such as `.env`, private keys, credential files, repository metadata, logs, backups, editor artifacts, local configuration, and runtime output can become part of the outbound package. Although `SKILL.md` instructs the operator to conduct a sensitive-data review, the implementation neither displays the exact file manifest nor enforces that review. The referenced release checklist also does not explicitly require secret scanning. Recursive package collection is necessary to publish a multi-file Skill, but uploading every file without filtering exceeds the minimum file-access scope required by that functionality. ### Attack Path 1. A credential, private file, runtime artifact, or other local-only file exists anywhere beneath the selected Skill directory. 2. The user or Agent invokes the documented publisher with that directory as `--skill-path`. 3. `listFiles()` recursively includes the sensitive file wi ...[truncated 1186 chars]
- Remediation
- ## Remediation Suggestions 1. Construct the upload from a strict package manifest or allowlist rather than recursively including every file. 2. Support a dedicated ignore file and, where appropriate, honor `.gitignore`. 3. Reject known sensitive names and patterns, including `.env*`, credential files, private keys, token files, VCS directories, logs, backups, editor state, and runtime artifacts. 4. Scan file contents for common secret formats and private-key headers before creating the request. 5. Resolve and validate every path, rejecting symbolic links and any file whose real path escapes the selected Skill directory. 6. Enforce maximum individual-file size, total package size, file count, and directory depth. 7. Print the exact relative-file manifest and destination before transmission. 8. Require explicit confirmation after the manifest and secret scan have completed, especially for public releases. 9. Abort publication when suspicious files are found rather than relying exclusively on procedural documentation.
