From 6bac5068423972e82cb4e50acde67f1c9ce36202 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 11 Oct 2026 20:18:29 -0700 Subject: [PATCH] sftp: terminate the missing-ancestor permission walk at the root A path whose ancestors are all absent recursed on the root forever, since Dir("/") is "/". Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- weed/sftpd/sftp_permissions.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weed/sftpd/sftp_permissions.go b/weed/sftpd/sftp_permissions.go index 8eea53f60..1a3210783 100644 --- a/weed/sftpd/sftp_permissions.go +++ b/weed/sftpd/sftp_permissions.go @@ -67,6 +67,9 @@ func (fs *SftpServer) CheckFilePermission(path string, perm string) error { // check permissions on the parent directory instead if err == os.ErrNotExist { parentPath := stdpath.Dir(path) + if parentPath == path { + return os.ErrPermission + } // Check if user can write to the parent directory return fs.CheckFilePermission(parentPath, perm) }