ruvnet/ruflo · error · Error
Invalid file path: path traversal detected
Error message
Invalid file path: path traversal detected
What it means
Security guard in the file-resource handler: after path.normalize, the resolved path contains '..' or a null byte, i.e. it can escape the intended directory (path traversal). The read is refused before the filesystem is touched — reject user-supplied paths that traverse out of the base.
Source
Thrown at v3/@claude-flow/mcp/src/resource-registry.ts:494
}
): { resource: MCPResource; handler: ResourceHandler } {
const resource: MCPResource = {
uri,
name,
description: options?.description,
mimeType: options?.mimeType || 'application/octet-stream',
};
const handler: ResourceHandler = async () => {
const fs = await import('fs/promises');
const path = await import('path');
// SECURITY: Normalize and validate the path
const normalizedPath = path.normalize(filePath);
// Prevent path traversal
if (normalizedPath.includes('..') || normalizedPath.includes('\0')) {
throw new Error('Invalid file path: path traversal detected');
}
// Prevent access to sensitive system paths
const blockedPaths = ['/etc/', '/proc/', '/sys/', '/dev/', '/root/', '/var/log/'];
const lowerPath = normalizedPath.toLowerCase();
for (const blocked of blockedPaths) {
if (lowerPath.startsWith(blocked) || lowerPath.includes('/.')) {
throw new Error('Access to system paths is not allowed');
}
}
// If allowedBasePaths specified, validate against them
if (options?.allowedBasePaths && options.allowedBasePaths.length > 0) {
const resolvedPath = path.resolve(normalizedPath);
const isAllowed = options.allowedBasePaths.some((basePath) => {
const resolvedBase = path.resolve(basePath);
return resolvedPath.startsWith(resolvedBase);
});View on GitHub (pinned to fa13ee4ad6)
Solutions
- Remove '..' segments and absolute prefixes from the requested path; resolve within the allowed root.
- Validate user-supplied paths against the allowed base directory before requesting the resource.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at v3/@claude-flow/mcp/src/resource-registry.ts:494 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/ab18037d9c8506f7.
Report an issue: GitHub.