OpenSSH scp Insecure File Permission Vulnerability (CVE-2026-35385)
OpenSSH versions before 10.3 allow for the potential installation of setuid or setgid files when using scp to download files as root with the -O option (legacy SCP protocol) and without the -p option (preserve mode), contrary to user expectations.
OpenSSH, a suite of secure networking utilities based on the Secure Shell (SSH) protocol, is affected by a vulnerability (CVE-2026-35385) in versions prior to 10.3. The vulnerability arises when using the scp command to download files as the root user with the -O (legacy SCP protocol) option and without the -p option (preserve mode). In this specific scenario, the downloaded file may be inadvertently installed with the setuid or setgid bits set. This behavior contradicts the expectations of some users, potentially leading to privilege escalation or other security misconfigurations. The vulnerability was publicly disclosed on April 2, 2026.
Attack Chain
- Attacker gains access to a system where a user has
scpinstalled and configured to connect to a remote server. - The user, operating as root, initiates an
scpdownload using the commandscp -O user@host:/path/to/file /local/path/. The-poption is omitted, and the-Oflag is used, triggering the legacy SCP protocol. - The remote server serves the file
/path/to/file. This file could have the setuid or setgid bits set. scp, due to the vulnerability, incorrectly handles the file permissions during the download process.- The downloaded file is placed at
/local/path/with the setuid or setgid bits unexpectedly preserved from the remote server. - A local user executes the downloaded file
/local/path/. - If the setuid or setgid bit is set, the process executes with elevated privileges, potentially leading to unauthorized access or modification of system resources.
Impact
Successful exploitation of this vulnerability can lead to unintended privilege escalation on the affected system. If a user downloads a file with the setuid bit set, an attacker could potentially execute the file with the privileges of the file owner (typically root). While the vulnerable scenario requires the user to be root and explicitly use the -O flag without -p, it can still represent a significant risk in environments where legacy SCP usage is prevalent or where users are unaware of the implications of these options. This scenario may affect a limited number of users who are using the specific vulnerable configuration.
Recommendation
- Upgrade OpenSSH to version 10.3 or later to patch the vulnerability (https://www.openssh.org/releasenotes.html#10.3p1).
- Avoid using the
-Ooption (legacy SCP protocol) withscp, especially when downloading files as the root user. Usesftporrsyncas a more secure alternative. - Always use the
-poption to preserve file permissions when downloading files withscpto ensure that the downloaded file’s permissions are explicitly controlled. - Deploy the Sigma rule provided below to detect the usage of
scpwith the-Oflag, which is indicative of using the vulnerable legacy protocol.
Detection coverage 2
Detect scp Usage with Legacy Protocol Option (-O)
lowDetects the use of scp command with the -O option, indicating the use of the legacy SCP protocol, which is related to CVE-2026-35385.
Detect scp Usage without Preserving Permissions (-p)
lowDetects the use of scp command without the -p option, which may lead to unintended permission issues. This can amplify the risk of CVE-2026-35385 if combined with the -O option.
Detection queries are kept inside the platform. Get full rules →