Zimbra Sender Login Mismatch: 4 Easy Steps, Avoid Lockouts
A sender login mismatch happens when a user logs in to your mail server as one account but sends mail with the address of another. On Zimbra you can make Postfix refuse a sender login mismatch, so a stolen or careless account cannot pretend to be your CEO. This article shows the four steps from the original post and, more importantly, what the Postfix documentation says each setting does, so you do not lock out your own users.
How this article was written: there is no Zimbra server in the author's lab, so nothing here is a fresh test run. The commands and the two zmprov outputs come from the original post, where an operator ran them on a real Zimbra mail server. All explanations of Postfix behaviour are taken from the Postfix postconf(5) manual.
Contents
- What a sender login mismatch check does
- How the sender login mismatch map is searched
- Check the Zimbra unlisted sender settings
- Enable the settings and add the restriction
- Test the sender login mismatch rule safely
- What the sender login mismatch rule does not protect
- Common mistakes with a sender login mismatch rule
- FAQ
What a sender login mismatch check does
Postfix has two related restrictions, and the original post used the short alias. According to the manual, reject_sender_login_mismatch is, since Postfix 2.1, an alias for reject_authenticated_sender_login_mismatch and reject_unauthenticated_sender_login_mismatch together. Their meaning is:
- Authenticated: reject the request when the client is authenticated with SASL, but either the MAIL FROM address is not listed in
smtpd_sender_login_maps, or the SASL login name is not an owner of that address. - Unauthenticated: reject the request when SASL is enabled, the MAIL FROM address is listed in
smtpd_sender_login_maps, but the client is not authenticated.
The manual describes smtpd_sender_login_maps as an optional lookup table with the SASL login names that own each envelope sender address; its default is empty. This is the key point of the whole topic: the restriction only works with a populated map. With an empty map, the first rule above means every authenticated sender is "not listed", so you must confirm that your Zimbra server has the map configured before you turn the restriction on. A quick check is postconf smtpd_sender_login_maps as the zimbra user.
How the sender login mismatch map is searched
The sender login mismatch check is only as good as its map, so it helps to know how Postfix reads it. The manual says tables are searched in the order given until a match is found, and that for a sender address user@domain three lookups are done with a clear precedence:
user@domain: always done, highest precedence.user: done only when the domain part of the sender address matches$myorigin,$mydestination,$inet_interfacesor$proxy_interfaces.@domain: done last, lowest precedence.
In every case the result must be either "not found" or a list of SASL login names separated by commas or spaces. A sender login mismatch is therefore decided by comparing the login name of the connection with that list. If a shared mailbox such as info@example.com may be used by three people, the map must return all three login names for that one address.
Check the Zimbra unlisted sender settings
The original post first checked two Zimbra global settings. Run these as the zimbra user:
$ zmprov gacf | egrep zimbraMtaSmtpdRejectUnlistedSender
$ zmprov gacf | egrep zimbraMtaSmtpdRejectUnlistedRecipient
zimbraMtaSmtpdRejectUnlistedSender: no
zimbraMtaSmtpdRejectUnlistedRecipient: no
On the operator's server both were set to no. They correspond to the Postfix parameters smtpd_reject_unlisted_sender and smtpd_reject_unlisted_recipient. The manual says the first one rejects mail from unknown sender addresses and "can slow down an explosion of forged mail from worms or viruses", with a Postfix default of no. The second rejects mail for unknown recipients and prevents the queue from filling up with undeliverable bounce messages; its Postfix default is yes.
Enable the settings and add the restriction
To turn both settings on, the post used:
$ zmprov mcf zimbraMtaSmtpdRejectUnlistedRecipient yes
$ zmprov mcf zimbraMtaSmtpdRejectUnlistedSender yes
Then it edited /opt/zimbra/conf/zmconfigd/smtpd_sender_restrictions.cf and put the restriction right after permit_mynetworks, so the line reads:
permit_mynetworks, reject_sender_login_mismatch
Order matters, and the manual states it: restrictions are applied in the order specified, and the first restriction that matches wins. Because permit_mynetworks comes first, clients in your trusted networks are allowed before the sender login mismatch check runs. Only other clients, typically users on the internet, are checked. Finally restart the MTA so that the file is read:
$ zmmtactl restart
Keep a copy of the original .cf file before editing. Check the line again after every Zimbra upgrade, in case the file was replaced.
Test the sender login mismatch rule safely
Test the sender login mismatch rule with a spare account before you announce the change. Send a message through port 587 with authentication as account A, using the address of account B as the sender. The Postfix manual says the check should reject the request when the login name is not an owner of the sender address. Watch /var/log/zimbra.log for the rejection while you test. Then send normally as account A with its own address to make sure legitimate mail still passes. If your users have aliases or distribution list addresses they send as, test those too, because the mismatch rule depends on the owner list returned by smtpd_sender_login_maps.
What the sender login mismatch rule does not protect
Do not rely on the sender login mismatch check for the visible From: header. The Postfix manual says explicitly that these restrictions check the envelope sender (MAIL FROM), and that to enforce that the From: header address matches the envelope sender you need an external filter such as a Milter on the submission service. A user can still show any From: header unless you add such a filter.
Common mistakes with a sender login mismatch rule
- Enabling
reject_sender_login_mismatchwhilesmtpd_sender_login_mapsis empty, which rejects every authenticated sender. - Putting the restriction before
permit_mynetworks, so that internal servers and scripts are rejected too. - Forgetting aliases and shared mailboxes that users legitimately send from.
- Skipping the restart of the MTA, so the old restrictions stay active.
If a client is rejected for another reason, the troubleshooting guides on Zimbra error 450 4.7.1 sender reject and client host rejected: access denied explain two other common SMTP rejections.
FAQ
Does this stop spam coming from the outside? No. It only controls who may use which sender address when they log in to your server.
Can I use reject_known_sender_login_mismatch instead? The manual describes it as protecting only addresses that are listed in the map while still allowing any unlisted sender address, which is gentler if your map is incomplete.
This comment has been removed by the author.
ReplyDelete