nf_tables - CVE-2024-1086
A short Proof-of-Concept of privilege escalation exploit CVE-2024-1086 (nf_tables
), working on most Linux kernels between version 5.14 - 6.6, including Debian, Ubuntu and KernelCTF. The exploit is very unstable, use with caution.
Verify kernel version:
Verify that unprivileged users can create namespaces:
Verify if kernel version is vulnerable to CVE-2024-1086, according to table below.
Note: Exploit will work up to (including) version 6.6.4 if CONFIG_INIT_ON_ALLOC_DEFAULT_ON
is toggled off.
v5.4.270
fail
[CODE] pre-dated nft code (denies rule alloc)
v5.10.209
fail
[TCHNQ] BUG mm/slub.c:4118
v5.14.21
working
n/a
v5.15.148
working
n/a
v5.16.20
working
n/a
v5.17.15
working
n/a
v5.18.19
working
n/a
v5.19.17
working
n/a
v6.0.19
working
n/a
v6.1.55
working
n/a
v6.1.69
working
n/a
v6.1.69
working
n/a
v6.1.72
working
n/a
v6.2.?
working
n/a
v6.2.16
working
n/a
v6.3.13
working
n/a
v6.4.16
fail
[TCHNQ] bad page: page->_mapcount != -1 (-513), bcs CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
v6.5.3
fail
[TCHNQ] bad page: page->_mapcount != -1 (-513), bcs CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
v6.5.13
fail
[TCHNQ] bad page: page->_mapcount != -1 (-513), bcs CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
v6.6.14
fail
[TCHNQ] bad page: page->_mapcount != -1 (-513), bcs CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
v6.7.1
fail
[CODE] nft verdict value incorrect is altered by kernel
Download, install and build exploit.
Run exploit.
Patch
To patch the vulnerability simply upgrade the kernel to a non-vulnerable version.
If you're not able to upgrade the kernel for some reason, you can temporarily fix the issue by denying unprivileged users to create namespaces:
sudo sysctl -w kernel.unprivileged_userns_clone=0
Or permanently by:
echo kernel.unprivileged_userns_clone=0 | \ sudo tee /etc/sysctl.d/99-disable-unpriv-userns.conf
Last updated