Privilege escalation in NetBSD - CVE-2012-0217

 

Privilege escalation in NetBSD - CVE-2012-0217

Published: September 9, 2017 / Updated: June 17, 2021


Vulnerability identifier: #VU8202
CSH Severity: Low
CVSS v4: 8.5 [CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N]
CVE-ID: CVE-2012-0217
CWE-ID: CWE-264
Exploitation vector: Local access
Exploit availability: The vulnerability is being exploited in the wild

Vulnerability details

The vulnerability allows a local user to escalate privileges on the system.

The vulnerability exists due to Intel processors sysret to non-canonical address behavior. This is a vulnerability following from a difference of behaviour of sysret in Intel's version of the amd64 architecture, em64t.

System calls may be implemented as using the em64t syscall/sysret instruction pair.

syscall saves the context of the calling unprivileged process before executing a system call in kernel mode; sysret restores it and resumes ordinary operations in user mode.

In the Intel implementation of sysret, if you have invalid information about the "next instruction" address in your saved context, the sysret instruction will trigger a trap in kernel space. However the sysret instruction is executed with the user stack pointer already loaded, so the kernel fault frame is written to the user stack. The kernel is unable to safely recover from this, so must ensure that the trap doesn't happen.

If your invalid "next instruction" address is in kernel space or in user space (and in the latter case, not where your program is) the program will segfault or execute attacker controlled code. If it is in the gap between user space and kernel space, the CPU will reset, except if someone managed to seed the address location with a valid instruction.

Successful exploitation of the vulnerability may allow an attacker to gain root access to the affected system.


Affected software

NetBSD
Debian Linux
Gentoo Linux
SUSE Linux
xen (Alpine package)
app-emulation/xen
app-emulation/xen-pvgrub
app-emulation/xen-tools

How to mitigate CVE-2012-0217

The fix in the following versions will disallow sysret to
an invalid address.

src/sys/arch/amd64/amd64/machdep.c
HEAD 1.184
netbsd-6 1.175.2.6
netbsd-5 1.102.4.14
netbsd-5-1 1.102.4.13.2.1
netbsd-5-0 1.102.4.10.2.2
netbsd-4 1.44.2.7
netbsd-4-0 1.44.2.3.6.1

src/sys/arch/amd64/amd64/netbsd32_machdep.c
HEAD 1.77
netbsd-6 1.74.10.2
netbsd-5 1.55.4.4
netbsd-5-1 1.55.4.3.2.1
netbsd-5-0 1.55.6.3
netbsd-4 1.30.2.4
netbsd-4-0 1.30.2.1.6.1


xen (Alpine package) - update to 4.1.1-r3
app-emulation/xen - update to 4.2.2-r1
app-emulation/xen-pvgrub - update to 4.2.2-r1
app-emulation/xen-tools - update to 4.2.2-r3

Links to Public Exploits and PoC-codes

External References

Related Security Bulletins