From 2711281ce4f64f399c50c655d3df3497197fe3dd Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 16 Sep 2026 15:05:25 +0000 Subject: [PATCH] util/winutil/s4u: log when a logon uses the linked administrator token Whether Login swaps a UAC-filtered token for its linked full token depends on the account: the built-in Administrator is never filtered, domain accounts' network logons are not filtered, and other local Administrators members are. Log which happened, and any failure to get the linked token, so a session running with fewer rights than expected can be explained from the log. Updates #4697 Signed-off-by: Brad Fitzpatrick Change-Id: I2c4e6a8b0d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c --- util/winutil/s4u/s4u_windows.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/util/winutil/s4u/s4u_windows.go b/util/winutil/s4u/s4u_windows.go index d25aa1ced..395449bfd 100644 --- a/util/winutil/s4u/s4u_windows.go +++ b/util/winutil/s4u/s4u_windows.go @@ -135,7 +135,7 @@ func Login(logf logger.Logf, srcName string, u *user.User, capLevel CapabilityLe return nil, err } if capLevel == CapCreateProcess { - token = maybeLinkedToken(token) + token = maybeLinkedToken(logfOrDiscard(logf), u, token) } tokenCloseOnce := sync.OnceFunc(func() { token.Close() }) defer func() { @@ -193,15 +193,25 @@ func Login(logf logger.Logf, srcName string, u *user.User, capLevel CapabilityLe // UAC-filtered token, closing token, and otherwise returns token unchanged. // The caller must hold SeTcbPrivilege for the linked token to be a usable // primary token rather than an identification-level one. -func maybeLinkedToken(token windows.Token) windows.Token { +// +// UAC filters the logon of a local Administrators member other than the +// built-in Administrator (see LocalAccountTokenFilterPolicy); domain +// accounts' network logons are not filtered, so for them this is a no-op. +func maybeLinkedToken(logf logger.Logf, u *user.User, token windows.Token) windows.Token { limited, err := winutil.IsTokenLimited(token) - if err != nil || !limited { + if err != nil { + logf("(s4u) IsTokenLimited(%q): %v", u.Username, err) + return token + } + if !limited { return token } linked, err := token.GetLinkedToken() if err != nil { + logf("(s4u) GetLinkedToken(%q): %v; using the UAC-filtered token", u.Username, err) return token } + logf("(s4u) using the linked (unfiltered) administrator token for %q", u.Username) token.Close() return linked }