CVE-2020-7247: OpenSMTPD Remote Code Execution Vulnerability
smtp_mailaddr in smtp_session.c in OpenSMTPD, as used in OpenBSD and other products, allows remote attackers to execute arbitrary commands as root via a crafted SMTP session.
CVE-2020-7247 is a remote code execution vulnerability in OpenSMTPD, the SMTP server used in OpenBSD and other products. A crafted SMTP session can let an unauthenticated attacker run arbitrary commands with root privileges on the mail server. Because mail transfer agents are often internet-facing and privileged, successful exploitation can give an attacker full control of the host and a foothold for further movement.
Defenders should treat this as a high-priority issue for any system running OpenSMTPD until the vendor update has been applied and verified. Specifics such as exact affected releases must be confirmed against the vendor advisory.
How it works
The vulnerability is rooted in improper handling of exceptional conditions (CWE-755) that leads to OS command injection (CWE-78). In the smtp_mailaddr function within smtp_session.c, OpenSMTPD fails to sanitize or correctly reject certain malformed address data supplied during an SMTP conversation. An attacker who can reach the SMTP service can send a specially crafted session that causes the daemon to pass attacker-controlled input to a shell executed as root.
No local account or prior authentication is required; the attack surface is the network-exposed SMTP listener. The result is arbitrary command execution with the highest privileges on the system. Exact exploit mechanics and any proof-of-concept details are outside the scope of public summary data and should be obtained only from trusted vendor or coordinator advisories if needed for defensive testing.
Am I affected? How to find it in your systems
OpenSMTPD is the default mail transfer agent on OpenBSD and is also packaged for other Unix-like operating systems. It typically listens on TCP port 25 (and sometimes submission ports) on mail relays, gateways, and servers that accept inbound or outbound SMTP.
Inventory steps:
- Identify hosts running OpenSMTPD by checking package databases, service managers, or process lists for the smtpd binary and its configuration files.
- Confirm the installed version against the list of fixed releases published in the vendor advisory; do not rely on version guesses.
- Note whether the SMTP listener is reachable from untrusted networks; internet-facing instances present the highest risk.
- Review SMTP logs and process-accounting records for unusual MAIL FROM/RCPT TO values, unexpected child processes spawned by smtpd, or commands executed under the root context around the time of suspicious sessions.
Network telemetry showing anomalous SMTP traffic patterns or sudden outbound connections originating from the mail server can also indicate exploitation attempts.
How to remediate
The primary remediation is to apply the security update supplied by the OpenBSD project or the downstream vendor that packages OpenSMTPD. Follow the vendor’s instructions exactly for obtaining, verifying, and installing the patched release, then restart the service and confirm the new version is running.
After patching:
- Re-validate that the SMTP service still functions for legitimate traffic.
- Restrict SMTP exposure with host-based or network firewalls so that only required peers can connect.
- Run OpenSMTPD with the least privilege feasible and ensure chroot or other isolation features recommended by the vendor are enabled.
- Keep the underlying operating system and any dependent libraries current.
CISA’s required action is simply to apply updates per vendor instructions; no additional mandatory steps are listed beyond that.
If you can't patch immediately
If an immediate upgrade is not possible, reduce the attack surface while you schedule the patch:
- Segment the mail server so that the SMTP port is reachable only from trusted internal relays or specific external partners; block direct internet access where operationally feasible.
- Place a reverse proxy, mail gateway, or WAF in front of OpenSMTPD that can enforce strict SMTP protocol validation and drop malformed address literals.
- Disable any unnecessary SMTP extensions or features that are not required for your mail flow.
- Increase monitoring: alert on smtpd process trees that spawn shells or unexpected binaries, and forward SMTP and system logs to a central SIEM for rapid review.
- Consider temporary replacement with an alternative MTA if the business can tolerate the cut-over, then return to the patched OpenSMTPD once available.
These measures are compensating controls only; they do not eliminate the underlying flaw.
If your data may have been exposed
Actively exploited remote-code-execution vulnerabilities on mail servers frequently lead to full host compromise, credential theft, and data exfiltration. If you have evidence of exploitation or cannot rule it out, treat the system as breached: isolate it, preserve volatile evidence, rotate credentials, and begin incident-response procedures. You can also run a free exposure scan of your email addresses against known breach data sets to determine whether associated accounts have appeared in prior leaks.
AICompiled with AI assistance from public sources and published under our editorial standards.