【安全漏洞】CVE-2021-41773和CVE-2021-42013漏洞分析

本文详细分析了Apache HTTP Server的两个安全漏洞:CVE-2021-41773和CVE-2021-42013。这两个漏洞都涉及路径穿越,可以通过特定的payload绕过安全检查。Apache通过发布2.4.50和2.4.51版本的更新来修复这些问题,加强了对URL编码的校验,防止路径穿越攻击。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CVE-2021-41773

漏洞成因

Apache HTTP Server 2.4.49版本使用的ap_normalize_path函数在对路径参数进行规范化时会先进行url解码,然后判断是否存在…/的路径穿越符,如下所示:

while (path[l] != '\0') {
   
    if ((flags & AP_NORMALIZE_DECODE_UNRESERVED)
            && path[l] == '%' && apr_isxdigit(path[l + 1])
            && apr_isxdigit(path[l + 2])) {
   
        const char c = x2c(&path[l + 1]);
        if (apr_isalnum(c) || (c && strchr("-._~", c))) {
   
            /* Replace last char and fall through as the current
                * read position */
            l += 2;
            path[l] = c;
        }
    }
    ......

    if (w == 0 || IS_SLASH(path[w - 1])) {
   
        /* Collapse / sequences to / */
        if ((flags & AP_NORMALIZE_MERGE_SLASHES) && IS_SLASH(path[l])) {
   
            do {
   
                l++;
            } while (IS_SLASH(path[l]));
            continue;
        }

        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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值