Skip to content

Commit ac0ac66

Browse files
committed
Cygwin: ACLs: don't allow special accounts as USER entry
While accounts from the BUILTIN, NT AUTHORITY, and NT SERVICE domains can be owner of a file, they are always treated as group entries if they show up as additional entrys in a Windows ACL. Consequentially, it shouldn't be possible to add or remove them as USER entry, for instance, via setfacl. Add a check to disallow BUILTIN, NT AUTHORITY, and NT SERVICE accounts as USER entries in a POSIX ACL. Fixes: bc444e5 ("Reapply POSIX ACL changes.") Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit 98112b9)
1 parent 5da6fdf commit ac0ac66

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

winsup/cygwin/release/3.6.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Fixes:
2020
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257783.html
2121

2222
- Fix reference counting when dlopen/dlclose a DLL with RTLD_NODELETE.
23+
24+
- Disallow accounts from the BUILTIN, NT AUTHORITY, NT SERVICE domains
25+
as USER entry in a POSIX ACL. Only allow USER_OBJ, GROUP_OBJ and GROUP.

winsup/cygwin/sec/acl.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,21 @@ set_posix_access (mode_t attr, uid_t uid, gid_t gid,
256256
}
257257
}
258258
if (!aclsid[idx])
259-
aclsid[idx] = sidfromuid (aclbufp[idx].a_id, &cldap);
259+
{
260+
struct passwd *pw = internal_getpwuid (aclbufp[idx].a_id, &cldap);
261+
if (pw)
262+
{
263+
/* Don't allow to pass special accounts as USER, only as
264+
USER_OBJ, GROUP_OBJ, or GROUP */
265+
#define BUILTIN "U-BUILTIN\\"
266+
#define NT_AUTH "U-NT AUTHORITY\\"
267+
#define NT_SVC "U-NT SERVICE\\"
268+
if (strncmp (pw->pw_gecos, BUILTIN, strlen (BUILTIN)) != 0
269+
&& strncmp (pw->pw_gecos, NT_AUTH, strlen (NT_AUTH)) != 0
270+
&& strncmp (pw->pw_gecos, NT_SVC, strlen (NT_SVC)) != 0)
271+
aclsid[idx] = (PSID) ((pg_pwd *) pw)->sid;
272+
}
273+
}
260274
break;
261275
case GROUP_OBJ:
262276
aclsid[idx] = group;

0 commit comments

Comments
 (0)