fix(auth): isolate auto-provisioned proxy and hook users to their own home

Proxy- and hook-authenticated users were auto-provisioned by applying the
default scope (".") and passing it straight to MakeUserDir, which normalizes
"." to "/". With CreateUserDir enabled, every provisioned user therefore
received the server root as its scope instead of a per-user home directory,
letting one user read, overwrite and delete another user's files.

The signup handler already cleared the scope before deriving the home
directory. Centralize that logic into Settings.CreateUserHome (clear the
scope when CreateUserDir is on and no explicit scope was supplied, derive the
home dir, then reject a scope already owned by another user) and use it from
signup, proxy and hook auth so the three provisioning paths cannot diverge.

Refs GHSA-j7jh-37pf-mf8h, GHSA-j2fc-28fx-hc8q
This commit is contained in:
Henrique Dias committed 2026-07-25 08:16:15 +02:00
1 parent 9fffee387f
commit 8ddd3d1db9
4 files changed
+50 -36

No files matched your search

+2 -6
View File
@@ -50,15 +50,11 @@ func (a ProxyAuth) createUser(usr users.Store, setting *settings.Settings, srv *
user.Perm.Execute = false
user.Commands = []string{}
var userHome string
userHome, err = setting.MakeUserDir(user.Username, user.Scope, srv.Root)
if err != nil {
if err = setting.CreateUserHome(user, usr, srv.Root, false); err != nil {
return nil, err
}
user.Scope = userHome
err = usr.Save(user)
if err != nil {
if err = usr.Save(user); err != nil {
return nil, err
}