T09 · Insecure Skill Coding Practices
- Location
scripts/analyze.ts:69- Finding
Arbitrary Local File Upload to an External Analysis Service
- Content
View full analysis
{ const fileBuffer = readFileSync(filePath); const blob = new Blob([fileBuffer]); const form = new FormData(); form.append("file", blob, basename(filePath)); const res = await fetch(`${API_BASE_URL}/api/v1/workspace/upload`, { method: "POST", headers: { "X-API-Key": apiKey }, body: form, }); ``` The caller performs only an existence check: ```ts const filePath = resolve(args[0]); if (!existsSync(filePath)) { console.error(`❌ 文件不存在: ${filePath}`); process.exit(1); } ``` ### Technical Analysis The Skill is documented as an email security analyzer that accepts `.eml` files, but the implementation accepts any filesystem path. It resolves the supplied argument, checks only whether that path exists, reads its complete contents with `readFileSync`, and sends those contents to `https://x.lizhisec.com`. There is no verification that: - The path identifies a regular file. - The filename has an `.eml` extension. - The content is plausibly an email message. - The path is within an approved input directory. - The path is not a symbolic link to a sensitive file. - The file is within a safe size limit. - The user has explicitly approved transmission of that particular file. Consequently, any file readable by the process can be submitted to the external service. This is especially relevant in an Agent environment, where an attacker may use social engineering or crafted instructions to induce the Agent to pass a credential file, private key, configuration file, or other sensitive path as the analysis target. ### Attack Path 1. An attacker supplies or recommends ...[truncated 1317 chars]- Remediation
View remediation
