spring Framework 特定条件下目录遍历漏洞(CVE-2024-38816)修复

spring Framework 特定条件下目录遍历漏洞(CVE-2024-38816)修复

漏洞描述

CVE-2024-38816: Path traversal vulnerability in functional web frameworks

通过功能性 Web 框架 WebMvc.fn 或 WebFlux.fn 提供静态资源的应用程序容易受到路径遍历攻击。攻击者可以编写恶意 HTTP 请求并获取文件系统上任何可由 Spring 应用程序正在运行的进程访问的文件。

具体来说,当以下两个条件都成立时,应用程序就容易受到攻击:

  • Web 应用程序用于RouterFunctions提供静态资源
  • 资源处理明确配置了FileSystemResource位置

但是,当以下任何一项满足时,恶意请求都会被阻止和拒绝:

受影响的 Spring 产品和版本

Spring 框架

  • 5.3.0 - 5.3.39
  • 6.0.0 - 6.0.23
  • 6.1.0 - 6.1.12
  • 较旧的、不受支持的版本也受到影响

分析:

通常我们会把sprintboot项目打包war部署tomcat,

或者直接本地springboot 运行(内置tomcat)

上述两种方式都阻止漏洞,因为tomcat会拦截,返回错误如下:

<!doctype html>
<html lang="en">

<head>
	<title>HTTP Status 400 – Bad Request</title>
	<style type="text/css">
		body {
			font-family: Tahoma, Arial, sans-serif;
		}

		h1,
		h2,
		h3,
		b {
			color: white;
			background-color: #525D76;
		}

		h1 {
			font-size: 22px;
		}

		h2 {
			font-size: 16px;
		}

		h3 {
			font-size: 14px;
		}

		p {
			font-size: 12px;
		}

		a {
			color: black;
		}

		.line {
			height: 1px;
			background-color: #525D76;
			border: none;
		}
	</style>
</head>

<body>
	<h1>HTTP Status 400 – Bad Request</h1>
	<hr class="line" />
	<p><b>Type</b> Status Report</p>
	<p><b>Message</b> Invalid URI</p>
	<p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a
		client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
	</p>
	<hr class="line" />
	<h3>Apache Tomcat/9.0.46</h3>
</body>

</html>

综上,内置和外置的tomcat都会校验地址,通过后才会进入spring webmvc解析才可能触发漏洞。

因此要重现漏洞需用不知名web服务器。 webflux默认采用netty也无需处理。

漏洞原因:spring地址解析URL地址代码考虑欠缺,需要依赖前置的web服务器(比如tomcat)拦截

修复参考:

https://xz.aliyun.com/t/15779?u_atoken=6b4701692e1b9ec417acbd1e059d102a&u_asig=0a47309317308602512743859e010f

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hvang1988

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值