@@ -489,6 +489,55 @@ public String ifUserExit(Model model, HttpServletRequest request) throws IOExcep
489489
490490* 使用最新或安全版本的第三方组件
491491
492+ ### SPel 注入
493+ ##### 介绍
494+ Spel是Spring框架el表达式的缩写,当使用SpelExpressionParser解析spel表达式,且表达式可被外部控制,则可能导致SPel表达式注入从而造成RCE,如[CVE-2018-1260](https:// github.com/Cryin/Paper/blob/master/CVE-2018-1260%20spring-security-oauth2%20RCE%20Analysis.md)就是spring-security-oauth2的一个SPel注入导致的RCE 。
495+
496+ ##### 漏洞示例
497+ ```java
498+ @RequestMapping (path = "/elinjection ")
499+ public class SPelInjectionController {
500+ @RequestMapping (value = " /spel.html" ,method = RequestMethod . GET )
501+ public String SPelInjection(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) throws IOException {
502+ String el= request. getParameter(" el" );
503+ // el="T(java.lang.Runtime).getRuntime().exec(\"open /Applications/Calculator.app\")";
504+ ExpressionParser PARSER = new SpelExpressionParser ();
505+ Expression exp = PARSER . parseExpression(el);
506+ return (String )exp. getValue();
507+ }
508+ }
509+ ```
510+ ##### 修复方案
511+ * 解析el表达式时,参数不要由外部用户输入
512+
513+ ### 任意文件上传漏洞
514+ ##### 介绍
515+ 使用MultipartFile 上传文件时,未对文件大小及后缀类型进行限制,则可能导致任意文件上传风险。
516+
517+ ##### 漏洞示例
518+ ```java
519+ @RequestMapping (value = " /Upload" , method = RequestMethod . POST )
520+ public Result Upload (@RequestParam MultipartFile file ) throws IOException {
521+ InputStream inputStream = null ;
522+ OutputStream outputStream = null ;
523+ try {
524+ inputStream = file. getInputStream();
525+ File dFile = new File ( " /home/user/" + file. getOriginalFilename());
526+ if (! dFile. exists()) {
527+ dFile. createNewFile();
528+ }
529+ outputStream = new FileOutputStream (dumpFile);
530+ Util . copy(inputStream, outputStream);
531+
532+ }finally {
533+ Util . Close(inputStream);
534+ }
535+ return True
536+ }
537+ ```
538+ ##### 修复方案
539+ * 配置MultipartFile ,限制上传文件的大小及后缀类型。
540+
492541### 待续...
493542
494543### 总结
0 commit comments