apache/beam · critical
error validating file path
Error message
error validating file path (%s, %s): %w
What it means
While iterating zip entries, extractJar calls validatePath(dest, file.Name) for every entry; this error wraps any path-validation failure with the destination and the offending entry name for context. It is the extractJar-level wrapper around the Zip Slip protection: an entry in the jar resolves outside the destination directory and cannot be safely extracted.
Solutions
- Stop using this jar; it failed the safe-extraction check.
- Identify the offending entry from the wrapped filename in the message.
- Re-obtain the jar from the official artifact repository.
- Rebuild the jar with relative entry paths if you control its creation.
Defensive patterns
Strategy: validation
Validate before calling
// Reject jars containing traversal entries before invoking extraction
r, err := zip.OpenReader(jarPath)
if err != nil { return err }
for _, f := range r.File {
if strings.Contains(f.Name, "..") || filepath.IsAbs(f.Name) {
return fmt.Errorf("jar contains unsafe entry %q", f.Name)
}
} Try / catch
err := expansionx.MakeJar(ctx, url, dest)
if err != nil && strings.Contains(err.Error(), "error validating file path") {
os.Remove(jarPath)
return fmt.Errorf("unsafe jar from %s rejected", url)
} Prevention
- Source jars only from trusted, checksum-verified repositories.
- Scan archive entry names for traversal patterns before use.
- Treat validation failures as supply-chain incidents, not retryable errors.
- Keep jar provenance (URL + checksum) recorded per pipeline.
When it happens
Trigger: An entry name in the jar contains ../ traversal segments, an absolute path, or otherwise fails filepath.Rel containment check during extractJar.
Common situations: A malicious or corrupted expansion-service jar; jars generated by tooling that wrote absolute entry paths; manually edited jars.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- file path is outside destination directory
- Cannot unzip file containing an entry with ".." in the…
- Refusing to serve " + filePath + " as it is not under " +…
- AfterProcessingTime trigger set without a delay or…
- array len mismatch. decoding
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/6c9b445f1672cccd.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go:167
return "", fmt.Errorf("file path %q is outside destination directory %q", filename, dest)
}
return cleanPath, nil
}
func extractJar(source, dest string) error {
reader, err := zip.OpenReader(source)
if err != nil {
return fmt.Errorf("error opening jar for extractJar(%s,%s): %w", source, dest, err)
}
if err := os.MkdirAll(dest, 0700); err != nil {
return fmt.Errorf("error creating directory %s in extractJar(%s,%s): %w", dest, source, dest, err)
}
for _, file := range reader.File {
fileName, err := validatePath(dest, file.Name)
if err != nil {
return fmt.Errorf("error validating file path (%s, %s): %w", dest, file.Name, err)
}
if file.FileInfo().IsDir() {
os.MkdirAll(fileName, 0700)
continue
}
sf, err := file.Open()
if err != nil {
return fmt.Errorf("error opening source file %s: %w", file.Name, err)
}
defer sf.Close()
df, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
return fmt.Errorf("error opening destination file %s: %w", fileName, err)
}
defer df.Close()
View on GitHub (pinned to 12126d8942)