diff --git a/packages/core/src/utils/pathReader.ts b/packages/core/src/utils/pathReader.ts index 54a95e179d..1eab4212b2 100644 --- a/packages/core/src/utils/pathReader.ts +++ b/packages/core/src/utils/pathReader.ts @@ -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(