T09 · Insecure Skill Coding Practices
- Location
index.js:41- Finding
Output Directory Traversal Through Untrusted Feishu Folder Names
- Content
View full analysis
({ ...subItem, path: path.join(item.name, subItem.path || subItem.name) }))); } } } ``` ```js const content = await readDocument(item.token); const title = content.title || item.name; const outputSubPath = item.path ? path.join(options.output, path.dirname(item.path)) : options.output; const filePath = saveMarkdown(content.content, outputSubPath, title); console.log(`✅ 已保存到: ${filePath}`); ``` The final filesystem write occurs in `saveMarkdown`: ```js function saveMarkdown(content, outputPath, title) { const filePath = path.join(outputPath, `${title.replace(/[\/\\:*?"<>|]/g, '_')}.md`); fs.mkdirSync(path.dirname(filePath), { recursive: true }); fs.writeFileSync(filePath, content); return filePath; } ``` ### Technical Analysis Folder names and paths returned by the Feishu Drive tool are remotely controlled metadata. During recursive enumeration, the implementation passes `item.name` directly to `path.join`. It later combines the resulting `item.path` with the user-selected output directory. Although document titles are partially sanitized before being used as filenames, directory components are neither sanitized nor checked against the intended export root. Node.js normalizes `..` path components when evaluating `path.join`. Consequently, a folder name such as `../../target` can cause the resolved destination to escape `options.output`. This issue applies to recursive folder exports where an attacker can influence the names of folders included in an export. The application does not verify that the fin ...[truncated 1708 chars]- Remediation
View remediation
