关联漏洞
描述
CVE-2022-22978漏洞实例代码
介绍
# 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提供的默认登录页面。

访问:http://127.0.0.1:8080/admin/admin%0a,成功绕过登录

访问:http://127.0.0.1:8080/hello%0a
绕过了所有路径都需要登录的安全检测,但是由于没有@RequestMapping("/hello/\*")注解的控制器,导致映射失败,报404错误

文件快照
[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
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。