إرسال #1078351: https://github.com/cshum/ imagor commit be3e5ee9d177317ae2af29f780b343bb8230a873 Path Traversalالمعلومات

عنوانhttps://github.com/cshum/ imagor commit be3e5ee9d177317ae2af29f780b343bb8230a873 Path Traversal
الوصفPath traversal in FileStorage lets a caller-influenced image key escape the configured storage root Affected versions: confirmed on commit `be3e5ee9d177317ae2af29f780b343bb8230a873`. ## Summary `FileStorage.Path()`, used by both `FileStorage.Get()` (read) and `FileStorage.Put()` (write), fails to confine a caller-supplied image key to the configured base directory. Under imagor's documented default configuration (`-imagor-storage-path-style=original`), the image key used as this storage path is the request's own image path with no additional sanitization layer beyond `FileStorage.Path()` itself, and `FileStorage.Path()`'s traversal defense is ineffective against a leading `../` sequence. A key such as `../../../../etc/passwd` resolves to a path outside the configured storage directory for both read and write operations. ## Details `imagorpath.Normalize()` (`imagorpath/normalize.go:135-141`) is the only normalization step applied to the image key before `FileStorage.Path()` builds a filesystem path from it. `path.Clean()` only clamps `../` segments at the filesystem root when the input is itself a rooted (leading-`/`) path. Here the raw image key is cleaned *before* any `/` prefix is added, so a key like `../../../../etc/passwd` passes through `path.Clean` unchanged, survives `strings.Trim(image, "/")` unchanged (no leading/trailing slash to trim), and survives the escape step unchanged (`.` and `/` are both explicitly marked as safe/unescaped characters). `FileStorage.Path()` (`storage/filestorage/filestorage.go:50-60`) then adds the `/` prefix *after* this normalization has already run. With `PathPrefix` defaulting to `/`, the prefix check always passes once the leading `/` has been prepended, regardless of how many `../` segments follow it. `filepath.Join(s.BaseDir, ...)` then performs its own clean on the combined absolute path, which does resolve `../` segments - but by that point they resolve against the real filesystem root, climbing straight through `BaseDir` and out the other side, rather than being confined to it. Both of `FileStorage`'s interface methods (`Get` and `Put`) pass the image key through this same function with no additional check. By default configuration (`StoragePathStyle`/`ResultStoragePathStyle` both `nil` unless explicitly set to `digest`), the key used is the request's own image path verbatim, with no hashing. Reaching this with an attacker-chosen image key requires either (a) the server running with URL signing disabled (`-imagor-unsafe`, a documented, explicitly insecure dev-only mode), or (b) a deployment where an upstream, trusted caller constructs and signs imagor URLs using a filename that is itself derived from untrusted input (a common real-world integration pattern) without separately sanitizing that filename for `../` sequences, on the assumption that imagor's own storage layer is responsible for containing the key to its configured directory. This finding shows that assumption is false: imagor's URL signing authenticates that a request came from a trusted caller, but does not substitute for path containment within `FileStorage` itself. ## Steps To Reproduce (available upon request) ## Impact When `FileStorage` is configured as imagor's `Loader` (serving source images from local disk), a key containing `../` sequences lets a caller read any file on the host filesystem that the imagor process has permission to read (arbitrary file read). When `FileStorage` is configured as imagor's `Storage` or `ResultStorage` (the common disk-based result-cache setup), the same traversal lets a caller cause imagor to create directories and write a file at an attacker-chosen path outside the configured storage directory (arbitrary file write/overwrite). Both primitives require either `-imagor-unsafe` mode (explicitly insecure by the project's own documentation) or a deployment that signs imagor URLs using an image key derived from untrusted input without separately validating that key - a realistic and common integration pattern this storage layer should itself be defending against, independent of the signing layer. CWE-22 (Path Traversal). CVSS 3.1: `AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N` (9.3, Critical) for the arbitrary-file-write scenario; `AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N` (8.6, High) for the arbitrary-file-read scenario alone.
المصدر⚠️ https://github.com/cshum/imagor/issues/857
المستخدم
 carfeii (UID 97470)
ارسال06/11/2026 06:08 PM (22 أيام منذ)
الاعتدال29/11/2026 03:36 AM (22 days later)
الحالةتمت الموافقة
إدخال VulDB445148 [cshum imagor حتى 1.9.12 filestorage.go Path اجتياز الدليل]
النقاط20

Do you know our Splunk app?

Download it now for free!