spring security regexrequestmatcher 认证绕过漏洞(CVE-2022-22978)

这篇具有很好参考价值的文章主要介绍了spring security regexrequestmatcher 认证绕过漏洞(CVE-2022-22978)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

漏洞详情

CVE-2022-22978 中,在Spring Security受影响版本范围内,若使用了存在特殊配置(含 .)的RegexRequestMatcher 的情况下可能导致权限绕过。

受影响版本:

5.5.0 <= Spring Security < 5.5.7

5.6.0 <= Spring Security < 5.6.4

Spring Security 更早的不受支持的版本

安全版本:

Spring Security >= 5.5.7

Spring Security >= 5.6.4

Spring Security >= 5.7.0

修复方法

修改pom.xml文件

<properties>
    <spring-security.version>5.5.8</spring-security.version>
</properties>

需要将springboot版本同步升级才能生效,我升级到了

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.14</version>
    <relativePath/>
</parent>

在升级完之后遇到以下问题:

1.跨域配置无效:我删除了之前的配置,重写了一个方法

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.util.Arrays;

/**
 * @author hecai
 * @description: TODO
 * @date 2022/10/17 13:33
 * @Version 1.0
 */
@Configuration
public class CorsConfig {
    @Bean
    public FilterRegistrationBean corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration config = new CorsConfiguration();
        config.setAllowedOriginPatterns(Arrays.asList("*"));
        config.setAllowCredentials(true);
        config.addAllowedHeader("*");
        config.addAllowedMethod("*");
        source.registerCorsConfiguration("/**", config);
        FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
        //配置CorsFilter优先级
                bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return bean;
    }
}

2.遇到了定时任务quzarts包自动装配数据库无效,我修改了配置文件为:

import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import javax.sql.DataSource;
import java.util.Properties;

@Configuration
public class SchedulerConfigurations {
    @Autowired
    DynamicRoutingDataSource dynamicDataSource;

    @Bean(name = "SchedulerFactoryBeanNameCunzai")
    public SchedulerFactoryBean schedulerFactoryBean() {
        DataSource dataSource= dynamicDataSource.getDataSource("scheduler");
        SchedulerFactoryBean factory = new SchedulerFactoryBean();
        factory.setDataSource(dataSource);
        Properties prop = new Properties();
        prop.put("org.quartz.scheduler.instanceName", "AmychScheduler");
        prop.put("org.quartz.scheduler.instanceId", "AUTO");
         prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
        prop.put("org.quartz.threadPool.threadCount", "20");
        prop.put("org.quartz.threadPool.threadPriority", "5");
        prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
        prop.put("org.quartz.jobStore.isClustered", "true");
        prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
        prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
        prop.put("org.quartz.jobStore.misfireThreshold", "12000");
        prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
        prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
        factory.setQuartzProperties(prop);
        factory.setSchedulerName("AmychScheduler");
        factory.setStartupDelay(30);
        factory.setApplicationContextSchedulerContextKey("applicationContextKey");
        factory.setOverwriteExistingJobs(true);
        factory.setAutoStartup(true);
        return factory;
    }
}

3.定时任务quzarts包的配置文件一开始卸载底层代码(公司内部封装好的,暂时无人维护),并自动注入容器,我已经无法修改底层代码,所以我采取的做法是:从容器中移除这个bean,使用我修改后的文件即可文章来源地址https://www.toymoban.com/news/detail-428228.html

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author hecai
 * @description: TODO
 * @date 2022/10/17 10:59
 * @Version 1.0
 */
@Component
public class RemoveRegistyBeanFactoryPostProcessor implements BeanDefinitionRegistryPostProcessor {
    /**
     * 移出bean。 aa是bean的名称
     * @param beanDefinitionRegistry
     * @throws BeansException
     */
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
        if (beanDefinitionRegistry.containsBeanDefinition("schedulerFactoryBean")){
            beanDefinitionRegistry.removeBeanDefinition("schedulerFactoryBean");
        }

    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {

    }
}

到了这里,关于spring security regexrequestmatcher 认证绕过漏洞(CVE-2022-22978)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Apache Shiro权限绕过漏洞(CVE-2022-32532)

      Shiro是Apache旗下一个开源的Java安全框架,它具有身份验证、访问控制、数据加密、会话管理等功能,可以用于保护任何应用程序的安全,如移动应用程序、web应用程序等。   2022年6月29日,Apache官方披露Apache Shiro权限绕过漏洞(CVE-2022-32532),当 Apache Shiro 中使用 RegexReques

    2024年02月04日
    浏览(29)
  • CVE-2023-27524 Apache Superset 身份认证绕过漏洞

    Apache Superset是一个开源的数据可视化和数据探测平台,它基于Python构建,使用了一些类似于Django和Flask的Python web框架。提供了一个用户友好的界面,可以轻松地创建和共享仪表板、查询和可视化数据,也可以集成到其他应用程序中。由于用户在默认安装过程中,未对SECRET_KE

    2024年02月10日
    浏览(51)
  • Apache Superset 身份认证绕过漏洞(CVE-2023-27524)

    Apache Superset是一个开源的数据可视化和数据探测平台,它基于Python构建,使用了一些类似于Django和Flask的Python web框架。提供了一个用户友好的界面,可以轻松地创建和共享仪表板、查询和可视化数据,也可以集成到其他应用程序中。由于用户在默认安装过程中,未对SECRET_KE

    2024年02月09日
    浏览(45)
  • CVE漏洞复现-CVE-2022-22965-Spring-RCE漏洞

    Spring framework 是Spring 里面的一个基础开源框架,其目的是用于简化 Java 企业级应用的开发难度和开发周期,2022年3月31日,VMware Tanzu发布漏洞报告,Spring Framework存在远程代码执行漏洞,在 JDK 9+ 上运行的 Spring MVC 或 Spring WebFlux 应用程序可能容易受到通过数据绑定的远程代码执行

    2023年04月21日
    浏览(48)
  • Spring Rce 漏洞分析CVE-2022-22965

    Spring Framework 是一个开源的轻量级J2EE应用程序开发框架。 3月31日,VMware发布安全公告,修复了Spring Framework中的远程代码执行漏洞(CVE-2022-22965)。在 JDK 9 及以上版本环境下,可以利用此漏洞在未授权的情况下在目标系统上写入恶意程序从而远程执行任意代码。 影响组件:

    2024年02月05日
    浏览(52)
  • CVE漏洞复现-CVE-2022-22947-Spring Cloud Gateway RCE

    微服务架构与Spring Cloud 最开始时,我们开发java项目时,所有的代码都在一个工程里,我们把它称为单体架构。当我们的项目的代码量越来越大时,开发的成员越来越多时,这时我们项目的性能以及我们开发的效率都会存在非常大的问题,所以对于这样的项目,我们需要把它

    2023年04月14日
    浏览(39)
  • Spring Cloud Foundry上使用通配符模式匹配进行的安全绕过漏洞 CVE-2023-20873

    背景:公司项目扫描到 Spring Cloud Foundry上使用通配符模式匹配进行的安全绕过漏洞 CVE-2023-20873 CVE-2023-20873:在Cloud Foundry上使用通配符模式匹配进行的安全绕过 高风险 | 2023年5月18日 | CVE-2023-20873 在Spring Boot版本3.0.0 - 3.0.5, 2.7.0 - 2.7.10, 2.6.0 - 2.6.14, 2.5.0 - 2.5.14以及旧版支持的版本

    2024年02月09日
    浏览(56)
  • Spring Security注销后未正确保存空的SecurityContext漏洞CVE-2023-20862

    背景:公司项目扫描到 Spring-security 组件 注销后未正确保存空的SecurityContext CVE-2023-20862 高风险 | 2023年4月17日 | CVE-2023-20862 在Spring Security中,5.7.x版本之前的5.7.8版本,5.8.x版本之前的5.8.3版本,以及6.0.x版本之前的6.0.3版本,如果使用序列化版本,注销支持不会正确清理安全上

    2024年02月07日
    浏览(31)
  • AppWeb 身份验证绕过漏洞 (CVE-2018-8715)

    当前漏洞环境部署在vulhub,当前验证环境为vulhub靶场(所有实验均为虚拟环境) 实验环境:攻击机----kali 靶机:centos7 1、进入靶场,启动环境 2、访问AppWeb控制台:http://your-ip:8080 使用用户名、密码admin访问 访问失败 3、抓包,使用用户名、密码admin 4、只保留用户名参数,发包

    2024年02月13日
    浏览(22)
  • 【认证绕过】NACOS身份认证绕过漏洞分析

    前言 工作中遇到一个nacos服务认证绕过的问题,在此总结一下漏洞原因。 官方文档描述: Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。 Nacos 帮助您更敏捷和容易地构建、

    2023年04月13日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包