漏洞描述
近日,微軟發佈了2月安全更新公告,其中CVE-2020-0618 SQL Server 遠程命令執行漏洞在國內存在危害,SQL Server 在國內使用量大。
Microsoft SQL Server(微軟結構化查詢語言服務器)是由微軟公司所推出的關係型數據庫解決方案。
漏洞存在於
ReportingServicesWebServer.dll
中,Microsoft.Reporting.WebForms.BrowserNavigationCorrector
的OnLoad()方法中,先從ViewState中取值,賦值給value變量,在對value變量進行非空判斷後,初始化LosFormatter對象並對使用LosFormatter對象中的Deserialize()方法對value變量直接反序列化。
攻擊者向 SQL Server 的Reporting Services發送特製請求會觸發漏洞,攻擊成功可獲得SQL Server服務的對應控制權限。
漏洞分析
此漏洞在ReportingServicesWebServer.dll中
Microsoft.Reporting.WebForms.BrowserNavigationCorrector的OnLoad方法使用LosFormatter類反序列化了不受信任的用戶輸入:
<code>protected override void OnInit(EventArgs e){ base.OnInit(e); ReportViewerHost reportViewer = this.ReportViewer; reportViewer.EnableHybrid = this.ShowHybrid; if (reportViewer != null) { PageRequestManagerErrorHandler child = new PageRequestManagerErrorHandler(); reportViewer.Parent.Controls.AddAt(reportViewer.Parent.Controls.IndexOf(reportViewer), child); BrowserNavigationCorrector child2 = reportViewer.CreateNavigationCorrector(); reportViewer.Parent.Controls.AddAt(reportViewer.Parent.Controls.IndexOf(reportViewer), child2);/<code>
回溯BrowserNavigationCorrector類來自
Microsoft.ReportingServices.WebServer.ReportViewerPage類:
<code>protected override void OnInit(EventArgs e){ base.OnInit(e); ReportViewerHost reportViewer = this.ReportViewer; reportViewer.EnableHybrid = this.ShowHybrid; if (reportViewer != null) { PageRequestManagerErrorHandler child = new PageRequestManagerErrorHandler(); reportViewer.Parent.Controls.AddAt(reportViewer.Parent.Controls.IndexOf(reportViewer), child); BrowserNavigationCorrector child2 = reportViewer.CreateNavigationCorrector(); reportViewer.Parent.Controls.AddAt(reportViewer.Parent.Controls.IndexOf(reportViewer), child2);/<code>
可以通過在本地 SharePoint服務器中調用/ReportServer/pages/ReportViewer.aspx頁面來調用此函數觸發漏洞。
將以下HTTP請求發送到服務器驗證漏洞:
<code>POST /ReportServer/pages/ReportViewer.aspx HTTP/1.1Host: targetContent-Type: application/x-www-form-urlencodedContent-Length: XNavigationCorrector$PageState=NeedsCorrection&NavigationCorrector$ViewState=[PayloadHere]&__VIEWSTATE=/<code>
在PowerShell中使用ysoserial.net工具生成paylaod:
<code>LosFormatter losFormatter = new LosFormatter(true, this.m_viewer.GetUserId());/<code>
使用上面生成的paylaod發送HTTP請求後得到了反向shell:
在微軟2020年二月的patch中,使用LosFormatter類時,補丁啟用了MAC驗證來緩解此漏洞:
<code>LosFormatter losFormatter = new LosFormatter(true, this.m_viewer.GetUserId());/<code>
漏洞危害
高危
影響版本
Microsoft SQL Server 2012 for 32-bit Systems Service Pack 4 (QFE)
Microsoft SQL Server 2012 for x64-based Systems Service Pack 4 (QFE)
Microsoft SQL Server 2014 Service Pack 3 for 32-bit Systems (CU)
Microsoft SQL Server 2014 Service Pack 3 for 32-bit Systems (GDR)
Microsoft SQL Server 2014 Service Pack 3 for x64-based Systems (CU)
Microsoft SQL Server 2014 Service Pack 3 for x64-based Systems (GDR)
Microsoft SQL Server 2016 for x64-based Systems Service Pack 2 (CU)
Microsoft SQL Server 2016 for x64-based Systems Service Pack 2 (GDR)
安全建議
打補丁是修補此漏洞的唯一選擇,要確保只有經過身份驗證的用戶才能訪問該程序。
請根據微軟官進行漏洞修復:
https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-0618
參考信息
https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-0618
https://support.microsoft.com/zh-cn/help/321185/how-to-determine-the-version-edition-and-update-level-of-sql-server-an
https://www.mdsec.co.uk/2020/02/cve-2020-0618-rce-in-sql-server-reporting-services-ssrs/
閱讀更多 白帽子 的文章