CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告

admin 2022年4月1日22:08:21评论130 views字数 3808阅读12分41秒阅读模式

CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告


CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告

昨天,国家信息安全漏洞共享平台发布了安:CNTA-2022-0009的安全公告,于3月30日收录了Spring框架远程命令执行漏洞(CNVD-2022-23942)。


Spring框架是由于软件开发的复杂性而创建的。Spring使用的是基本的JavaBean来完成以前只可能由EJB完成的事情。然而,Spring的用途不仅仅限于服务器端的开发。从简单性、可测试性和松耦合性角度而言,绝大部分Java应用都可以从Spring中受益。
公告称攻击者可利用该漏洞,在未授权的情况下远程执行命令。

结合Spring官方公告,可以看到:

漏洞影响范围:

该漏洞影响在 JDK 9+ 上运行的 Spring MVC 和 Spring WebFlux 应用程序。

具体的利用需要应用程序作为 WAR 部署在 Tomcat 上运行。如果应用程序被部署为 Spring Boot 可执行 jar,即默认值,则它不易受到漏洞利用。但是,该漏洞的性质更为普遍,可能还有其他方法可以利用它。

Spring给出的漏洞解决方法:

注意:如果能够升级到 Spring Framework 5.3.185.2.20,则不需要此部分。
泄露的报告建议disallowedFields通过WebDataBinder以下方式设置@ControllerAdvice
@ControllerAdvice@Order(Ordered.LOWEST_PRECEDENCE)public class BinderControllerAdvice {

@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
String[] denylist = new String[]{"class.*", "Class.*", "*.class.*", "*.Class.*"};
dataBinder
.setDisallowedFields(denylist);
}}

这通常有效,但作为集中应用的解决方法修复,可能会留下一些漏洞,特别是如果控制器disallowedFields通过自己的@InitBinder方法在本地设置,这会覆盖全局设置。
为了以更安全的方式应用解决方法,应用程序可以扩展以在所有其他初始化之后RequestMappingHandlerAdapter更新最后。WebDataBinder为此,Spring Boot 应用程序可以声明一个WebMvcRegistrationsbean (Spring MVC) 或一个WebFluxRegistrationsbean (Spring WebFlux)。

例如在 Spring MVC 中(在 WebFlux 中类似):

package car.app;import java.util.ArrayList;import java.util.Arrays;import java.util.List;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;import org.springframework.context.annotation.Bean;import org.springframework.web.bind.ServletRequestDataBinder;import org.springframework.web.context.request.NativeWebRequest;import org.springframework.web.method.annotation.InitBinderDataBinderFactory;import org.springframework.web.method.support.InvocableHandlerMethod;import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;import org.springframework.web.servlet.mvc.method.annotation.ServletRequestDataBinderFactory;@SpringBootApplicationpublic class MyApp {
public static void main(String[] args) {
SpringApplication.run(CarApp.class, args);
}

@Bean
public WebMvcRegistrations mvcRegistrations() {
return new WebMvcRegistrations() {
@Override
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
return new ExtendedRequestMappingHandlerAdapter();
}
};
}
private static class ExtendedRequestMappingHandlerAdapter extends RequestMappingHandlerAdapter {
@Override
protected InitBinderDataBinderFactory createDataBinderFactory(List<InvocableHandlerMethod> methods) {
return new ServletRequestDataBinderFactory(methods, getWebBindingInitializer()) {
@Override
protected ServletRequestDataBinder createBinderInstance(
Object target, String name, NativeWebRequest request) throws Exception {
ServletRequestDataBinder binder = super.createBinderInstance(target, name, request);
String[] fields = binder.getDisallowedFields();
List<String> fieldList = new ArrayList<>(fields != null ? Arrays.asList(fields) : Collections.emptyList());
fieldList
.addAll(Arrays.asList("class.*", "Class.*", "*.class.*", "*.Class.*"));
binder
.setDisallowedFields(fieldList.toArray(new String[] {}));
return binder;
}
};
}
}}

对于没有 Spring Boot 的 Spring MVC,应用程序可以从文档的高级配置部分中描述的直接@EnableWebMvc扩展,然后覆盖该方法。DelegatingWebMvcConfigurationcreateRequestMappingHandlerAdapter



CNVD公告称,2022年3月30日,CNVD平台接收到蚂蚁科技集团股份有限公司报送的Spring框架远程命令执行漏洞。由于Spring框架存在处理流程缺陷,攻击者可在远程条件下,实现对目标主机的后门文件写入和配置修改,继而通过后门文件访问获得目标主机权限。使用Spring框架或衍生框架构建网站等应用,且同时使用JDK版本在9及以上版本的,易受此漏洞攻击影响。

CNVD对该漏洞的综合评级为“高危”。

CNVD给出的漏洞处置建议:

目前,Spring官方已发布新版本完成漏洞修复,CNVD建议受漏洞影响的产品(服务)厂商和信息系统运营者尽快进行自查,并及时升级至最新版本:

目前,Spring官方已发布新版本完成漏洞修复,CNVD公告建议受漏洞影响的产品(服务)厂商和信息系统运营者尽快进行自查,并及时升级至最新版本:

https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement

 附:参考链接:

https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement

https://github.com/spring-projects/spring-framework/compare/v5.3.17...v5.3.18

 

信息来源:CNVD官网、Spring官网


CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告
END
了解更多云智信安信息请移步“阅读原文”
CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告



力引领

原文始发于微信公众号(云知云享):CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年4月1日22:08:21
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CNVD发布:关于Spring框架存在远程命令执行漏洞的安全公告http://cn-sec.com/archives/862957.html

发表评论

匿名网友 填写信息