diegosouzapw/OmniRoute · error · Error

Invalid path: directory traversal detected

Error message

Invalid path: directory traversal detected

What it means

Error "Invalid path: directory traversal detected" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/shared/services/backupService.ts:16

import fs from "fs/promises";
import path from "path";
import { resolveDataDir } from "@/lib/dataPaths";

const BACKUP_DIR = path.join(resolveDataDir(), "backups");
const MAX_BACKUPS_PER_TOOL = 5;

/**
 * Resolve a path within BACKUP_DIR and verify it stays within bounds.
 * Throws if the resolved path escapes BACKUP_DIR (path traversal guard).
 */
function safePath(...segments: string[]): string {
  const resolved = path.resolve(BACKUP_DIR, ...segments);
  const base = path.resolve(BACKUP_DIR);
  if (resolved !== base && !resolved.startsWith(base + path.sep)) {
    throw new Error("Invalid path: directory traversal detected");
  }
  return resolved;
}

/**
 * Get backup directory for a specific tool
 */
function getToolBackupDir(toolId: string) {
  return safePath(toolId);
}

/**
 * Ensure backup directory exists for a tool
 */
async function ensureBackupDir(toolId: string) {
  const dir = getToolBackupDir(toolId);
  await fs.mkdir(dir, { recursive: true });
  return dir;

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/shared/services/backupService.ts:16 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/eee19f71ff3e745a. Report an issue: GitHub.