musistudio/claude-code-router · error · Error
Input image is outside allowed roots: ${resolved}
Error message
Input image is outside allowed roots: ${resolved} What it means
After resolving symlinks and ~ expansion, each input image path must fall inside one of the runtime config's allowedInputRoots. This is a path-traversal guard: realpath resolution defeats ../ and symlink escapes, so only genuinely whitelisted locations are accepted.
Source
Thrown at packages/core/src/media/service.ts:526
}
private cleanup(): void {
const now = Date.now();
for (const job of this.jobStore.list()) {
if (job.artifact && Date.parse(job.artifact.expiresAt) <= now) this.artifactStore.delete(job.artifact);
}
for (const job of this.jobStore.deleteOlderThan(now - jobRetentionDays * 24 * 60 * 60 * 1000)) this.artifactStore.delete(job.artifact);
}
private validateImages(value: unknown, min: number, max: number): string[] {
const raw = typeof value === "string" ? [value] : Array.isArray(value) ? value : [];
if (raw.length < min || raw.length > max || raw.some((item) => typeof item !== "string" || !item.trim())) {
throw new Error(`images must contain between ${min} and ${max} local image paths.`);
}
const roots = mediaInputRoots(this.requireRuntimeConfig().allowedInputRoots);
return raw.map((item) => {
const resolved = realpathSync(expandHome(String(item).trim()));
if (!roots.some((root) => isPathInside(resolved, root))) throw new Error(`Input image is outside allowed roots: ${resolved}`);
const stats = statSync(resolved);
if (!stats.isFile() || stats.size <= 0 || stats.size > maxInputBytes) throw new Error(`Input image must be a non-empty regular file no larger than ${maxInputBytes} bytes.`);
if (!detectMediaType(resolved).mimeType?.startsWith("image/")) throw new Error(`Unsupported input image format: ${resolved}`);
return resolved;
});
}
private finishCanceled(job: MediaJob, message: string): MediaJob {
const next = this.jobStore.update(job.id, {
error: { code: "canceled", message, retryable: false },
finishedAt: new Date().toISOString(),
status: "canceled"
});
this.completions.get(job.id)?.resolve(next);
this.completions.delete(job.id);
return next;
}
View on GitHub (pinned to 99f24806c6)
Solutions
- Add the directory containing your images to allowedInputRoots in runtime config
- Move/copy images into an already-allowed root and pass the resolved path
- Use absolute real paths (no symlinks) pointing inside a whitelisted root
Example fix
// before
{ allowedInputRoots: ["/var/media"] }
// images: "/home/user/pic.png"
// after
{ allowedInputRoots: ["/var/media", "/home/user"] } Defensive patterns
Strategy: validation
Validate before calling
import { realpathSync } from "node:fs";
const resolved = realpathSync(inputPath);
if (!roots.some(r => isPathInside(resolved, r))) throw new Error("outside roots"); Type guard
const isInsideRoots = (p: string, roots: string[]): boolean => roots.some(r => !path.relative(path.resolve(r), path.resolve(p)).startsWith("..")); Try / catch
try { await call(); } catch (e) { if (e instanceof Error && e.message.includes("outside allowed roots")) return configError(); throw e; } Prevention
- Stage inputs under a whitelisted directory
- Resolve symlinks before passing paths
When it happens
Trigger: Passing an image path outside allowedInputRoots, or a path that resolves (via symlink or ~) to a location outside the whitelist.
Common situations: Default allowed roots don't include /tmp or the project dir; user home shorthand points elsewhere; images placed next to configs in a non-whitelisted directory.
Related errors
- No Bot Gateway conversationRef is available for media respon
- Artifact URL contains an invalid access token.
- The CCR artifact endpoint attempted a redirect.
- The CCR artifact endpoint returned a non-media content type.
- The CCR media artifact exceeds the inline preview size limit
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/467ac49aa27eba98.
Report an issue: GitHub.