From 71f9a2d16b70d347c28c2f3d5e849adf8c26f917 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 29 Sep 2026 08:14:02 +0200 Subject: [PATCH] Update comment regarding O_NOFOLLOW Go was bitten by this issue: CVE-2026-39822, https://github.com/advisories/GHSA-xcgv-8mv7-v8c7 On Unix systems, opening a file in an os.Root improperly follows symlinks to locations outside of the Root when the final path component of the a path is a symbolic link and the path ends in /. For example, 'root.Open("symlink/")' will open "symlink" even when "symlink" is a symbolic link pointing outside of the root. --- remote/sync/files.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/remote/sync/files.go b/remote/sync/files.go index 4ccca5d..d45bbfe 100644 --- a/remote/sync/files.go +++ b/remote/sync/files.go @@ -36,7 +36,8 @@ import ( // openReadonlyFlags are flags for open* syscalls to safely read a file or // directory. // -// O_NOFOLLOW prevents symlink attacks in the last path component +// O_NOFOLLOW prevents symlink attacks in the last path component (as long as +// it doesn't end in a slash!) // O_NONBLOCK is necessary to prevent blocking on FIFOs const openReadonlyFlags = unix.O_RDONLY | unix.O_NOFOLLOW | unix.O_NONBLOCK -- 2.56.1