CWE-22
Allowed-with-ReviewImproper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Abstraction: Base · Status: Stable
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.
14019 vulnerabilities reference this CWE, most recent first.
GHSA-7P22-FRC8-W9H8
Vulnerability from github – Published: 2026-03-06 15:31 – Updated: 2026-03-06 15:31Surreal ToDo 0.6.1.2 contains a local file inclusion vulnerability that allows unauthenticated attackers to read arbitrary files by manipulating the content parameter. Attackers can supply directory traversal sequences through the content parameter in index.php to access sensitive system files like configuration and initialization files.
{
"affected": [],
"aliases": [
"CVE-2018-25184"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-03-06T13:16:00Z",
"severity": "MODERATE"
},
"details": "Surreal ToDo 0.6.1.2 contains a local file inclusion vulnerability that allows unauthenticated attackers to read arbitrary files by manipulating the content parameter. Attackers can supply directory traversal sequences through the content parameter in index.php to access sensitive system files like configuration and initialization files.",
"id": "GHSA-7p22-frc8-w9h8",
"modified": "2026-03-06T15:31:29Z",
"published": "2026-03-06T15:31:29Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-25184"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/45826"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/surreal-todo-local-file-inclusion-via-indexphp"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-7P3M-8MRV-PVRF
Vulnerability from github – Published: 2022-05-01 23:46 – Updated: 2022-05-01 23:46Directory traversal vulnerability in index.php in Siteman 2.0.x2 allows remote authenticated administrators to include and execute arbitrary local files via a .. (dot dot) in the module parameter.
{
"affected": [],
"aliases": [
"CVE-2008-2081"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2008-05-05T17:20:00Z",
"severity": "HIGH"
},
"details": "Directory traversal vulnerability in index.php in Siteman 2.0.x2 allows remote authenticated administrators to include and execute arbitrary local files via a .. (dot dot) in the module parameter.",
"id": "GHSA-7p3m-8mrv-pvrf",
"modified": "2022-05-01T23:46:34Z",
"published": "2022-05-01T23:46:34Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-2081"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/42021"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/42022"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/5499"
},
{
"type": "WEB",
"url": "http://ircrash.com/english/index.php?topic=29.0"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/28943"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-7P4M-QXVV-G567
Vulnerability from github – Published: 2026-08-05 20:48 – Updated: 2026-08-05 20:48Summary
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": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 1.74.4"
},
"package": {
"ecosystem": "Go",
"name": "github.com/rclone/rclone"
},
"ranges": [
{
"events": [
{
"introduced": "1.51.0"
},
{
"fixed": "1.75.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-71313"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-08-05T20:48:46Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "## Summary\n\nThe 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\u0027s standard-encoded `\uff0e\uff0e` 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.\n\nAn 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.\n\nThe 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`.\n\nThis is not merely an odd filename-conversion result. The local remote\u0027s 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.\n\n## Affected Assets \u0026 Attack Surface\n\n### Confirmed affected versions\n\n- `v1.51.0` through `v1.74.4`\n- Local development commit tested: `a0c09f1381ae93e2a9a33c529d170186c61ad058`\n- Public `master` inspected through commit `c99b2d11edb0986cd2b1190e9fa25a58a3f12661` (2026-07-23)\n\n`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`.\n\n### Required destination configuration\n\nThe destination is a local backend whose effective encoding does not safely encode `.` and `..` components. Examples include:\n\n```text\n--local-encoding Slash\n--local-encoding None\n--local-encoding Raw\n```\n\nThe first PoC below uses `Slash`. Default configurations are not affected because the platform-specific `encoder.OS` masks include `Dot`.\n\nOn 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.\n\n### Attacker-controlled input\n\nThe relevant input is an object name returned by a source backend. The confirmed source case is S3:\n\n- `backend/s3/s3.go:2554` converts raw object keys to rclone\u0027s standard path representation with `f.opt.Enc.ToStandardPath`.\n- A raw `..` component becomes the standard component `\uff0e\uff0e`.\n- When the destination local encoder omits `Dot`, `FromStandardPath` decodes `\uff0e\uff0e` back to `..`.\n\nAmazon S3 permits relative path components when their left-to-right cumulative count does not exceed the preceding non-relative components. Consequently, an object named:\n\n```text\ntenant/../marker.txt\n```\n\nis valid. When the victim\u0027s 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.\n\n### Reachable operations\n\nThe unsafe path resolver is used throughout the local backend, including:\n\n- `backend/local/local.go:798` \u2014 `localPath`\n- `backend/local/local.go:803` \u2014 `Put`\n- `backend/local/local.go:979` \u2014 `Move`\n- `backend/local/local.go:1534` \u2014 `Object.Update`\n- `backend/local/local.go:1747` \u2014 `Object.Remove`\n- Local directory creation and object lookup operations that call `localPath`\n\nNormal copy and synchronization propagate the source name to the destination:\n\n- `fs/sync/sync.go:518` passes `src.Remote()` to `operations.Copy`.\n- `fs/operations/copy.go:390` uses that remote name for destination `Put` or `Update`.\n\nCommands that copy attacker-controlled source objects to a local destination are therefore in scope, including `copy`, `sync`, and `move`.\n\n## Technical Root Cause Analysis\n\nRclone 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:\n\n```text\n. -\u003e \uff0e\n.. -\u003e \uff0e\uff0e\n```\n\nWhen a standard path is converted for a destination backend, `lib/encoder/encoder.go:1214-1240` performs the following transformation for every path component:\n\n```go\nfunc FromStandardName(e Encoder, s string) string {\n\tif e == Standard {\n\t\treturn s\n\t}\n\treturn e.Encode(Standard.Decode(s))\n}\n```\n\nFor a destination encoding that omits `Dot`:\n\n1. `Standard.Decode(\"\uff0e\uff0e\")` returns `\"..\"`.\n2. The destination encoder leaves `\"..\"` unchanged.\n3. `FromStandardPath` returns a path containing an actual parent-directory component.\n\nThe local backend then constructs the native path without validating containment:\n\n```go\nfunc (f *Fs) localPath(name string) string {\n\treturn filepath.Join(f.root, filepath.FromSlash(f.opt.Enc.FromStandardPath(name)))\n}\n```\n\n`filepath.Join` cleans the resulting path. For example:\n\n```text\nroot: /tmp/destination\nname: ../marker.txt\nresult: /tmp/marker.txt\n```\n\n`Put` creates an object from `src.Remote()`, and `Object.Update` eventually opens that resolved path using:\n\n```go\nos.O_WRONLY | os.O_CREATE | os.O_TRUNC\n```\n\nThere is no subsequent `filepath.Rel` check, anchored filesystem operation, or rejection of an absolute, volume-qualified, `.` or `..` result.\n\nThe 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.\n\nThe 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.\n\n## Proof of Concept \u0026 Evidence\n\n### Deterministic regression test\n\nAdd the following test to the `backend/local` package. It requires no external storage service. It uses S3\u0027s actual default encoding mask to construct the same standard `Remote()` value that an S3 key with a relative `..` component produces.\n\n```go\npackage local\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/rclone/rclone/fs/config/configmap\"\n\t\"github.com/rclone/rclone/fs/object\"\n\t\"github.com/rclone/rclone/lib/encoder\"\n\t\"github.com/stretchr/testify/require\"\n)\n\nfunc TestLocalEncodingWithoutDotEscapesRoot(t *testing.T) {\n\tctx := context.Background()\n\touter := t.TempDir()\n\n\t// S3\u0027s default encoder converts a raw \"..\" object-key component\n\t// into rclone\u0027s standard fullwidth representation.\n\ts3Encoding := encoder.EncodeInvalidUtf8 | encoder.EncodeSlash | encoder.EncodeDot\n\tremote := s3Encoding.ToStandardPath(\"../marker.txt\")\n\trequire.NotEqual(t, \"../marker.txt\", remote)\n\n\t// The default local encoding includes Dot and keeps the path confined.\n\tsafeRaw, err := NewFs(ctx, \"safe\", filepath.Join(outer, \"safe\"),\n\t\tconfigmap.Simple{\"encoding\": encoder.OS.String()})\n\trequire.NoError(t, err)\n\tsafe := safeRaw.(*Fs)\n\trel, err := filepath.Rel(safe.root, safe.localPath(remote))\n\trequire.NoError(t, err)\n\trequire.False(t,\n\t\trel == \"..\" ||\n\t\t\tstrings.HasPrefix(rel, \"..\"+string(filepath.Separator)))\n\n\t// Removing Dot converts the same component to a real \"..\".\n\tunsafeRaw, err := NewFs(ctx, \"unsafe\", filepath.Join(outer, \"destination\"),\n\t\tconfigmap.Simple{\"encoding\": \"Slash\"})\n\trequire.NoError(t, err)\n\tunsafe := unsafeRaw.(*Fs)\n\n\t// Place an existing file outside the configured destination.\n\tescaped := filepath.Join(filepath.Dir(unsafe.root), \"marker.txt\")\n\trequire.NoError(t, os.WriteFile(escaped, []byte(\"original\"), 0600))\n\n\tpayload := \"attacker-controlled\"\n\tsrc := object.NewStaticObjectInfo(\n\t\tremote, time.Now(), int64(len(payload)), true, nil, nil)\n\n\t_, err = unsafe.Put(ctx, bytes.NewBufferString(payload), src)\n\trequire.NoError(t, err)\n\n\tgot, err := os.ReadFile(escaped)\n\trequire.NoError(t, err)\n\trequire.Equal(t, payload, string(got))\n}\n```\n\nRun:\n\n```text\ngo test ./backend/local -run \u0027^TestLocalEncodingWithoutDotEscapesRoot$\u0027 -count=1 -v\n```\n\nObserved result against commit `a0c09f1381ae93e2a9a33c529d170186c61ad058`:\n\n```text\n=== RUN TestLocalEncodingWithoutDotEscapesRoot\n--- PASS: TestLocalEncodingWithoutDotEscapesRoot\nPASS\n```\n\nThe test establishes both sides of the issue:\n\n- The default local encoding keeps the generated path under the root.\n- `encoding=Slash` causes `Put` to overwrite a pre-existing file outside the root.\n\n### Confirmed Windows backslash variant\n\nA second regression test was run on Windows using the standard remote name:\n\n```text\n..\\backslash-marker.txt\n```\n\nand a local destination configured with:\n\n```text\nencoding = Slash,Dot\n```\n\nThis 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`.\n\nThis variant demonstrates why rejecting only configurations that omit `Dot` is incomplete. The security check must run after conversion to the platform\u0027s native path representation.\n\n### S3 command-line reproduction\n\nPerform this test only with a disposable bucket and temporary local paths.\n\n```bash\nprintf \u0027attacker-controlled\\n\u0027 \u003e payload.txt\n\naws s3api put-object \\\n --bucket \"$BUCKET\" \\\n --key \u0027tenant/../rclone-traversal-marker.txt\u0027 \\\n --body payload.txt\n\nrm -rf /tmp/rclone-destination\nrm -f /tmp/rclone-traversal-marker.txt\nmkdir -p /tmp/rclone-destination\n\nrclone copy \\\n \"s3remote:${BUCKET}/tenant/\" \\\n /tmp/rclone-destination \\\n --local-encoding Slash \\\n -vv\n\ntest ! -e /tmp/rclone-destination/rclone-traversal-marker.txt\ntest -f /tmp/rclone-traversal-marker.txt\ngrep -F \u0027attacker-controlled\u0027 /tmp/rclone-traversal-marker.txt\n```\n\nExpected result:\n\n```text\n/tmp/rclone-traversal-marker.txt\n```\n\nis created outside:\n\n```text\n/tmp/rclone-destination\n```\n\nThe 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.\n\n## Impact Assessment\n\nThe direct impact is creation or overwrite of files outside the configured local destination as the rclone process user.\n\nRealistic consequences include:\n\n- Destruction or corruption of files accessible to the rclone account.\n- Modification of user startup files, application configuration, service data, or executable search paths.\n- Possible persistence or code execution in the rclone user\u0027s security context if the attacker can target a file that another component subsequently executes or loads.\n- Greater host impact when rclone runs as a privileged backup, synchronization, container, or system service account.\n\nDefault 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.\n\n## Remediation Guidance\n\n### Enforce containment after native-path conversion\n\nThe 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.\n\nRefactor `localPath`, or introduce a checked equivalent, so it can return an error. The check should:\n\n1. Convert the standard remote name using the configured local encoding.\n2. Convert separators to the native format.\n3. Reject any non-empty result for which `filepath.IsLocal` is false. This rejects absolute, volume-qualified, and lexically escaping paths using platform-aware rules.\n4. Join the result to `f.root`.\n5. Calculate `filepath.Rel(f.root, candidate)` using the normalized `f.root`, not the original user-supplied root string.\n6. Reject `rel == \"..\"`, any relative path beginning with `\"..\" + filepath.Separator`, and any absolute relative result.\n\nIllustrative logic:\n\n```go\nfunc (f *Fs) checkedLocalPath(remote string) (string, error) {\n\tnative := filepath.FromSlash(f.opt.Enc.FromStandardPath(remote))\n\n\t// Some root-level backend operations legitimately resolve the empty name.\n\tif native != \"\" \u0026\u0026 !filepath.IsLocal(native) {\n\t\treturn \"\", fmt.Errorf(\"invalid local object path %q: not a local relative path\", remote)\n\t}\n\n\tcandidate := filepath.Join(f.root, native)\n\trel, err := filepath.Rel(f.root, candidate)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid local object path %q: %w\", remote, err)\n\t}\n\tif filepath.IsAbs(rel) ||\n\t\trel == \"..\" ||\n\t\tstrings.HasPrefix(rel, \"..\"+string(filepath.Separator)) {\n\t\treturn \"\", fmt.Errorf(\"local object path %q escapes the configured root\", remote)\n\t}\n\treturn candidate, nil\n}\n```\n\nThis is illustrative rather than a complete patch. The implementation should account for the local backend\u0027s Windows UNC normalization and return an existing rclone path-validation error type if one is available.\n\nA 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.\n\n### Apply the check to every local filesystem entry point\n\nThe checked resolver must protect all operations that accept an `fs` remote name, not only `Put`. At minimum, review and update:\n\n- `NewObject` and object construction.\n- `Put`, `PutStream`, and `Update`.\n- `Mkdir`, `Rmdir`, and directory metadata operations.\n- `Move`, `DirMove`, and copy/rename helpers.\n- `Remove` and cleanup of failed or partial transfers.\n- Metadata and hash operations that resolve a remote name to a local path.\n\nIf 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.\n\n### Consider anchored filesystem operations\n\nThe 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.\n\nThis 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.",
"id": "GHSA-7p4m-qxvv-g567",
"modified": "2026-08-05T20:48:46Z",
"published": "2026-08-05T20:48:46Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/rclone/rclone/security/advisories/GHSA-7p4m-qxvv-g567"
},
{
"type": "WEB",
"url": "https://github.com/rclone/rclone/commit/6a69713864b1d8f6edbc03d8af735f9624576d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/rclone/rclone"
},
{
"type": "WEB",
"url": "https://github.com/rclone/rclone/releases/tag/v1.75.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:N/I:H/A:L",
"type": "CVSS_V3"
}
],
"summary": "rclone: Local Encoding Path Traversal"
}
GHSA-7P55-PV3F-9RR9
Vulnerability from github – Published: 2022-05-24 22:28 – Updated: 2022-05-24 22:28Corero SecureWatch Managed Services 9.7.2.0020 is affected by a Path Traversal vulnerability via the snap_file parameter in the /it-IT/splunkd/__raw/services/get_snapshot HTTP API endpoint. A ‘low privileged’ attacker can read any file on the target host.
{
"affected": [],
"aliases": [
"CVE-2021-38136"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2021-08-06T15:15:00Z",
"severity": "MODERATE"
},
"details": "Corero SecureWatch Managed Services 9.7.2.0020 is affected by a Path Traversal vulnerability via the snap_file parameter in the /it-IT/splunkd/__raw/services/get_snapshot HTTP API endpoint. A \u2018low privileged\u2019 attacker can read any file on the target host.",
"id": "GHSA-7p55-pv3f-9rr9",
"modified": "2022-05-24T22:28:23Z",
"published": "2022-05-24T22:28:23Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-38136"
},
{
"type": "WEB",
"url": "https://www.corero.com/blog/data-sheets-corero-securewatch-managed-services"
},
{
"type": "WEB",
"url": "https://www.shielder.it/advisories/corero_secure_watch_managed_services-get_snapshot-path-traversal"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-7P5M-CCCG-GQ8J
Vulnerability from github – Published: 2022-05-02 03:32 – Updated: 2025-04-09 04:11Directory traversal vulnerability in global.php in 4images before 1.7.7, when magic_quotes_gpc is disabled, allows remote attackers to include and execute arbitrary local files via directory traversal sequences in the l parameter.
{
"affected": [],
"aliases": [
"CVE-2009-2132"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2009-06-19T18:00:00Z",
"severity": "MODERATE"
},
"details": "Directory traversal vulnerability in global.php in 4images before 1.7.7, when magic_quotes_gpc is disabled, allows remote attackers to include and execute arbitrary local files via directory traversal sequences in the l parameter.",
"id": "GHSA-7p5m-cccg-gq8j",
"modified": "2025-04-09T04:11:11Z",
"published": "2022-05-02T03:32:07Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2009-2132"
},
{
"type": "WEB",
"url": "http://bbs.wolvez.org/topic/56"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/35427"
},
{
"type": "WEB",
"url": "http://www.4homepages.de/forum/index.php?topic=15186.0"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-7P7C-PVVX-2VX3
Vulnerability from github – Published: 2022-12-05 22:03 – Updated: 2022-12-05 22:03Path resolution in hyper-staticfile didn't correctly validate Windows paths, meaning paths like /foo/bar/c:/windows/web/screen/img101.png would be allowed and respond with the contents of c:/windows/web/screen/img101.png. Thus users could potentially read files anywhere on the filesystem.
This only impacts Windows. Linux and other unix likes are not impacted by this.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "hyper-staticfile"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.9.2"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "crates.io",
"name": "hyper-staticfile"
},
"ranges": [
{
"events": [
{
"introduced": "0.10.0-alpha.1"
},
{
"fixed": "0.10.0-alpha.2"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.10.0-alpha.1"
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2022-12-05T22:03:46Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "Path resolution in `hyper-staticfile` didn\u0027t correctly validate Windows paths, meaning paths like `/foo/bar/c:/windows/web/screen/img101.png` would be allowed and respond with the contents of `c:/windows/web/screen/img101.png`. Thus users could potentially read files anywhere on the filesystem.\n\nThis only impacts Windows. Linux and other unix likes are not impacted by this.\n",
"id": "GHSA-7p7c-pvvx-2vx3",
"modified": "2022-12-05T22:03:46Z",
"published": "2022-12-05T22:03:46Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/stephank/hyper-staticfile/issues/35"
},
{
"type": "WEB",
"url": "https://github.com/stephank/hyper-staticfile/pull/36"
},
{
"type": "WEB",
"url": "https://github.com/stephank/hyper-staticfile/commit/1e40e31d64bc6b32e595d24074092dcf84410b2b"
},
{
"type": "PACKAGE",
"url": "https://github.com/stephank/hyper-staticfile"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2022-0069.html"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "hyper-staticfile\u0027s improper validation of Windows paths could lead to directory traversal attack"
}
GHSA-7P7M-Q926-GVC3
Vulnerability from github – Published: 2025-03-26 12:30 – Updated: 2025-03-26 12:30The Product Import Export for WooCommerce – Import Export Product CSV Suite plugin for WordPress is vulnerable to Directory Traversal in all versions up to, and including, 2.5.0 via the download_file() function. This makes it possible for authenticated attackers, with Administrator-level access and above, to read the contents of arbitrary log files on the server, which can contain sensitive information.
{
"affected": [],
"aliases": [
"CVE-2025-1769"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-03-26T12:15:15Z",
"severity": "MODERATE"
},
"details": "The Product Import Export for WooCommerce \u2013 Import Export Product CSV Suite plugin for WordPress is vulnerable to Directory Traversal in all versions up to, and including, 2.5.0 via the download_file() function. This makes it possible for authenticated attackers, with Administrator-level access and above, to read the contents of arbitrary log files on the server, which can contain sensitive information.",
"id": "GHSA-7p7m-q926-gvc3",
"modified": "2025-03-26T12:30:34Z",
"published": "2025-03-26T12:30:34Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-1769"
},
{
"type": "WEB",
"url": "https://plugins.trac.wordpress.org/browser/product-import-export-for-woo/trunk/admin/modules/history/history.php#L753"
},
{
"type": "WEB",
"url": "https://plugins.trac.wordpress.org/changeset/3261194"
},
{
"type": "WEB",
"url": "https://wordpress.org/plugins/product-import-export-for-woo/#developers"
},
{
"type": "WEB",
"url": "https://www.wordfence.com/threat-intel/vulnerabilities/id/4df60fbe-4475-4cbf-b497-a9c5251bc91f?source=cve"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-7P7P-QRX2-WWHC
Vulnerability from github – Published: 2025-12-04 15:30 – Updated: 2025-12-04 15:30A vulnerability in VideoPlayer2 subtitle cgi allows remote authenticated users to read .srt files.
{
"affected": [],
"aliases": [
"CVE-2025-29845"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-12-04T15:15:56Z",
"severity": "MODERATE"
},
"details": "A vulnerability in VideoPlayer2 subtitle cgi allows remote authenticated users to read .srt files.",
"id": "GHSA-7p7p-qrx2-wwhc",
"modified": "2025-12-04T15:30:33Z",
"published": "2025-12-04T15:30:33Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-29845"
},
{
"type": "WEB",
"url": "https://www.synology.com/en-global/security/advisory/Synology_SA_25_04"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-7P7X-RFV5-5C5J
Vulnerability from github – Published: 2022-05-01 18:44 – Updated: 2022-05-01 18:44Directory traversal vulnerability in index.php in XZero Community Classifieds 4.95.11 and earlier allows remote attackers to include and execute arbitrary local files via a .. (dot dot) in the pagename parameter in a page view action.
{
"affected": [],
"aliases": [
"CVE-2007-6567"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2007-12-28T21:46:00Z",
"severity": "MODERATE"
},
"details": "Directory traversal vulnerability in index.php in XZero Community Classifieds 4.95.11 and earlier allows remote attackers to include and execute arbitrary local files via a .. (dot dot) in the pagename parameter in a page view action.",
"id": "GHSA-7p7x-rfv5-5c5j",
"modified": "2022-05-01T18:44:10Z",
"published": "2022-05-01T18:44:10Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2007-6567"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/39260"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/4794"
},
{
"type": "WEB",
"url": "http://en.rstzone.org/xzero-community-classifieds-v4-95-11-lfi-sql-in-t9394.rst"
},
{
"type": "WEB",
"url": "http://osvdb.org/39741"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/485545/100/0/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/27041"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-7PC7-HFXF-C22Q
Vulnerability from github – Published: 2024-08-13 12:30 – Updated: 2024-08-13 12:30Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability in Rashid87 WPSection allows PHP Local File Inclusion.This issue affects WPSection: from n/a through 1.3.8.
{
"affected": [],
"aliases": [
"CVE-2024-43165"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-08-13T12:15:07Z",
"severity": "MODERATE"
},
"details": "Improper Limitation of a Pathname to a Restricted Directory (\u0027Path Traversal\u0027) vulnerability in Rashid87 WPSection allows PHP Local File Inclusion.This issue affects WPSection: from n/a through 1.3.8.",
"id": "GHSA-7pc7-hfxf-c22q",
"modified": "2024-08-13T12:30:54Z",
"published": "2024-08-13T12:30:54Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-43165"
},
{
"type": "WEB",
"url": "https://patchstack.com/database/vulnerability/wpsection/wordpress-wpsection-plugin-1-3-8-contributor-limited-local-file-inclusion-vulnerability?_s_id=cve"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
]
}
Mitigation MIT-5.1
Strategy: Input Validation
- 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 be removed from the original string, but the remaining characters would still form the "../" string.
Mitigation MIT-15
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.
Mitigation MIT-20.1
Strategy: Input Validation
- 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
Mitigation MIT-4
Strategy: Libraries or Frameworks
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].
Mitigation MIT-29
Strategy: Firewall
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].
Mitigation MIT-17
Strategy: Environment Hardening
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.
Mitigation MIT-21.1
Strategy: Enforcement by Conversion
- 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.
Mitigation MIT-22
Strategy: Sandbox or Jail
- 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.
Mitigation MIT-34
Strategy: Attack Surface Reduction
- 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.
Mitigation MIT-39
- 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.
Mitigation MIT-16
Strategy: Environment Hardening
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.
CAPEC-126: Path Traversal
An adversary uses path manipulation methods to exploit insufficient input validation of a target to obtain access to data that should be not be retrievable by ordinary well-formed requests. A typical variety of this attack involves specifying a path to a desired file together with dot-dot-slash characters, resulting in the file access API or function traversing out of the intended directory structure and into the root file system. By replacing or modifying the expected path information the access function or API retrieves the file desired by the attacker. These attacks either involve the attacker providing a complete path to a targeted file or using control characters (e.g. path separators (/ or \) and/or dots (.)) to reach desired directories or files.
CAPEC-64: Using Slashes and URL Encoding Combined to Bypass Validation Logic
This attack targets the encoding of the URL combined with the encoding of the slash characters. An attacker can take advantage of the multiple ways of encoding a URL and abuse the interpretation of the URL. A URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An attacker will try to craft an URL with a sequence of special characters which once interpreted by the server will be equivalent to a forbidden URL. It can be difficult to protect against this attack since the URL can contain other format of encoding such as UTF-8 encoding, Unicode-encoding, etc.
CAPEC-76: Manipulating Web Input to File System Calls
An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.
CAPEC-78: Using Escaped Slashes in Alternate Encoding
This attack targets the use of the backslash in alternate encoding. An adversary can provide a backslash as a leading character and causes a parser to believe that the next character is special. This is called an escape. By using that trick, the adversary tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack.
CAPEC-79: Using Slashes in Alternate Encoding
This attack targets the encoding of the Slash characters. An adversary would try to exploit common filtering problems related to the use of the slashes characters to gain access to resources on the target host. Directory-driven systems, such as file systems and databases, typically use the slash character to indicate traversal between directories or other container components. For murky historical reasons, PCs (and, as a result, Microsoft OSs) choose to use a backslash, whereas the UNIX world typically makes use of the forward slash. The schizophrenic result is that many MS-based systems are required to understand both forms of the slash. This gives the adversary many opportunities to discover and abuse a number of common filtering problems. The goal of this pattern is to discover server software that only applies filters to one version, but not the other.