{"id":3628,"date":"2014-10-09T10:12:13","date_gmt":"2014-10-09T02:12:13","guid":{"rendered":"http:\/\/rmohan.com\/?p=3628"},"modified":"2014-10-09T10:12:13","modified_gmt":"2014-10-09T02:12:13","slug":"zimbra-improvement-restricted-sendersender-must-login-on-zimbra-8","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3628","title":{"rendered":"ZIMBRA IMPROVEMENT : RESTRICTED SENDER\/SENDER MUST LOGIN ON ZIMBRA 8"},"content":{"rendered":"<p>powerful mail server, Zimbra has some system security features applied by default. We can also applying some additional security policy to increase mail server protection, such as applying PolicyD and Fail2Ban<\/p>\n<p>All the above security rule may be sufficient, but there are some additional security tips should be considered, especially in the case of SMTP authorization.<\/p>\n<p>Look at the following mail flow delivery, sent from or into Zimbra :<\/p>\n<p>From : External User\u00a0\u00a0 To : External User, Result : Relay Access Denied<br \/>\ntelnet mail.rmohan.com 25<br \/>\nTrying 103.XXX.XXX.XXX&#8230;<br \/>\nConnected to mail.rmohan.com.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n220 mail.rmohan.com ESMTP Postfix<br \/>\nehlo mail<br \/>\n250-mail.rmohan.com<br \/>\n250-PIPELINING<br \/>\n250-SIZE 51200000<br \/>\n250-VRFY<br \/>\n250-ETRN<br \/>\n250-STARTTLS<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-8BITMIME<br \/>\n250 DSN<br \/>\nmail from:rmohan@yahoo.com<br \/>\n250 2.1.0 Ok<br \/>\nrcpt to:zezevavai@gmail.com<br \/>\n554 5.7.1 &lt;zezevavai@gmail.com&gt;: Relay access denied<\/p>\n<p>From : External User\u00a0\u00a0 To : Zimbra User, Result : Accepted with prior Scanning for Spam and Viruses<br \/>\ntelnet mail.rmohan.com 25<br \/>\nTrying 103.XXX.XXX.XXX&#8230;<br \/>\nConnected to mail.rmohan.com.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n220 mail.rmohan.com ESMTP Postfix<br \/>\nehlo mail<br \/>\n250-mail.rmohan.com<br \/>\n250-PIPELINING<br \/>\n250-SIZE 51200000<br \/>\n250-VRFY<br \/>\n250-ETRN<br \/>\n250-STARTTLS<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-8BITMIME<br \/>\n250 DSN<br \/>\nmail from:rmohan@yahoo.com<br \/>\n250 2.1.0 Ok<br \/>\nrcpt to:myemail@rmohan.com<br \/>\n250 2.1.5 Ok<br \/>\ndata<br \/>\n354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;<br \/>\nHello Vavai<br \/>\n.<br \/>\n250 2.0.0 Ok: queued as C78EDB6E001<br \/>\nquit<br \/>\n221 2.0.0 Bye<\/p>\n<p>From : Zimbra User\u00a0 To : External User, Result : Accepted with prior SMTP Authorization check<\/p>\n<p>Zimbra should be respond our request\u00a0 with \u201cRelay Access Denied when trying to send emails without prior authorization<br \/>\ntelnet mail.rmohan.com 25<br \/>\nTrying 103.XXX.XXX.XXX&#8230;<br \/>\nConnected to mail.rmohan.com.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n220 mail.rmohan.com ESMTP Postfix<br \/>\nehlo mail<br \/>\n250-mail.rmohan.com<br \/>\n250-PIPELINING<br \/>\n250-SIZE 6144000<br \/>\n250-VRFY<br \/>\n250-ETRN<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-8BITMIME<br \/>\n250 DSN<br \/>\nmail from:rmohan@rmohan.com<br \/>\n250 2.1.0 Ok<br \/>\nrcpt to:myemail@gmail.com<br \/>\n554 5.7.1 &lt;myemail@vavai.com&gt;: Relay access denied<\/p>\n<p>From : Zimbra User\u00a0 To : Zimbra User, Result : Accepted WITHOUT prior SMTP Authorization check<br \/>\ntelnet mail.rmohan.com 25<br \/>\nTrying 103.XXX.XXX.XXX&#8230;<br \/>\nConnected to mail.rmohan.com.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n220 mail.rmohan.com ESMTP Postfix<br \/>\nehlo mail<br \/>\n250-mail.rmohan.com<br \/>\n250-PIPELINING<br \/>\n250-SIZE 6144000<br \/>\n250-VRFY<br \/>\n250-ETRN<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-8BITMIME<br \/>\n250 DSN<br \/>\nmail from:rmohan@rmohan.com<br \/>\n250 2.1.0 Ok<br \/>\nrcpt to:rmohan@rmohan.com<br \/>\n250 2.1.5 Ok<\/p>\n<p>zimbra-logoLook at the last example. I\u2019m trying to send email from rmohan@rmohan.com to rmohan@rmohan.com without prior authorization and Zimbra accepted this email whereas should not. How if I\u2019m trying to send fake email, let\u2019s say from my boss email into my colleagues?<\/p>\n<p>To prevent the above security hole, below are some modification which are able to be applied on Zimbra 8. This modification will force the user to authenticate and login before sending an email to an internal users.<br \/>\n1.Backup all configuration. Incorrect settings while applying \u201csender must login\u201d policy would interfere Zimbra services and would stop your email communication<br \/>\n2.Log in as Zimbra user and edit \/opt\/zimbra\/conf\/zmconfigd.cf<br \/>\nAdd the following lines right under POSTCONF smtpd_recipient_restrictions FILE zmconfigd\/postfix_recipient_restrictions.cfPOSTCONF proxy_read_maps FILE zmconfigd\/proxy_read_maps.cf<\/p>\n<p>and add the following lines right under POSTCONF smtpd_sender_restrictions FILE zmconfigd\/smtpd_sender_restrictions.cf<br \/>\nPOSTCONF smtpd_sender_login_maps proxy:ldap:\/opt\/zimbra\/conf\/ldap-slm.cf<\/p>\n<p>3.Save your changes and then navigate to \/opt\/zimbra\/conf\/zmconfigd\/ folder and edit smtpd_sender_restriction.cfcd \/opt\/zimbra\/conf\/zmconfigd\/<br \/>\nvi smtpd_sender_restrictions.cf<\/p>\n<p>4.Put the following code on the top of the linespermit_mynetworks, reject_sender_login_mismatch<\/p>\n<p>5.Save your change<br \/>\n6.Check your read maps settings with the following command :postconf | grep proxy_read_maps<\/p>\n<p>7.On my Zimbra 8, the result would shown as below<br \/>\n$local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps $sender_bcc_maps $recipient_bcc_maps $smtp_generic_maps $lmtp_generic_maps $alias_maps<\/p>\n<p>8.Create a proxy_read_maps.cf file<br \/>\nvi proxy_read_maps.cf<\/p>\n<p>and add proxy:ldap:\/opt\/zimbra\/conf\/ldap-slm.cf on the last line of postconf result, so the result is supposedly like this:<\/p>\n<p>$local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps $sender_bcc_maps $recipient_bcc_maps $smtp_generic_maps $lmtp_generic_maps $alias_maps, proxy:ldap:\/opt\/zimbra\/conf\/ldap-slm.cf<\/p>\n<p>9.Navigate to \/opt\/zimbra\/conf and create ldap-slm.cf file<br \/>\ncd \/opt\/zimbra\/conf<br \/>\ngrep server_host \/opt\/zimbra\/conf\/ldap-vam.cf<br \/>\ngrep bind_pw \/opt\/zimbra\/conf\/ldap-vam.cf<br \/>\nvi ldap-slm.cf<\/p>\n<p>10.Content of ldap-slm.cf file<br \/>\nserver_host = ldap:\/\/HOST:389<br \/>\nserver_port = 389<br \/>\nsearch_base =<br \/>\nquery_filter = (&amp;(|(zimbraMailDeliveryAddress=%s)(zimbraMailAlias=%s)(zimbraMailCatchAllAddress=%s)(mail=%s))(zimbraMailStatus=enabled))<br \/>\nresult_attribute = zimbraMailDeliveryAddress,zimbraMailForwardingAddress,zimbraPrefMailForwardingAddress,zimbraMailCatchAllForwardingAddress,uid<br \/>\nversion = 3<br \/>\nstart_tls = yes<br \/>\ntls_ca_cert_dir = \/opt\/zimbra\/conf\/ca<br \/>\nbind = yes<br \/>\nbind_dn = uid=zmpostfix,cn=appaccts,cn=zimbra<br \/>\nbind_pw = PASSWORD<br \/>\ntimeout = 30<\/p>\n<p>11.Replace server_host\u00a0 and bind_pw with the result of grep command<br \/>\n12.Save all changes and then run the postfix reload to apply the changes<br \/>\nchown zimbra:postfix ldap-slm.cf<br \/>\npostfix reload<\/p>\n<p>13.Test the policy by telnet to your Zimbra server and send an email from internal to internal users without prior authorizationtelnet mail.rmohan.com 25<br \/>\nTrying XXX.XXX.XXX.XXX&#8230;<br \/>\nConnected to mail.rmohan.com.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n220 mail.rmohan.com ESMTP Postfix<br \/>\nehlo mail<br \/>\n250-mail.rmohan.com<br \/>\n250-PIPELINING<br \/>\n250-SIZE 51200000<br \/>\n250-VRFY<br \/>\n250-ETRN<br \/>\n250-STARTTLS<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-8BITMIME<br \/>\n250 DSN<br \/>\nmail from:rmohan@rmohan.com<br \/>\n250 2.1.0 Ok<br \/>\nrcpt to:rmohan@rmohan.com<br \/>\n553 5.7.1 rmohan@rmohan.com: Sender address rejected: not logged in<br \/>\nNotes : Please backup all configuration before trying to set the \u201cSender must login\u201d policy to prevent\u00a0 unexpected things \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>powerful mail server, Zimbra has some system security features applied by default. We can also applying some additional security policy to increase mail server protection, such as applying PolicyD and Fail2Ban<\/p>\n<p>All the above security rule may be sufficient, but there are some additional security tips should be considered, especially in the case of SMTP [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,45],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3628"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3628"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3628\/revisions"}],"predecessor-version":[{"id":3629,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3628\/revisions\/3629"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}