CVE-2023-4207: Use-After-Free Vulnerability in Linux Kernel's net/sched: cls_fw Component Leads to Local Privilege Escalation
A use-after-free vulnerability has been discovered in the Linux kernel's net/sched: cls_fw component, which can be exploited by attackers to gain local privilege escalation. The vulnerability lies in the way the fw_change() function is handled when called on an existing filter. This blog post will provide a detailed explanation of the vulnerability, exploit details, links to original sources, and a recommended solution.
Vulnerability Details
The use-after-free vulnerability occurs due to improper handling of the fw_change() function in the Linux kernel's net/sched: cls_fw component. When fw_change() is called on an existing filter, the whole tcf_result struct is always copied into the new instance of the filter. Here is the relevant code snippet in cls_fw.c:
int fw_change(struct rtnl_ematch_tree *tree, void *data,
const struct tcf_proto *tp,
unsigned long base, struct tc_cls_u32_offload *offload,
u16 proto, bool rtnl_held, struct netlink_ext_ack *extack)
{
// ...
old_r = head->res;
new_r = &fw->res;
*new_r = *old_r;
// ...
}
This copy operation can lead to a problem when updating a filter bound to a class since tcf_unbind_filter() is always called on the old instance in the success path, which in turn decreases the filter_cnt of the still-referenced class. This can lead to the class being deleted, resulting in a use-after-free situation.
Exploit Details
To exploit this vulnerability, an attacker requires local access to the vulnerable system. Once gained, they would need the ability to make a call to the vulnerable fw_change() function with carefully crafted filter parameters to trigger the use-after-free condition. Successful exploitation can lead to local privilege escalation, granting the attacker elevated privileges on the target system.
For a more detailed explanation of this vulnerability and the possible ways to exploit it, please refer to the following sources:
- Linux kernel mailing list discussion
- Linux kernel Git source code
Recommended Solution
To fix this vulnerability, it is recommended to upgrade your Linux kernel to a version that contains the patch for this issue. The patch has been merged in commit 76e42ae831991c828cffa8c37736ebfb831ad5ec and all stable versions past this commit are considered secure.
As an additional security measure, consider restricting access to your systems to only trusted users who require access for legitimate purposes. This can help limit the potential attack surface.
Conclusion
The CVE-2023-4207 vulnerability highlights the importance of secure coding practices in the development of complex software systems, such as the Linux kernel. By staying up-to-date with the latest kernel releases and applying security patches, users can protect themselves from potential vulnerabilities like this one.
Timeline
Published on: 09/06/2023 14:15:11 UTC
Last modified on: 09/11/2023 18:13:33 UTC