]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.24] os: avoid escape from Root via paths ending in ../
authorDamien Neil <dneil@google.com>
Wed, 16 Apr 2025 18:01:19 +0000 (11:01 -0700)
committerCherry Mui <cherryyz@google.com>
Tue, 6 May 2025 17:29:09 +0000 (10:29 -0700)
commit8947f3395eb24dce6a5749517c0b40204b585f0a
tree2ad8e6cabf7a29ed9abfc8a9754da5364cd25845
parent06fd2f115b98dfa7fc0f1a9d451d2538b23e40fb
[release-branch.go1.24] os: avoid escape from Root via paths ending in ../

The doInRoot function operates on a path split into components.
The final path component retained any trailing path separator
characters, to permit operations in a Root to retain the
trailing-separator behavior of non-Root operations. However,
doInRoot failed to take trailing separators into account
when checking for .. path components.

This could permit opening the parent directory of the Root
with a path ending in "../".

Change the split path to never include path separators in
components, and handle trailing separators independently
of the split path.

Thanks to Dan Sebastian Thrane of SDU eScience Center for
reporting this issue.

Fixes #73556
Updates #73555
Fixes CVE-2025-22873

Change-Id: I9a33a145c22f5eb1dd4e4cafae5fcc61a8d4f0d4
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2160
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2180
Commit-Queue: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/670357
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/os/root.go
src/os/root_js.go
src/os/root_openat.go
src/os/root_test.go