ProblemYou want to disable certain SMTP commands. SolutionAdd the confPRIVACY_FLAGS define to the sendmail configuration to set PrivacyOptions that disable unwanted, optional SMTP commands. This sample define disables the EXPN , VRFY , VERB , and ETRN commands: dnl Disable EXPN, VRFY, VERB and ETRN define(`confPRIVACY_FLAGS', `noexpn,novrfy,noverb,noetrn') Build the sendmail.cf file, copy it to /etc/mail/sendmail.cf , and restart sendmail, as described in Recipe 1.8. DiscussionThe confPRIVACY_FLAGS define sets PrivacyOptions flags in the sendmail.cf file. One of the things that these flags can do is disable unwanted, optional SMTP commands. By default, sendmail supports the full array of SMTP commands, as this simple test shows: # sendmail -bs -Cgeneric-linux.cf 220 chef.wrotethebook.com ESMTP Sendmail 8.12.9/8.12.9; Mon, 10 Mar 2003 14:39:47 -0500 EHLO localhost 250-chef.wrotethebook.com Hello root@localhost, pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP EXPN <admin> 250-2.1.5 <anna@crab.wrotethebook.com> 250-2.1.5 <andy@rodent.wrotethebook.com> 250 2.1.5 <jane@rodent.wrotethebook.com> VRFY <alana> 250 2.1.5 Alana Henson <alana@chef.wrotethebook.com> QUIT 221 2.0.0 chef.wrotethebook.com closing connection In response to the EHLO command, the SMTP server lists the SMTP extensions it supports, including optional commands. Some of these commands, VRFY , EXPN , and VERB , provide information that a security-conscious site might not wish to provide:
After reconfiguring sendmail with the confPRIVACY_FLAGS define shown in Recipe 10.14.2, rerunning the test produces very different results: # sendmail -bs 220 chef.wrotethebook.com ESMTP Sendmail 8.12.9/8.12.9; Mon, 10 Mar 2003 14:47:35 -0500 EHLO localhost 250-chef.wrotethebook.com Hello root@localhost, pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP EXPN <admin> 502 5.7.0 Sorry, we do not allow this operation VRFY <alana> 252 2.5.2 Cannot VRFY user; try RCPT to attempt delivery (or try finger) QUIT 221 2.0.0 chef.wrotethebook.com closing connection Now the server advertises a smaller set of features, and returns errors when the EXPN and VRFY commands are entered. In addition to the noexpn , novrfy , and noverb flags, the sample define in Recipe 10.14.2 uses the noetrn flag. In the first test, the system advertised the ETRN command. After this recipe is applied, the server no longer advertises or supports that command. ETRN is used by remote systems to cause the server to run the queue. ETRN is an important command for supporting dial-in clients that need to have the queue run while they are online. Our sample system does not support dial-in SMTP clients , so we have disabled the ETRN command to prevent remote sites from forcing the server to run the queue. The noexpn , novrfy , and noverb flags could all have been set using the goaway flag. The goaway flag sets several flags at once. In addition to the noexpn , novrfy , and noverb flags, the goaway flag sets:
The goaway flag does not set the noetrn flag used in this recipe, nor does it set the public and noreceipts flags described above. Additionally, it does not set the restrictexpand , restrictmailq , and restrictqrun flags. noetrn and noreceipts are not used because they disable features that are, in certain circumstances, very useful. The goaway flag does not use public because it lessens security. restrictexpand , restrictmailq , and restrictqrun are not used because those flags affect who can use certain options on the sendmail command line; they do not affect the SMTP protocol or security interactions with remote systems that are the target of the goaway flag. [8] goaway is a good choice for enhanced sendmail security. However, this recipe shows that individual flags can also be selected to create a custom security configuration.
Even more custom control is available through creating custom rulesets. The rulesets check_vrfy , check_expn , and check_etrn can be used to define custom controls for the VRFY , EXPN , and ETRN commands, respectively. This recipe disables these commands completely. See AlsoRecipe 10.15 and Recipe 10.16 provide related material. The sendmail book covers the PrivacyOptions in Section 24.9.80. |