Security is fundamental to data synchronization tasks. A widely used open-source data synchronization tool, rsync, has recently been found to contain a critical vulnerability, which we will discuss in detail in this article. This vulnerability allows an attacker to potentially leak sensitive information and subsequently lead to privilege escalation. We will be examining the following aspects of this flaw:

Exploit details and mitigation strategies

What is rsync?
Rsync is a versatile, fast, and sophisticated command-line tool for synchronizing files across devices and platforms. It is widely used for backups, replication, and mirroring. Rsync uses a compression algorithm that transfers only the changes between source and target files, resulting in minimal data transfer and quick synchronization.

The Vulnerability: CVE-2024-12747
A flaw was recently uncovered in the rsync software, referred to as CVE-2024-12747. This vulnerability arises from a race condition while rsync handles symbolic links. Symbolic links are pointers to other files that are automatically resolved or followed by most software tools. By default, rsync skips symbolic links during synchronization to prevent potential security risks.

The cause of this vulnerability lies in the following code snippet

if (S_ISLNK(file->mode)) {
    if (link_dest || copy_links || copy_dirlinks) {
        // handling of links
    } else {
        // skipping symbolic links
    }
} else {
    // handling of regular files
}

When rsync encounters a symbolic link, it checks if the options link_dest, copy_links, or copy_dirlinks are enabled. If not, it skips the symbolic link. However, an attacker can exploit a race condition by replacing a regular file with a symbolic link at the right time, thereby bypassing the default check and traversing the symbolic link, potentially leaking sensitive information.

Original References

- Link to the original CVE report
- Rsync's official website
- Original mailing list discussion

Monitor the file system for the presence of an rsync process.

2. Once detected, the attacker replaces a regular file with a symbolic link that points to a sensitive file or folder.
3. If the timing is right, rsync will skip the check for symbolic links and copy the target of the link instead.

This exploit poses serious risks, especially if rsync is running with high privileges, as it allows unauthorized access to sensitive data and opens up the possibility of privilege escalation for the attacker.

Mitigation Strategies

To protect against this vulnerability, users and system administrators are advised to take the following precautions:

Avoid running rsync with elevated privileges whenever possible.

- Implement strict access control policies to limit the attacker's ability to replace files with symbolic links.

In conclusion, the rsync vulnerability, CVE-2024-12747, presents a severe risk. Timely patching and adhering to recommended security practices can help mitigate this threat.

Timeline

Published on: 01/14/2025 18:15:25 UTC
Last modified on: 03/15/2025 00:15:23 UTC