CVE-2020-7247 exploit: LPE and RCE in OpenBSD’s OpenSMTPD

I’ve written an exploit for the local privilege escalation and remote command execution vulnerability in OpenBSD’s OpenSMTPD recently reported by Qualys as CVE-2020-7247:

“smtp_mailaddr in smtp_session.c in OpenSMTPD 6.6, as used in OpenBSD 6.6 and other products, allows remote attackers to execute arbitrary commands as root via a crafted SMTP session, as demonstrated by shell metacharacters in a MAIL FROM field. This affects the uncommented default configuration. The issue exists because of an incorrect return value upon failure of input validation.”

My exploit has been tested on OpenBSD 6.6 and Debian GNU/Linux bullseye/sid. It’s available here: