The vulnerability is a path traversal issue in SFTPGo versions prior to 2.7.1. It stems from a discrepancy in how file paths are normalized between the protocol handlers (SFTP, FTP) and the underlying virtual filesystem (VFS).
Authenticated attackers could craft malicious paths using a mix of forward slashes (/), backslashes (\\), and directory traversal sequences (..). The protocol handlers would pass these un-sanitized paths to the VFS layer. The VFS routing logic, which determines which filesystem backend to use (e.g., local, S3, GCS), could interpret the path differently than the permission checking logic, leading to an authorization bypass. This allowed an attacker to access files or directories outside of their designated home directory or virtual folder, effectively bypassing folder-level permissions.
The patch, identified in commit 2f092d128917e2c059520a2ce3e22c3b5ea7ffd6, addresses this by moving the path sanitization to the "edge" – the very beginning of the protocol handler functions. The fix involves consistently converting all backslashes to forward slashes and then cleaning the path (e.g., resolving .. components) using a new util.CleanPath function before any further processing, such as permission checks or VFS routing, takes place.
The vulnerable functions are the methods within the FTP (internal/ftpd/handler.go) and SFTP (internal/sftpd/handler.go) connection handlers that accept file paths as input from the user. These functions were modified to include calls to util.CleanPath or the new updateRequestPaths helper function as the first step in their execution.