Details
The dangling test "fails" by design: the assertion fires because the file escaped. The control test passes: an escape_link -> outside (existing dir) write to escape_link/injected.txt is rejected by OpenFile with permission denied and nothing is created in outside/. That is exactly the scenario the project's own tests cover.
End-to-end HTTP equivalent:
POST /api/resources/escape?override=true
X-Auth: <token for user scoped to /tmp/root/scope with Create+Modify>
body: http-outside
-> ScopedFs.OpenFile("/escape", O_CREATE|O_TRUNC) follows the dangling link
-> file created at the link's out-of-scope target with the request body
The handler returns 200 OK, and the outside file contains the uploaded body.
Impact
- Direct primitive (live-verified): arbitrary file creation with attacker-controlled content at any non-existent path outside the user's scope that the File Browser process user can write to.
- Cross-tenant integrity (source-reasoned): in multi-user deployments the scopes are sibling directories under one server root. A low-priv user can plant files into another user's home (a script, an HTML page later served, a config the victim trusts).
- Persistence / RCE on permissive deployments (source-reasoned): creating a not-yet-existent
~/.ssh/authorized_keysfor the service account, a file under a web-served or later-executed directory, a cron or profile fragment. The official Docker image runs as non-root UID 1000, which bounds this to whatever that user owns. Bare-metal/systemd deployments that run File Browser as root raise this to host-level file write and RCE. - Scope limit (honest): this is file creation, not overwrite. Overwriting an existing out-of-scope file is genuinely blocked, because an existing target makes the link "escaping" and
within()rejects it. The negative control confirms this.
Suggested remediation
For write/create/truncate operations, do not treat a dangling final symlink as safe merely because the nearest existing ancestor is inside the scope. The walk-up in within() should treat "the leaf is a symlink" as an escape candidate rather than validating its parent:
- In
guard()/within(),Lstatthe target. If it is a symlink,Readlinkit, resolve the link target lexically (join with the link's directory,Clean), and require that target to be within the scope root, regardless of whether it currently exists. - More robust: resolve path components one by one for the operation being attempted, or open the final component with
O_NOFOLLOW(unix.Openat(... O_NOFOLLOW)) so creating through a symlink fails withELOOP; orfstatthe descriptor after opening and verify it resolves within the scope before writing.
Add a regression test mirroring TestTusHandlersRejectSymlinkScopeEscape but with a dangling target (os.Symlink(filepath.Join(outside, "newfile"), ...)), asserting both a 4xx and that no file is created outside the scope.
References
- Incomplete fix of CVE-2026-54094 /
GHSA-239w-m3h6-ch8v. - Affected code:
files/scoped.go(ScopedFs.within,ScopedFs.OpenFile,ScopedFs.Create), reached fromhttp/resource.go(resourcePostHandler,writeFile) andhttp/tus_handlers.go. - Confirmed unpatched at
be23ab3a15bf957928ecfed88de5ab67850c1b9c(v2.63.15).