googleapis/mcp-toolbox · error
path %q escapes configured directory %q
Error message
path %q escapes configured directory %q
What it means
Path-containment guard in ResolveWithinDir: after joining, the cleaned destination starts with '..' or is absolute relative to the configured directory, so writing/reading there would escape destination_dir (classic traversal such as '../../etc/passwd').
Source
Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:141
func ResolveWithinDir(dir, rel string) (string, error) {
cleanDir, err := ValidateLocalPath(dir)
if err != nil {
return "", fmt.Errorf("directory %q is invalid: %w", dir, err)
}
if rel == "" {
return "", fmt.Errorf("relative path is empty")
}
if filepath.IsAbs(rel) {
return "", fmt.Errorf("path %q must be relative", rel)
}
cleanDest := filepath.Clean(filepath.Join(cleanDir, rel))
out, err := escapes(cleanDir, cleanDest)
if err != nil {
return "", fmt.Errorf("path %q cannot be resolved within %q: %w", rel, cleanDir, err)
}
if out {
return "", fmt.Errorf("path %q escapes configured directory %q", rel, cleanDir)
}
// Repeat the check against the real targets. A symlink under cleanDir can
// point anywhere, so the name-level check above proves nothing on its own.
resolvedDir, err := ResolveSymlinks(cleanDir)
if err != nil {
return "", fmt.Errorf("directory %q cannot be resolved: %w", cleanDir, err)
}
resolvedDest, err := ResolveSymlinks(cleanDest)
if err != nil {
return "", fmt.Errorf("path %q cannot be resolved: %w", rel, err)
}
out, err = escapes(resolvedDir, resolvedDest)
if err != nil {
return "", fmt.Errorf("path %q cannot be resolved within %q: %w", rel, cleanDir, err)
}
if out {
return "", fmt.Errorf("path %q resolves through a symbolic link to a target outside configured directory %q", rel, cleanDir)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Remove '..' sequences and use a plain path relative to destination_dir
- If the file legitimately lives elsewhere, extend destination_dir rather than traversing out of it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:141 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/1d026774d22be191.
Report an issue: GitHub.