feat(core): add defense-in-depth workspace validation for directory expansion

Re-validate every file found during directory expansion to prevent traversal
via symlinks or other methods during recursion.

Related to #1489
This commit is contained in:
Om Patel
2026-05-18 16:22:39 -04:00
parent 2858ab75d4
commit 7bcadeca39

View File

@@ -87,6 +87,11 @@ export async function readPathFromWorkspace(
);
for (const filePath of finalFiles) {
// Defense in depth: validate each file found within the directory.
if (!workspace.isPathWithinWorkspace(filePath)) {
continue;
}
const relativePathForDisplay = path.relative(absolutePath, filePath);
allParts.push({ text: `--- ${relativePathForDisplay} ---\n` });
const result = await processSingleFileContent(