{"record":{"id":"6516960ae9f8cd7e","repo":"headroomlabs-ai/headroom","slug":"path-traversal-detected-path","errorCode":null,"errorMessage":"Path traversal detected: {path}","messagePattern":"Path traversal detected: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"headroom/proxy/memory_handler.py","lineNumber":1594,"sourceCode":"\n        # User-scoped memory directory\n        user_dir = self._native_memory_dir / user_id\n        user_dir.mkdir(parents=True, exist_ok=True)\n\n        # Normalize path (remove /memories prefix if present)\n        if path.startswith(\"/memories\"):\n            path = path[len(\"/memories\") :]\n        if path.startswith(\"/\"):\n            path = path[1:]\n\n        # Resolve and validate\n        resolved = (user_dir / path).resolve()\n\n        # Security: ensure path is within user directory\n        try:\n            resolved.relative_to(user_dir.resolve())\n        except ValueError:\n            raise ValueError(f\"Path traversal detected: {path}\") from None\n\n        return resolved\n\n    def _native_view(self, input_data: dict[str, Any], user_id: str) -> str:\n        \"\"\"View directory contents or file contents.\"\"\"\n        path = input_data.get(\"path\", \"/memories\")\n        view_range = input_data.get(\"view_range\")\n\n        resolved = self._resolve_native_path(path, user_id)\n\n        if not resolved.exists():\n            return f\"The path {path} does not exist. Please provide a valid path.\"\n\n        if resolved.is_dir():\n            # List directory contents\n            lines = [\n                f\"Here're the files and directories up to 2 levels deep in {path}, \"\n                \"excluding hidden items and node_modules:\"","sourceCodeStart":1576,"sourceCodeEnd":1612,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/proxy/memory_handler.py#L1576-L1612","documentation":"Error \"Path traversal detected: {path}\" thrown in headroomlabs-ai/headroom.","triggerScenarios":"Raised when a memory-handler file path resolves outside the allowed storage root, blocking a path traversal attempt.","commonSituations":"See trigger scenarios.","solutions":["Do not include '..' or absolute path segments in the requested path","Use a path relative to the memory storage root","If the path is built from user input, sanitize/normalize it before sending"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}