
Linux local privilege escalation exploit for CVE-2026-31431, abusing the AF_ALG crypto API with splice() to modify page cache and spawn a root shell.
This repository contains a small Linux local privilege escalation PoC for CVE-2026-31431, also known as "Copy Fail".
The exploit targets the Linux kernel algif_aead path in the AF_ALG userspace
crypto API. It uses AF_ALG plus splice() to coerce the kernel into writing
into the page cache of /usr/bin/su in 4-byte chunks, then executes su after
the page cache has been modified.
The PoC in copy_fail_exp.py does four things:
AF_ALG socket for aead with the transform
authencesn(hmac(sha256),cbc(aes)).setsockopt() values used in the
original proof of concept.splice() calls to move data from the target file into the AF_ALG
request path, which is the buggy kernel path./bin/sh.The zlib blob is not random data. It is a compact payload that is meant to
replace the start of /usr/bin/su in page cache so the next execution of su
spawns a root shell.
The vulnerable code was introduced in Linux kernel 4.14-era algif_aead
changes and remained present until the upstream fix that reverts the in-place
optimization.
algif_aead in-place path.AF_ALG crypto API is enabled, which is the default on
most general-purpose Linux distributions.| Distribution | Kernel |
|---|---|
| Ubuntu 24.04 LTS | 6.17.0-1007-aws |
| Amazon Linux 2023 | 6.18.8-9.213.amzn2023 |
| RHEL 10.1 |
6.18.226.19.127.0Downstream LTS branches are safe only after the vendor backport lands in the kernel package you actually run.
Use a lab VM or container host you own. Do not run this on production systems.
/usr/bin/su exists and is setuid-root.python3 copy_fail_exp.py
/usr/bin/su and then invokes
su. You should end up in a root shell or see a root prompt, depending on
the environment.The script has no extra dependencies beyond the Python 3 standard library.
python3 copy_fail_exp.py
If you want to inspect the target first, the script currently defaults to
/usr/bin/su.
If you maintain a downstream kernel, the correct fix is to backport the upstream revert that removes the in-place AEAD optimization:
a664bf3d603dc3bdcf9ae47cc21e0daec706d7a572548b093ee3 in-place change.Recommended workflow for a downstream kernel tree:
git cherry-pick a664bf3d603dc3bdcf9ae47cc21e0daec706d7a5
make olddefconfig
make -j"$(nproc)"
make modules_install
make install
reboot
If you are not rebuilding kernels yourself, install the vendor kernel package that contains the backport and reboot into it.
If patching is delayed, disable the module path as a temporary measure:
echo "install algif_aead /bin/false" > /etc/modprobe.d/disable-algif-aead.conf
rmmod algif_aead 2>/dev/null
This is a mitigation, not a fix.
6.12.0-124.45.1.el10_1 |
| SUSE 16 | 6.12.0-160000.9-default |