Summary
File Browser's path rules can deny a descendant while leaving its parent allowed. Recursive copy, rename and delete authorize only the root of the operation and then process the whole subtree, so an authenticated non-administrator can copy or rename an allowed parent to read denied descendants at the new location, or delete the parent to destroy them. Reported against v2.63.2 and verified at v2.63.21.
Details
http/resource.go checks the root of the operation only. resourcePatchHandler authorizes the two endpoints of a copy or rename:
if !d.Check(src) || !d.Check(dst) {
return http.StatusForbidden, nil
}
and resourceDeleteHandler resolves its target through files.NewFileInfo, whose checker validates that one path. The recursive work then runs with no checker at all:
case "copy":
...
return fileutils.Copy(d.user.Fs, src, dst, d.settings.FileMode, d.settings.DirMode)
err = d.RunHook(func() error {
return d.user.Fs.RemoveAll(r.URL.Path)
}, "delete", r.URL.Path, "", d.user)
fileutils.CopyDir, fileutils.MoveFile and RemoveAll walk the tree directly, so every descendant is copied, moved or removed regardless of the rules. Everywhere else the rules are applied per path: listings drop denied entries (files.FileInfo.readListing), direct access returns 403 (files.NewFileInfo), and the archive download walker checks each descendant (getFiles in http/raw.go).
PoC
Preconditions:
- The attacker is an authenticated non-administrator with the relevant file-operation permission on the parent directory.
- A rule denies one or more descendants while leaving the parent allowed.
- The destination of the copy or rename is allowed.
Steps:
- Deny
/copy-src/secret, /rename-src/secret and /delete-src/secret, leave the three parent directories accessible, and place a marker file in each denied directory.
- As the restricted user, request each denied descendant through the resource API. All three return
403.
PATCH /api/resources/copy-src/?action=copy&destination=/dst returns 200, and the marker is readable at its new path.
PATCH /api/resources/rename-src/?action=rename&destination=/moved returns 200, and the marker is readable at its new path.
DELETE /api/resources/delete-src/ returns 204, and the denied marker file no longer exists.
Impact
An authenticated user holding ordinary create, rename or delete permission can read, relocate or destroy files the rules deny them, defeating rule-based isolation for confidentiality and integrity alike.
Patches
Fixed in v2.63.22. Copy, rename and delete now walk the source tree — and the location that tree would land on — before mutating anything, and reject the whole operation with 403 if any path is denied. The walk consults the rules only: hiding dotfiles is a display preference, and must not stop a user from moving a directory that contains one.
Workarounds
None. Until you can upgrade, withhold create, rename and delete permission from users whose rules deny descendants of directories they may otherwise operate on.
References
Summary
File Browser's path rules can deny a descendant while leaving its parent allowed. Recursive copy, rename and delete authorize only the root of the operation and then process the whole subtree, so an authenticated non-administrator can copy or rename an allowed parent to read denied descendants at the new location, or delete the parent to destroy them. Reported against v2.63.2 and verified at v2.63.21.
Details
http/resource.gochecks the root of the operation only.resourcePatchHandlerauthorizes the two endpoints of a copy or rename:and
resourceDeleteHandlerresolves its target throughfiles.NewFileInfo, whose checker validates that one path. The recursive work then runs with no checker at all:fileutils.CopyDir,fileutils.MoveFileandRemoveAllwalk the tree directly, so every descendant is copied, moved or removed regardless of the rules. Everywhere else the rules are applied per path: listings drop denied entries (files.FileInfo.readListing), direct access returns 403 (files.NewFileInfo), and the archive download walker checks each descendant (getFilesinhttp/raw.go).PoC
Preconditions:
Steps:
/copy-src/secret,/rename-src/secretand/delete-src/secret, leave the three parent directories accessible, and place a marker file in each denied directory.403.PATCH /api/resources/copy-src/?action=copy&destination=/dstreturns200, and the marker is readable at its new path.PATCH /api/resources/rename-src/?action=rename&destination=/movedreturns200, and the marker is readable at its new path.DELETE /api/resources/delete-src/returns204, and the denied marker file no longer exists.Impact
An authenticated user holding ordinary create, rename or delete permission can read, relocate or destroy files the rules deny them, defeating rule-based isolation for confidentiality and integrity alike.
Patches
Fixed in v2.63.22. Copy, rename and delete now walk the source tree — and the location that tree would land on — before mutating anything, and reject the whole operation with
403if any path is denied. The walk consults the rules only: hiding dotfiles is a display preference, and must not stop a user from moving a directory that contains one.Workarounds
None. Until you can upgrade, withhold create, rename and delete permission from users whose rules deny descendants of directories they may otherwise operate on.
References