You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

非管理员用户可创建Global互斥对象的原因及异常排查

全局互斥对象创建权限异常排查

问题背景

SeCreateGlobalObjects权限默认授予Administrators、Service、Local Service及Network Service账户。按预期,创建无管理员权限的本地测试用户后,通过runas /user:testuser cmd.exe启动shell并运行MutexTest程序时,应触发System.UnauthorizedAccessException,但实际创建Global互斥对象成功。

通过SystemInformer确认,该测试用户未启用SeCreateGlobalObjects权限,因此产生疑问:为何无此权限仍能创建Global对象?

测试代码(MutexTest)

using System.Security.AccessControl;
using System.Security.Principal;

namespace MutexTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var rule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
            var mutexSecurity = new MutexSecurity();
            mutexSecurity.AddAccessRule(rule);
            
            var mutex = new Mutex(false, $"Global\\TestlollMutex{new Random().Next()}", out bool createdNew);
            if(createdNew)
            {
                Console.WriteLine("Allowing everyone access to mutex");
                mutex.SetAccessControl(mutexSecurity);
            }

            Console.WriteLine("Waiting for work... Press Enter to exit.");

            Console.ReadLine();
            Console.WriteLine("Finished");
        }
    }
}

更新1:权限范围疑问

根据微软官方文档,SeCreateGlobalPrivilege仅针对全局命名空间中的文件映射对象创建操作。那创建Global互斥对象是否无需该权限?但实际存在创建Global互斥对象失败的情况,此时负责管控的安全设置是什么?

更新2:交互式登录相关异常现象

通过ETW系统调用追踪发现ntdll.dll!NtOpenDirectoryObject返回NTSTATUS 0xC0000022(STATUS_ACCESS_DENIED)。修改MutexTester程序在异常时重试,发现程序会在某个时间点停止抛出异常,且该现象与交互式登录密切相关:以管理员用户启动的进程在交互式登录前持续抛出异常,登录后异常消失,此行为是否符合预期?

抛出的异常信息如下:

Exception Info: System.UnauthorizedAccessException
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.Threading.Mutex+MutexTryCodeHelper.MutexTryCode(System.Object)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
   at System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean, System.String, Boolean ByRef, SECURITY_ATTRIBUTES)
   at System.Threading.Mutex..ctor(Boolean, System.String, Boolean ByRef, System.Security.AccessControl.MutexSecurity)

内容的提问来源于stack exchange,提问作者Alois Kraus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 10:50:29