🧱 Chunk is a download manager for slow and unstable servers

Percent-encoded separators allow path traversal out of the output directory #11

Open cuducos.me
Open opened by cuducos.me

Problem

filepath.Base runs before url.PathUnescape (downloader.go:321). A URL ending in %2f..%2f.. segments unescapes to ../.., so filepath.Join(OutputDir, name) escapes the output directory and writes the file elsewhere.

Impact

Files can be written outside OutputDir — a path-traversal write.

Reproduction (verified)

A crafted URL landed a file in the parent of OutputDir.

Suggested fix

Sanitize after unescaping: reject path separators and .. segments in the derived name.

Sign up or Sign in to add to the discussion.