Successfully reported this slideshow.

Chapter 10


Published on


Published in: Education, Technology
  • Be the first to comment

Chapter 10

  1. 1. Linux Networking and Security Chapter 10 File Security
  2. 2. File Security <ul><li>Correctly set up special Linux file permissions </li></ul><ul><li>Monitor log files to check suspicious system activity </li></ul><ul><li>Automate checks for file integrity and unauthorized modifications </li></ul>
  3. 3. Reviewing Linux File Permissions <ul><li>Unauthorized users may want to: </li></ul><ul><ul><li>view files to access or to see how security settings are configured </li></ul></ul><ul><ul><li>delete data to make it unavailable, disrupt business plans, or corrupt system configurations </li></ul></ul><ul><ul><li>modify existing files or create new files, either to corrupt data, to cover signs of their activity, or to alter security settings for their continued purposes </li></ul></ul><ul><li>The first line of defense is careful use of Linux file permissions </li></ul>
  4. 4. Reviewing Linux File Permissions
  5. 5. Reviewing Linux File Permissions
  6. 6. Reviewing Linux File Permissions <ul><li>For any file or directory, standard Linux file permissions are: </li></ul><ul><ul><li>read (represented by r) </li></ul></ul><ul><ul><li>write (represented by w) </li></ul></ul><ul><ul><li>execute (represented by x) </li></ul></ul><ul><li>Each can be assigned to: </li></ul><ul><ul><li>the owner of a file or directory (u, for user) </li></ul></ul><ul><ul><li>to a group defined in /etc/group (g) </li></ul></ul><ul><ul><li>to all other users who are logged in but who are not the owner or part of the named group (o) </li></ul></ul>
  7. 7. Reviewing Linux File Permissions <ul><li>Several Linux distributions use a techniques called User Private Groups to enhance file-based security </li></ul><ul><li>Because every file and directory are assigned both a user and a group, each with separate permissions, it is more secure to have a group with only a single member, then make that the default group for all files created by that user </li></ul>
  8. 8. Reviewing Linux File Permissions <ul><li>Other group-related techniques to help manage file security </li></ul><ul><ul><li>When SGID is set on a directory, any file created within that directory is assigned the group of the directory, rather than the group of the user that creates the file </li></ul></ul><ul><ul><li>Members of a group can be denied access, which implies that all authorized users have a certain level of access, but users of this particular group can not access the file or directory </li></ul></ul>
  9. 9. Using the System Log for Security Checks <ul><li>System log files may reveal security problems </li></ul><ul><li>These files record the activity of programs such as login, FTP, email servers and many others </li></ul><ul><li>System log files are usually stored in /var/log/messages </li></ul><ul><li>A number of utilities can help watch for log messages that indicate potential security violations </li></ul>
  10. 10. Using the System Log for Security Checks <ul><li>Log files require regular attention because they can become very large </li></ul><ul><li>The logrotate command helps automate the process of compressing and archiving log files so that the logs don’t grow unreasonably large, and so that older log data can be stored in another location </li></ul><ul><li>logrotate is executed through the cronjob entry stored in /etc/cron.daily and is configured by etc/logrotate.conf </li></ul>
  11. 11. Using the System Log for Security Checks <ul><li>The programs running on Linux system are constantly adding to their corresponding log files and this information needs to be tracked </li></ul><ul><li>The logfile information can be viewed by: </li></ul><ul><ul><li>opening the log file in a text editor </li></ul></ul><ul><ul><li>using the grep or the tail commands </li></ul></ul><ul><li>If running Linux with a graphical desktop, use the xlogmaster program to view system resources, including the system log file </li></ul>
  12. 12. Using the System Log for Security Checks
  13. 13. Using the System Log for Security Checks
  14. 14. Using the System Log for Security Checks <ul><li>The logcheck package does much more than display log entries - it checks them hourly for suspicious entries and if found, they are emailed to the root user </li></ul><ul><li>The logcheck package is not part of most Linux distributions, but can be obtained from various Internet download sites </li></ul><ul><li>The commercial version of logcheck is called LogSentry offered by Psionic Technologies </li></ul>
  15. 15. Maintaining File Integrity <ul><li>It is necessary to keep track of the state of important system files for any unexpected changes, due to the fact that some crackers can gain access and the system log does not indicate a problem </li></ul><ul><li>Once a cracker has obtained root access, a way to maintain that access is to use a rootkit, a collection of programs and scripts designed to permit continued access, even if the original break-in is discovered </li></ul>
  16. 16. Maintaining File Integrity
  17. 17. Maintaining File Integrity <ul><li>The chkrootkit package is used to check the system for evidence of a rootkit </li></ul><ul><li>This package includes a script that works much like a virus checker, and though it can report the presence of a rootkit, it cannot eliminate it from the system </li></ul><ul><li>chkrootkit can check for modifications to user login files, and for Linux Kernel modules (LKMs), which permit complete access to your system </li></ul>
  18. 18. Maintaining File Integrity <ul><li>If a rootkit is discovered on the system: </li></ul><ul><ul><li>If possible, shut down networking on the server until the problem is cleaned up </li></ul></ul><ul><ul><li>Back up the entire system, including all of the operating system files and all data files; this data can be reviewed later to assist in tracking down the cracker </li></ul></ul><ul><ul><li>Rebuild the system, either by updating the infected packages, or by reinstalling the entire operating system </li></ul></ul>
  19. 19. Maintaining File Integrity <ul><li>A broader more constant approach to file security than checking for rootkits, is to watch the integrity of files on the system </li></ul><ul><li>Tripwire is the best known integrity checker </li></ul><ul><li>Tripwire is available in a free version included with many Linux distributions and a commercial version is available from Tripwire, Incorporated </li></ul>
  20. 20. Maintaining File Integrity
  21. 21. Maintaining File Integrity <ul><li>To use Tripwire, start with a freshly installed system before it is connected to any networks </li></ul><ul><li>Tripwire creates a baseline, or snapshot, of the critical system files according to a policy that is configured by the system administrator </li></ul><ul><li>Once the baseline is established, Tripwire is run at regular intervals to see whether the state of the system has changed </li></ul><ul><li>Tripwire configuration files are protected by a cryptographic signature </li></ul>
  22. 22. Maintaining File Integrity <ul><li>Another file integrity checker is Samhain and some of its key features are: </li></ul><ul><ul><li>Runs as a daemon instead of a cron job </li></ul></ul><ul><ul><li>Can detect kernel modules that were loaded as part of a rootkit </li></ul></ul><ul><ul><li>Can operate in a client/server environment </li></ul></ul><ul><ul><li>Report and audit logs are supported </li></ul></ul><ul><ul><li>Database and configuration files are signed </li></ul></ul><ul><ul><li>Runs on a number of UNIX and Linux platforms </li></ul></ul><ul><ul><li>HTML status pages show information about any client system being monitored </li></ul></ul>
  23. 23. Maintaining File Integrity <ul><li>For more tools regarding file integrity, consider installing the binutils package </li></ul><ul><li>binutils includes more than a dozen utilities useful for exploring the contents of files </li></ul><ul><ul><li>objdump allows examination of the contents of a file byte by byte </li></ul></ul><ul><ul><li>strings lists all the text strings within any binary file, including system utilities and shared libraries </li></ul></ul>
  24. 24. Chapter Summary <ul><li>Crackers who break into a system typically want to view or modify the files on that system, either for their own direct use or to cause problems for the organization running the server </li></ul><ul><li>Linux file permissions do not allow such sophisticated control as some other operating systems because they only permit assigning rights to a file’s owner, a single group, and to all other users </li></ul><ul><li>User Private Groups enhance security by creating a group for each new user account; when that user creates files, no other group member will have access to them </li></ul>
  25. 25. Chapter Summary <ul><li>Using file permissions can create unexpected results unless you are familiar with their exact consequences </li></ul><ul><li>Log files are important to system security because they may contain evidence of crackers attempting to break into a system or of actions by programs running on the system that indicate security issues </li></ul><ul><li>Rotating logs keeps them a manageable size and permits easy backup by breaking log entries into groups by date </li></ul><ul><li>Running the logrotate command as a cron job makes automated log rotation easy </li></ul>
  26. 26. Chapter Summary <ul><li>System services are continually adding lines to the log files and they are often reviewed using the grep search utility or the tail program </li></ul><ul><li>The xlogmaster program displays log file and other system data in a graphical window </li></ul><ul><li>The logcheck utility package watches log files for specific words and phrases that may indicate an attempted security breach or a successful one </li></ul><ul><li>The commercial version of logcheck is called LogSentry and is available from Psionic Technologies </li></ul>
  27. 27. Chapter Summary <ul><li>Crackers hide their activities by replacing system utilities with new versions designed to ignore special cracker-related files, or to prevent reporting the crackers processes and networking connections </li></ul><ul><li>A rootkit helps a cracker easily install a number of programs on a compromised system that permit continued root access; the chkrootkit package can detect many of these, much like a virus checker </li></ul><ul><li>Linux rootkits often include loadable kernel modules (LKMs) that are particularly useful for crackers and difficult to detect without the proper software </li></ul>
  28. 28. Chapter Summary <ul><li>To remove a rootkit, you can reinstall affected programs, or you may choose to reinstall the entire operating system </li></ul><ul><li>A simple step to protect a system from further damage by rootkits is to store statically linked copies of core utilities on diskette or CD-ROM to use when examining a system that has a suspected rootkit </li></ul><ul><li>Regularly checking the integrity of system utilities and configuration files will help you identify changes made by unauthorized users; Tripwire is the most widely used utility for checking the integrity of files and directories </li></ul>
  29. 29. Chapter Summary <ul><li>To use Tripwire, you set up a policy and configuration text files, generate policy and configuration binary files with cryptographic signatures, then establish a baseline snapshot of the system; comparison snapshots are made at regular intervals to determine unexpected system alterations </li></ul><ul><li>Tripwire utilities such as twprint and twadmin let you maintain up-to-date policy files and manage the Tripwire reports </li></ul>
  30. 30. Chapter Summary <ul><li>Another impressive file integrity-checking package is Samhain; this package provides a client/server model to allow maintenance of multiple servers from a central location, plus it runs continually rather than occasionally, as Tripwire does </li></ul><ul><li>The binutils package includes several useful utilities for exploring Linux files; the strings command is one example and it displays all text strings stored in any binary file </li></ul>