CVE-2018-14665 exploit: local privilege escalation on OpenBSD 6.3 and 6.4

This is my take on the recent Xorg vulnerability (CVE-2018-14665):

“A flaw was found in xorg-x11-server before 1.20.3. An incorrect permission check for -modulepath and -logfile options when starting Xorg. X server allows unprivileged users with the ability to log in to the system via physical console to escalate their privileges and run arbitrary code under root privileges.”

My exploit specifically targets OpenBSD’s cron in order to escalate privileges to root on OpenBSD 6.3 and 6.4. You don’t need to be connected to a physical console, it works perfectly on pseudo-terminals connected via SSH as well.

The code is available here:

https://github.com/0xdea/exploits/blob/master/openbsd/raptor_xorgasm