Replies: 19 comments
-
Two questions from a long time debian+opesmtpd user: in your post you described the severity of the vulnerability for the mbox, maildir and lmtp cases, but what about mda? My config looks like this is dovecot run directly as an unprivileged user or it goes through a vulnerable intermediate process run as root? By checking the logs it looks like an attempted attack was made while I was vulnerable, the log line looks like
from my understanding the attack failed (because the RCPT TO was not valid), so no (privileged or not) process has been executed in this case, right? |
Beta Was this translation helpful? Give feedback.
-
I didn't mention I say potentially vulnerable because this is directly related to the command used, some may have no impact, others may have the same impact as
This command is vulnerable but dovecot is ran as unprivileged user "mail", not root.
The attack failed indeed because in this case you are not accepting MAIL FROM unless the session is authenticated. As a result, the bug didn't get a chance to propagate to the mda layer, the MAIL FROM was rejected during the SMTP session. |
Beta Was this translation helpful? Give feedback.
-
Users can avoid dangerous code by not using |
Beta Was this translation helpful? Give feedback.
-
Unfortunately I saw the advisory waaaaay too late due to travel. There definitely are exploitation attempts in my logs:
Would there be anything in the logs on a successful one? I'm currently trying to figure out if I need to reinstall the machine. Did I dodge a bullet here because my config should only allow local users to send to the empty domain? My config looks like this:
/var/mail/domains contains a list of fully qualified domains. /var/mail/virtuals looks like this:
(The last line is because user1 receives mail from other VMs) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply. I was reading again your post, and from my little understanding of how mail delivery works, although in the general case there has to be a process running as root, in some configurations this may not be so. Correct me if I am wrong, but with a config like mine, with just one type of receive action
opensmtpd could drop privileges to user mail on startup, and not have any process running as root, maybe? I don't know how complicated could it be to make a config-dependent privilege dropping, but if it can be done in many or widely used cases, it could be worth it. |
Beta Was this translation helpful? Give feedback.
-
In a vulnerable OpenSMTPD, only maildir is safe. On a fix OpenSMTPD, yes you are right: only I'm working with other OpenBSD hackers on lifting the requirement for privileges in |
Beta Was this translation helpful? Give feedback.
-
These attempts failed for a variety of reasons ranging from not understanding how the exploit works and trying to use it on an authenticated listener where MAIL is not processed for unauthenticated sessions.
On a successful one, you'd see the session accepted for delivery, the exploit doesn't happen during the session but is deferred to be executed during the delivery. If you don't see a message accepted for a session with a bogus MAIL FROM, it's supposedly good... if you are sure your logs were not altered.
You dodged a bullet because you used |
Beta Was this translation helpful? Give feedback.
-
Yes, this action would create a process and immediately drop privileges to user
That is already what happens |
Beta Was this translation helpful? Give feedback.
-
Actually I was suggesting to drop the privileges at startup if the config allows it, before even accepting connections from sockets, thus having absolutely no process running as root where an escalation can occur. It's just a random thought, if it's not possible/too cumbersome to implement don't worry. |
Beta Was this translation helpful? Give feedback.
-
It is not really possible but if we disallow delivery to root, the result will be very similar to be honest, the dangerous part is here |
Beta Was this translation helpful? Give feedback.
-
Besides all other improvements I'd suggest to make the server banner override-able inside the config instead of using the default SMTPD_NAME. This will not improve security directly but makes it harder to search for possible targets available in public databases for mass exploitation. |
Beta Was this translation helpful? Give feedback.
-
Maildir by default! Eliminating bugs is a noble pursuit, but making the secure path the easiest path is the first step. mbox is a terrible format designed to solve problems of slow filesystems on slow disks. That's not the current problem. Death to mbox. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to say, a bit late though, a sentence I heard a lot when I was a child : "Seuls ceux qui ne font rien ne font pas d'erreurs". (I know you understand it) |
Beta Was this translation helpful? Give feedback.
-
Hi, maybe for the Linux side of things it could use |
Beta Was this translation helpful? Give feedback.
-
FWIW, I think that the previous use of A good analogy is SQL statements, where you generally should use prepared SQL statements instead of string-formatting them. With string-formatted SQL statements, you need to very carefully escape the data that you embed in your SQL string that the database will interpret as a statement. This actually requires knowledge of the SQL parser's grammar. With prepared statements, where any data is passed out of band, no knowledge of the grammar is required at all. The worst that can happen is that some insufficient validation results in the SQL statement applying to some unexpected data, but the statement itself remains the same. The problem becomes much, much worse for shells. Not only are there multiple confusing ways to quote strings with various levels of effectiveness already (compare the output of
Consequently, I am of the opinion that using |
Beta Was this translation helpful? Give feedback.
-
Apart from that, a question to help me assess how vulnerable my server was before I applied the patches: My configuration only matches actions for external connections for some specific domains. That is, while I allow full relaying locally, I only have two non-obvious domains where mails from outward-facing interfaces are allowed (one of the actions is a "relay host" action, the other is indeed an mbox one). There are more generic matches, including Am I right in the assumption that in order to exploit the bug, an attacker would have to know one of the two domains, because otherwise the attempt would fail at the My mail server does not advertise either of the two domains in its welcome banner or through its DNS reverse PTR, so I think it's very unlikely that automatic scanning/exploiting would know a proper recipient domain. In particular, most vulnerability scanners seem to use just |
Beta Was this translation helpful? Give feedback.
-
@ejelly regarding your first comment I'm not so convinced by your rationale: assuming we only take care of That doesn't mean we won't replace As for your second comment, you are right, the envelope needs to be accepted for the exploit to work and that recipient must use |
Beta Was this translation helpful? Give feedback.
-
Since last OpenSMTPd upgrade I have a small regression with local email sender hostname. |
Beta Was this translation helpful? Give feedback.
-
At the moment I set |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions