-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The function's name says sandbox. The function's body says normalize.\n\nPre-patch `storage/local_file_system.go`:\n\n```go\nfunc (sp LocalFileSystemProvider) GetFullPath(path string) string {\n fullPath := path\n if !strings.HasPrefix(path, sp.BaseDir) {\n fullPath, _ = filepath.Abs(filepath.Join(sp.BaseDir, path))\n }\n return fullPath\n}\n```\n\nThe intent in code: if the caller's `path` already starts with `BaseDir`, trust it as already inside. Otherwise, glue the caller's `path` onto `BaseDir` and take the absolute form.\n\nThe \"glue it onto `BaseDir`\" call is `filepath.Join`. The Go standard library documents what `Join` does: \"Join joins any number of path elements into a single path... The result is Cleaned.\" And what `Clean` does: \"Eliminate each inner `..` path name element along with the non-`..` element that precedes it.\"\n\n`filepath.Join(\"/app/files\", \"../../../../../../etc/passwd\")` returns `/etc/passwd`. Six `..` segments walk back through six non-`..` segments; everything before `etc/passwd` is consumed; the resulting path is absolute and lives outside `BaseDir`. The function has run as designed. The documentation explains the design.\n\n`filepath.Abs` then runs on `/etc/passwd`. `Abs` returns the absolute representation of a path. `/etc/passwd` is already absolute. `Abs` is a no-op.\n\nThe function returns `/etc/passwd`. The upload handler writes there. The handler does not verify after the fact. It does not need to. The handler trusts the function whose job is to put the file in the sandbox.\n\n## Both branches of the if-statement are exploitable.\n\nRead the function again with adversarial eyes. There are two branches.\n\nThe first branch: `path` already starts with `BaseDir`. The function trusts the caller and returns `path` verbatim, no normalization, no resolution. A caller who supplies `files/../../../../etc/passwd` satisfies `HasPrefix(path, \"files/\")`, the function returns the input string unchanged, and the kernel's `open(2)` resolves `..` at write time. The \"is this path already inside BaseDir\" check uses the same string the attacker controls; satisfying the check is a prefix away.\n\nThe second branch: `path` does not start with `BaseDir`. The function joins under `BaseDir` and absolutizes. This is the `filepath.Join` path described above.\n\nTwo branches, two bypasses. The `HasPrefix` check is itself the trust boundary; the attacker chooses which side of it to be on, and both sides write outside `BaseDir`. The function has no third branch.\n\n## The PoC supplies two inputs. The function distinguishes neither.\n\n`GetFullPath` takes one string. That string is composed upstream from two attacker-controllable sources:\n\n1. The storage provider's `PathPrefix`, set by an authenticated administrator at provider creation time via `/api/add-provider` and `/api/update-provider`.\n2. The `fullFilePath` query parameter, sent by the caller on each `/api/upload-resource` request.\n\nThe PoC writes both. Provider creation, from `CVE-2026-6815.py`:\n\n```python\nprovider_payload = {\n \"owner\": \"admin\",\n \"name\": \"path_traversal\",\n \"type\": \"Local File System\",\n \"method\": \"Normal\",\n \"pathPrefix\": \"../../../../../../../../../\"\n}\nsession.post(f\"{target_url}/api/add-provider\",\n data=json.dumps(provider_payload), ...)\n```\n\nFile upload:\n\n```python\nupload_params = {\n \"owner\": args.orgname,\n \"user\": args.usr,\n \"application\": args.appname,\n \"tag\": \"custom\",\n \"parent\": \"ResourceListPage\",\n \"fullFilePath\": args.rpath, # e.g. /home/casdoor/.ssh/authorized_keys\n \"provider\": \"path_traversal\"\n}\n```\n\nBoth inputs flow downward into the same `GetFullPath`. The function does not know that one was supposed to be administrative configuration and the other was supposed to be a per-call file path. The function sees a string. The function calls `Join`. `Join` cleans.\n\nThe PoC's README leads with \"the attacker must be authenticated with admin privileges.\" The PoC's defaults are `--usr admin --psw 123`, the credentials Casdoor ships out of the box and that operators forget to rotate. The architectural read of the bug is \"admins can configure storage providers, so admins can write where storage providers write.\" The code read is that the storage provider has not been told where it is allowed to write. The admin role gates the API surface. The function `GetFullPath` is not on that surface; it gates nothing.\n\n## The patch is the function the author should have written the first time.\n\nCommit `fc03a30`, by maintainer `hsluoyz`:\n\n```go\nfunc (sp LocalFileSystemProvider) GetFullPath(path string) string {\n fullPath := filepath.Clean(filepath.Join(sp.BaseDir, path))\n sandboxRoot := sp.BaseDir + string(filepath.Separator)\n if fullPath != sp.BaseDir && !strings.HasPrefix(fullPath, sandboxRoot) {\n return sp.BaseDir\n }\n return fullPath\n}\n```\n\nThe diff is small. The reframe is large.\n\nThe `if !strings.HasPrefix(path, sp.BaseDir)` branch is gone. There is no \"trust the caller already prefixed `BaseDir`\" path. Every input is normalized; every input is checked. `filepath.Clean` is called. `filepath.Join` is called. The traversal still gets resolved. What changes is what happens after: ask whether the resulting path is `BaseDir` itself, or lives strictly under `BaseDir + Separator`. If neither, fall back to `BaseDir`. The result is no longer \"wherever `filepath.Join` landed\"; the result is \"a path reachable from `BaseDir` without first leaving `BaseDir`.\"\n\nThis is what sandboxing-by-Join requires. The Go standard library does not provide a single-call sandbox helper. It provides `filepath.Clean`, `filepath.Join`, `filepath.Abs`, and `filepath.Rel`. The sandbox is a composition: join, clean, verify the result lives under the base. The pre-patch code reached for the piece that sounded like a sandbox and stopped one step short of being one.\n\n## The researcher fixed one layer. The maintainer fixed two and refined the first.\n\nThe same commit changes `object/provider.go`. Both `AddProvider` and `UpdateProvider` now reject a `PathPrefix` containing any `..` path component, gated on the provider type:\n\n```go\nif provider.Type == ProviderTypeLocalFileSystem {\n for _, component := range strings.Split(provider.PathPrefix, \"/\") {\n if component == \"..\" {\n return false, fmt.Errorf(\"the pathPrefix: %s is not allowed\", provider.PathPrefix)\n }\n }\n}\n```\n\nThe researcher's original pull request (#5458, opened the same day as the public PoC) had used `strings.Contains(provider.PathPrefix, \"..\")`. The maintainer rewrote it as a per-component check, gated on the storage type. The two are not equivalent. `strings.Contains` rejects every two-dot substring, including legitimate filenames like `..hidden` and directories with two dots in their names. The component check rejects only path components that are exactly `..`. The type guard exists because providers like S3, Azure, and OSS have their own `pathPrefix` semantics where `..` is a valid object-key character; rejecting it globally would corrupt them.\n\n`PathPrefix` and `fullFilePath` are two separate inputs that flow into the same function with the same (zero) post-conditions. Closing one input leaves the other open. The maintainer closed both.\n\nThe PR was not merged. Its status reads \"closed; replaced by `fc03a30`.\" The PoC repo ships the researcher's framing as gospel. The fix on disk is the maintainer's, and they are not the same patch.\n\n## An identity product's storage component had no identity in it.\n\nCasdoor is an OAuth and SSO identity provider. The product's job description is \"who can act with what authority.\" The storage backend that ships in the box takes a base directory and a per-call path and writes the file there. The function deciding where the file goes never asked whose authority it was running under and never asked whether the resulting path was a place authority extended to.\n\nThat is not a strange omission. Access control in an identity product lives at the API layer, not the storage layer. But the destination here is caller-controlled all the way down. The IdP's threat model trusted admins with identity. The storage backend treated admin-controlled input the same way it would treat any other input, which is to say, completely.\n\nThere is a name for this shape now: **Join Is Not Sandbox**. The Go standard library does not ship a \"scope this path to that directory\" call; the project that needs one has to compose it from `Clean`, `Join`, and either `Rel` or an explicit prefix check on `BaseDir + Separator`. `GetFullPath`, pre-patch, composed `filepath.Join` with `filepath.Abs` and called the composition a sandbox. Neither of those calls is one. Together they are not one. The patch is the line that finally is.\n\nPoC: [danilo-dellorco/CVE-2026-6815](https://github.com/danilo-dellorco/CVE-2026-6815)","closing_line":"`filepath.Join` is not a sandbox. The function that read it as one shipped as Casdoor's storage layer.","hook_md":"Casdoor's `LocalFileSystemProvider.GetFullPath` is the function that converts a caller-supplied path into the absolute disk location where the upload handler writes. Its job, in plain English, is one sentence: prefix the caller's path with the storage provider's `BaseDir` so the file lands inside the sandbox. The pre-patch implementation did exactly that.\n\nIt called `filepath.Join`.\n\n`filepath.Join` is documented to clean `..` segments from the joined path. The line that scoped the path was the line that let the path escape. CVE-2026-6815 is what that costs.","post_id":556,"slug":"casdoor-cve-2026-6815-getfullpath-joined-the-path-out","title":"CVE-2026-6815: Casdoor's GetFullPath Joined the Path Out of the Sandbox","type":"initial","unreadable_sentence":"The line that scoped the path was the line that let the path escape."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawo31wAKCRDeZjl4jgkQ JuZtAP0UfYV++jPoC59+AL/WfGj9OCWdWEJ2DpPKmJZyJs0HkwEAl0nwJBcMcoR4 270brOhXQXhBLv7IDvrDPi3fJawqgQg= =AhY8 -----END PGP SIGNATURE-----