Server Administration
  Home arrow Server Administration arrow Maintain Security with sendmail
IBM Developerworks
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
SERVER ADMINISTRATION

Maintain Security with sendmail
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-24

    Table of Contents:
  • Maintain Security with sendmail
  • 4.2 The Environment
  • 4.3 SMTP Probes
  • 4.4 The Configuration File

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Maintain Security with sendmail
    (Page 1 of 4 )

    The most poular email routing program is sendmail. This article, the first in a series, will show you how to keep your sendmail program secure. It is excerpted from chapter four of sendmail, fourth edition, written by Bryan Costales, Claus Assmann, George Jansen and Gregory Shapiro (O'Reilly, 2007; ISBN: 0596510292). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    When the administrator is not careful, the misuse or misconfiguration of sendmail  can lead to an insecure and possibly compromised system. Since pre-V8.12 sendmail is often installed to run as a set-user-id root  process, it is a prime target for intrusion.* The “Internet worm,” for example, used a flaw in old versions of sendmail as one way to gain entry to thousands of machines.† If sendmail  is not properly installed, improper file permissions can be used to trick the system into giving away root privilege.

    In this chapter, we present several ways to protect your site from intrusion via sendmail. Most of these are just good common sense, and the experienced system administrator might be offended that we state the obvious. But not all system administrators are experienced, and not all who administer systems are system administrators. If you fall into the latter category, you might wish to keep a good, general Unix reference by your side to better appreciate our suggestions.

    4.1   Why root?

    One common complaint about sendmail centers on the fact that it is often run, set-user-id root  (that is, run as root no matter who actually runs it).‡ Beginning with V8.12, the default is to run sendmail as a user other than root. The listening daemon needs to be root, but sendmail  itself no longer needs to be set-user-id root.

    For the most part, it is necessary for sendmail  to run as root  to satisfy legitimate needs. Consider the following:

    1. Users want ~/.forward files to work even when their home directory is set to mode 700. The sendmail  program requires root  privilege so that it can temporarily become the user to read and process the ~/.forward file.
    2. Users want :include: mailing-list files readable only by themselves and sendmail. The sendmail  program requires root privilege so that it can temporarily become the owner of the list.
    3. Users want programs that run on their behalf to run as themselves. This requires root  privileges, and running as anything else would be potentially very dangerous.
    4. Users want sendmail to listen on TCP/IP ports that are common (ports 25 and 587). The sendmail  program requires root privilege so that it can initiate listening connections to privileged ports.

    Some folks have been tempted to run sendmail as an untrusted pseudouser (such as nobody). But this doesn’t really work. For example, it causes programs in users’ ~/.forward files to be run as nobody, and it requires the queue to be owned by nobody. Consequently, such a scheme allows any user to break into and modify the queue.*

    4.1.1   Test seteuid and setreuid

    Clearly, many of sendmail's duties require it to run as root. As a corollary, however, whenever sendmail does not need to be root, it should become the appropriate non-privileged user. It does this by using the following bit of logic:

    1. If it was compiled with support for seteuid(3) (§3.4.76 on page 151), use that routine to set the effective uid  to that of the desired non-root  user. This is less preferred than the following.
    2. If it was compiled with support for setreuid(3) (§3.4.12 on page 114), use that routine to set the effective and real uids to those of the desired non-root user.
    3. Otherwise, use setuid(3) to become the desired non-root user.

    Note that setreuid(3) is preferred over
    seteuid(3)† and setuid(3) because it allows sendmail  to temporarily give away both its real and effective root  privilege, then to get it back again. To illustrate the need for this behavior, consider processing a mailing list that saves mail to two different files:

      /u/bill/archive      ←owned by the user bill, mode 4600
     
    /u/alice/archive     ←owned by the user alice, mode 460
    0

    Further consider that these files both have permissions of set-user-id  to the individual users* and are writable only by the individual users. To perform delivery in this instance, sendmail  must† first become bill  (this requires root  privilege). To become another user, sendmail  forks. The parent remains root and the child becomes the user, bill in our example. When it is done, the child exits. The parent sendmail  remains root  so that it can next become alice. By retaining a real uid  of root, sendmail  is able to change its effective uid  to one user after another as needed.

    See the description of the test  directory in §3.4.76 on page 151 for more on this subject.

    More Server Administration Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "sendmail, fourth edition," published by...
     
     

    Buy this book now. This article is excerpted from chapter four of sendmail, fourth edition, written by Bryan Costales, Claus Assmann, George Jansen and Gregory Shapiro (O'Reilly, 2007; ISBN: 0596510292). Check it out today at your favorite bookstore. Buy this book now.

    SERVER ADMINISTRATION ARTICLES

    - Security Features of sendmail
    - Handling sendmail Permissions
    - Maintain Security with sendmail
    - Generating Your Own Security Certificates Fo...
    - Introduction to crontab


     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway