CVE-2020-12062 Overview
CVE-2020-12062 is an improper input validation vulnerability affecting the SCP (Secure Copy Protocol) client in OpenSSH 8.2. The vulnerability allows a malicious unprivileged user on a remote server to overwrite arbitrary files in a client's download directory by exploiting how the SCP client handles duplicate responses after a utimes system call failure.
When a user connects to a compromised or malicious SSH server using the scp -rp command to recursively download files with preserved timestamps, an attacker who controls the remote server can craft a malicious subdirectory structure that triggers duplicate responses. This race condition enables the attacker to overwrite files in the victim's download directory.
Critical Impact
A malicious actor on a remote SSH server can overwrite arbitrary files in a client's download directory, potentially leading to code execution, data corruption, or configuration tampering on the victim's system.
Affected Products
- OpenBSD OpenSSH 8.2
Discovery Timeline
- 2020-06-01 - CVE-2020-12062 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2020-12062
Vulnerability Analysis
This vulnerability exploits a flaw in how the OpenSSH SCP client handles response acknowledgments to the server. When a utimes system call fails during a recursive copy operation with the -rp flags (recursive with preserved timestamps), the SCP client incorrectly sends duplicate responses to the server. This inconsistency creates an opportunity for exploitation.
The vulnerability is classified under CWE-20 (Improper Input Validation), as the client fails to properly validate and handle the state of file transfer operations during error conditions. An attacker with access to the remote server can create a specially crafted subdirectory structure that, when downloaded, triggers this duplicate response behavior and allows files to be written to unintended locations within the client's download directory.
It is worth noting that the OpenSSH vendor has indicated that this attack can achieve no more than what a hostile peer could already accomplish within the SCP protocol, and that utimes does not typically fail under normal circumstances. Nevertheless, the vulnerability represents a real security risk in scenarios involving potentially malicious servers.
Root Cause
The root cause lies in the SCP client's error handling logic when processing utimes system calls. Instead of properly managing the error state and sending a single appropriate response, the client sends duplicate responses to the server. This protocol violation creates an inconsistent state that can be exploited to manipulate file write operations during the recursive download process.
Attack Vector
The attack requires the following conditions:
- The victim must connect to a server controlled by or accessible to the attacker
- The victim must use the scp -rp command (recursive copy with preserved file timestamps)
- The attacker must have the ability to create directories on the remote server
- A utimes system call must fail during the transfer (which can be triggered through crafted directory structures)
The attacker creates a malicious subdirectory structure anywhere on the remote server. When the victim downloads a file hierarchy containing this crafted subdirectory, the duplicate response bug is triggered, allowing the attacker to redirect file writes to arbitrary locations within the victim's download directory.
Detection Methods for CVE-2020-12062
Indicators of Compromise
- Unexpected files appearing in SCP download directories after transfers from external servers
- File modification timestamps that don't match expected values after scp -rp operations
- Unusual directory structures created during SCP file transfers
- Log entries showing utimes failures during SCP operations
Detection Strategies
- Monitor SCP client operations for unusual file creation patterns in download directories
- Implement file integrity monitoring on directories commonly used as SCP destinations
- Review SSH client logs for unexpected error conditions during file transfers
- Deploy endpoint detection rules to identify files created outside expected directories during SCP operations
Monitoring Recommendations
- Enable verbose logging for SSH/SCP client operations with -v flags during suspicious transfers
- Implement baseline monitoring for critical directories that receive files via SCP
- Configure security tools to alert on unexpected file modifications following SCP transfers
- Audit systems for OpenSSH version 8.2 and flag for priority patching
How to Mitigate CVE-2020-12062
Immediate Actions Required
- Upgrade OpenSSH to version 8.3 or later, which contains the fix for this vulnerability
- Avoid using the -rp flags with scp when connecting to untrusted or potentially malicious servers
- Consider using rsync over SSH or sftp as alternatives to SCP for recursive file transfers
- Restrict SCP usage to trusted internal servers until patching is complete
Patch Information
OpenSSH addressed this vulnerability in version 8.3. The fix modifies how the SCP client handles responses after utimes failures to prevent duplicate responses from being sent to the server.
The following resources provide patch details:
Workarounds
- Use sftp instead of scp for secure file transfers, as it uses a different protocol not affected by this vulnerability
- Use rsync over SSH (rsync -avz -e ssh) as an alternative for recursive directory transfers
- Implement strict access controls on remote servers to limit the ability of unprivileged users to create arbitrary directory structures
- Validate the integrity of downloaded files using checksums after completing SCP transfers from less-trusted sources
# Check OpenSSH version and upgrade if necessary
ssh -V
# Alternative: Use sftp for secure transfers instead of scp
sftp -r user@remoteserver:/path/to/directory /local/destination/
# Alternative: Use rsync over SSH
rsync -avz -e ssh user@remoteserver:/path/to/directory /local/destination/
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


