Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-22978 PoC — VMware Spring Security 授权问题漏洞

Source
Associated Vulnerability
Title:VMware Spring Security 授权问题漏洞 (CVE-2022-22978)
Description:In spring security versions prior to 5.4.11+, 5.5.7+ , 5.6.4+ and older unsupported versions, RegexRequestMatcher can easily be misconfigured to be bypassed on some servlet containers. Applications using RegexRequestMatcher with `.` in the regular expression are possibly vulnerable to an authorization bypass.
Description
CVE-2022-22978漏洞实例代码
Readme
# CVE-2022-22978-demo
CVE-2022-22978漏洞示例代码

# 利用条件
虽然定为高危,但是利用条件还是比较苛刻的,个人感觉这个漏洞比较鸡肋。
1. 首先肯定是spring-security在漏洞影响范围内
2. 其次需要使用spring-security的正则匹配器regexMatchers或者直接使用RegexRequestMatcher,并且使用了`.` 匹配路径,类似这样: 
   - regexMatcher("/api/.*") // 允许/api下的所有子路径
   - regexMatcher("/files/.*\\.jpg") // 匹配所有.jpg结尾的文件请求
   - regexMatcher("/user/.*/profile") // 允许/user下任意用户名的profile路径
4. 实际上这种情况很少见,比如regexMatcher("/api/.*"),有这样的路径,那么还需要一个有类似@RequestMapping("/api/\*")注解的controller,用户处理/api下的所有路径的请求。否则即使用`%0a%0d`绕过了spring-security的路径匹配规则,但是却会报404错误。

# 利用演示
正常访问所有路径,都会跳转到spring-security提供的默认登录页面。
![image](https://github.com/wan9xx/CVE-2022-22978-demo/assets/65795483/7fe9c086-8a99-4810-970f-5aa75d5b18e9)


访问:http://127.0.0.1:8080/admin/admin%0a,成功绕过登录
![image](https://github.com/wan9xx/CVE-2022-22978-demo/assets/65795483/6d30b535-cbe8-440e-bde8-690863e6ac65)

访问:http://127.0.0.1:8080/hello%0a
绕过了所有路径都需要登录的安全检测,但是由于没有@RequestMapping("/hello/\*")注解的控制器,导致映射失败,报404错误
![image](https://github.com/wan9xx/CVE-2022-22978-demo/assets/65795483/54d67828-4261-4922-a469-e6772eb03128)

   
File Snapshot

[4.0K] /data/pocs/1f1a5dc165acab1ef369cda552a4797e6a6d9560 ├── [4.0K] CVE-2022-22978-demo │   ├── [9.3K] CVE-2022-22978-demo.iml │   ├── [1.4K] HELP.md │   ├── [3.8K] pom.xml │   ├── [4.0K] src │   │   ├── [4.0K] main │   │   │   ├── [4.0K] java │   │   │   │   └── [4.0K] com │   │   │   │   └── [4.0K] example │   │   │   │   └── [4.0K] cve202222978demo │   │   │   │   ├── [ 353] Cve202222978DemoApplication.java │   │   │   │   └── [4.0K] demos │   │   │   │   └── [4.0K] web │   │   │   │   ├── [2.1K] BasicController.java │   │   │   │   ├── [1.7K] PathVariableController.java │   │   │   │   ├── [1.0K] User.java │   │   │   │   └── [2.0K] WebSecurityConfig.java │   │   │   └── [4.0K] resources │   │   │   ├── [1.0K] application.properties │   │   │   └── [4.0K] templates │   │   │   ├── [ 192] admin.html │   │   │   └── [ 79] index.html │   │   └── [4.0K] test │   │   └── [4.0K] java │   │   └── [4.0K] com │   │   └── [4.0K] example │   │   └── [4.0K] cve202222978demo │   │   └── [ 239] Cve202222978DemoApplicationTests.java │   └── [4.0K] target │   ├── [4.0K] classes │   │   ├── [1.0K] application.properties │   │   ├── [4.0K] com │   │   │   └── [4.0K] example │   │   │   └── [4.0K] cve202222978demo │   │   │   ├── [ 763] Cve202222978DemoApplication.class │   │   │   └── [4.0K] demos │   │   │   └── [4.0K] web │   │   │   ├── [2.1K] BasicController.class │   │   │   ├── [1.4K] PathVariableController.class │   │   │   ├── [ 815] User.class │   │   │   └── [4.8K] WebSecurityConfig.class │   │   └── [4.0K] templates │   │   ├── [ 192] admin.html │   │   └── [ 79] index.html │   ├── [7.3K] CVE-2022-22978-demo-0.0.1-SNAPSHOT.jar │   ├── [4.0K] maven-archiver │   │   └── [ 124] pom.properties │   ├── [4.0K] maven-status │   │   └── [4.0K] maven-compiler-plugin │   │   ├── [4.0K] compile │   │   │   └── [4.0K] default-compile │   │   │   ├── [ 305] createdFiles.lst │   │   │   └── [ 570] inputFiles.lst │   │   └── [4.0K] testCompile │   │   └── [4.0K] default-testCompile │   │   ├── [ 68] createdFiles.lst │   │   └── [ 121] inputFiles.lst │   └── [4.0K] test-classes │   └── [4.0K] com │   └── [4.0K] example │   └── [4.0K] cve202222978demo │   └── [ 591] Cve202222978DemoApplicationTests.class └── [1.6K] README.md 35 directories, 28 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →