{"record":{"id":"41f7a41d0fbd5533","repo":"ruvnet/ruflo","slug":"file-path-is-outside-allowed-directories","errorCode":null,"errorMessage":"File path is outside allowed directories","messagePattern":"File path is outside allowed directories","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/mcp/src/resource-registry.ts","lineNumber":515,"sourceCode":"    // Prevent access to sensitive system paths\n    const blockedPaths = ['/etc/', '/proc/', '/sys/', '/dev/', '/root/', '/var/log/'];\n    const lowerPath = normalizedPath.toLowerCase();\n    for (const blocked of blockedPaths) {\n      if (lowerPath.startsWith(blocked) || lowerPath.includes('/.')) {\n        throw new Error('Access to system paths is not allowed');\n      }\n    }\n\n    // If allowedBasePaths specified, validate against them\n    if (options?.allowedBasePaths && options.allowedBasePaths.length > 0) {\n      const resolvedPath = path.resolve(normalizedPath);\n      const isAllowed = options.allowedBasePaths.some((basePath) => {\n        const resolvedBase = path.resolve(basePath);\n        return resolvedPath.startsWith(resolvedBase);\n      });\n\n      if (!isAllowed) {\n        throw new Error('File path is outside allowed directories');\n      }\n    }\n\n    const content = await fs.readFile(normalizedPath);\n    return [\n      {\n        uri,\n        mimeType: options?.mimeType || 'application/octet-stream',\n        blob: content.toString('base64'),\n      },\n    ];\n  };\n\n  return { resource, handler };\n}\n","sourceCodeStart":497,"sourceCodeEnd":531,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/mcp/src/resource-registry.ts#L497-L531","documentation":"The file resource was configured with allowedBasePaths, and the resolved real path does not fall under any of them. The read is refused as out-of-scope: whitelist the directory in allowedBasePaths or request a file inside an already-allowed one.","triggerScenarios":"A resource registration or read in the MCP resource registry resolves to a path outside the configured allowed directories.","commonSituations":"Occurs when a client requests a file:// resource with '..' segments or an absolute path that escapes the allowed roots, or when allowedDirectories is misconfigured.","solutions":["Normalize and resolve the requested path, then verify it starts with one of the configured allowed directories before accessing it.","Add the intended parent directory to the server's allowed directories configuration.","Reject paths containing '..' or symlinks that escape allowed roots at the trust boundary."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}