diegosouzapw/OmniRoute · error

Refusing to delete a path outside the plugin directory

Error message

Refusing to delete a path outside the plugin directory: "${t}" is not under "${root}"

What it means

assertWithinPluginDir security guard (CRITICAL-2): the resolved delete target is not contained under pluginRoot. Prevents a tampered/legacy DB pluginDir from turning uninstall/upgrade's rm({recursive:true}) into deletion of an arbitrary filesystem path.

Solutions

  1. Fix the pluginDir row in the DB to point inside the real plugin directory
  2. Delete the stray directory manually if it is genuinely misplaced
  3. Audit the DB for corrupted plugin paths before retrying
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/plugins/manager.ts:81 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/ae073a9e93c76722. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/plugins/manager.ts:81

  const [bMaj, bMin, bPat] = parse(b);
  if (aMaj !== bMaj) return aMaj - bMaj;
  if (aMin !== bMin) return aMin - bMin;
  return aPat - bPat;
}

// ── SECURITY: CRITICAL-2 ────────────────────────────────────────────────────
/**
 * Assert that `target` is strictly contained within `pluginRoot`.
 * Prevents a tampered/legacy DB `pluginDir` from causing deletion of an
 * arbitrary filesystem path when passed to `rm({ recursive: true })`.
 *
 * Throws immediately if `target` resolves outside `pluginRoot`.
 */
function assertWithinPluginDir(pluginRoot: string, target: string): void {
  const root = resolve(pluginRoot);
  const t = resolve(target);
  if (t !== root && !t.startsWith(root + sep)) {
    throw new Error(
      `Refusing to delete a path outside the plugin directory: "${t}" is not under "${root}"`
    );
  }
}

// ── SECURITY: CRITICAL-3 (shared) ──────────────────────────────────────────
/**
 * Assert that `entryPoint` is strictly within `destDir`.
 * Called at install/upgrade time to reject `manifest.main` values like
 * `"../../evil.js"` before the plugin is ever persisted to DB.
 *
 * Throws if the resolved entryPoint escapes `destDir`.
 */
function assertEntryPointWithinDest(destDir: string, entryPoint: string): void {
  const root = resolve(destDir);
  const ep = resolve(entryPoint);
  if (!ep.startsWith(root + sep)) {
    throw new Error(

View on GitHub (pinned to a179ffed5b)