From: Simon Ruderich Date: Tue, 29 Sep 2026 06:14:02 +0000 (+0200) Subject: Update comment regarding O_NOFOLLOW X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=71f9a2d16b70d347c28c2f3d5e849adf8c26f917;p=safcm%2Fsafcm.git 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. --- 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