diff --git a/src/memory/manager.ts b/src/memory/manager.ts index 9a9991d10..fa8493fb5 100644 --- a/src/memory/manager.ts +++ b/src/memory/manager.ts @@ -401,7 +401,8 @@ export class MemoryIndexManager { throw new Error("path required"); } const absPath = path.resolve(this.workspaceDir, relPath); - if (!absPath.startsWith(this.workspaceDir)) { + const rel = path.relative(this.workspaceDir, absPath); + if (rel.startsWith("..") || path.isAbsolute(rel)) { throw new Error("path escapes workspace"); } const content = await fs.readFile(absPath, "utf-8");