[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ A ] [ B ] [ C ] [ D ] [ E ] [ F ] [ G ] [ next ]

Securing Debian Manual
Chapter 3 - Before and during the installation


3.1 Choose a BIOS password

Before you install any operating system on your computer, set up a BIOS password. After installation (once you have enabled bootup from the hard disk) you should go back to the BIOS and change the boot sequence to disable booting from floppy, cdrom and other devices that shouldn't boot. Otherwise a cracker only needs physical access and a boot disk to access your entire system.

Disabling booting unless a password is supplied is even better. This can be very effective if you run a server, because it is not rebooted very often. The downside to this tactic is that rebooting requires human intervention which can cause problems if the machine is not easily accessible.

Note: many BIOSes have well known default master passwords, and applications also exist to retrieve the passwords from the BIOS. Corollary: don't depend on this measure to secure console access to system.


3.2 Partitioning the system


3.2.1 Choose an intelligent partition scheme

An intelligent partition scheme depends on the how the machine is used. A good rule of thumb is to be fairly liberal with your partitions and to pay attention to the following factors:

In the case of a mail server it is important to have a separate partition for the mail spool. Remote users (either knowingly or unknowingly) can fill the mail spool (/var/mail and/or /var/spool/mail). If the spool is on a separate partition, this situation will not render the system unusable. Otherwise (if the spool directory is on the same partition as /var) the system might have important problems: log entries will not be created, packages can not be installed, and some programs might even have problems starting up (if they use /var/run).

Also, for partitions in which you cannot be sure of the needed space, installing Logical Volume Manager (lvm-common and the needed binaries for your kernel, this might be either lvm10, lvm6, or lvm5). Using lvm, you can create volume groups that expand multiple physical volumes.


3.2.1.1 Selecting the appropriate file systems

During the system partitioning you also have to decide which file system you want to use. The default file system selected in the Debian installation for Linux partitions is ext2. However, it is recommended you switch to a journalling file system, such as ext3, reiserfs, jfs or xfs, to minimize the problems derived from a system crash in the following cases:

Leaving aside the performance issues regarding journalling file systems (since this sometimes can turn into a religious war), it is usually better to use the ext3 file system. The reason for this is that it is backwards compatible with ext2, so if there are any issues with the journalling you can disable it and still have a working file system. Also, if you need to recover the system with a bootdisk (or CDROM) you do not need a custom kernel. If the kernel is 2.4 ext3 support is already available, if it is a 2.2 kernel you will be able to boot the file system even if you lose journalling capabilities. If you are using other journalling file systems you will find that you might not be able to recover unless you have a 2.4 kernel with the needed modules built-in. If you are stuck with a 2.2 kernel in the rescue disk it might even be more difficult to have it access reiserfs or xfs.

In any case, data integrity might be better under ext3 since it does file-data journalling while others do only meta-data journalling, see http://lwn.net/2001/0802/a/ext3-modes.php3.


3.3 Do not plug to the Internet until ready

The system should not be immediately connected to the Internet during installation. This could sound stupid but network installation is a common method. Since the system will install and activate services immediately, if the system is connected to the Internet and the services are not properly configured you are opening it to attack.

Also note that some services might have security vulnerabilities not fixed in the packages you are using for installation. This is usually true if you are installing from old media (like CD-ROMs). In this case, the system could even be compromised before you finish installation!

Since Debian installation and upgrades can be done over the Internet you might think it is a good idea to use this feature on installation. If the system is going to be directly connected to the Internet (and not protected by a firewall or NAT), it is best to install without connection to the Internet, using a local packages mirror for both the Debian package sources and the security updates. You can set up package mirrors by using another system connected to the Internet with Debian-specific tools (if it's a Debian system) like apt-move or apt-proxy, or other common mirroring tools, to provide the archive to the installed system. If you cannot do this, you can set up firewall rules to limit access to the system while doing the update (see Security update protected by a firewall, Appendix F).


3.4 Set a root password

Setting a good root password is the most basic requirement for having a secure system. See passwd(1) for some hints on how to create good passwords. You can also use an automatic password generation program to do this for you (see Generating user passwords, Section 4.10.14).

FIXME: Add pointers to information about good passwords.


3.5 Activate shadow passwords and MD5 passwords

At the end of the installation, you will be asked if shadow passwords should be enabled. Answer yes to this question, so passwords will be kept in the file /etc/shadow. Only the root user and the group shadow have read access to this file, so no users will be able to grab a copy of this file in order to run a password cracker against it. You can switch between shadow passwords and normal passwords at any time by using shadowconfig.

Read more on Shadow passwords in Shadow Password (/usr/share/doc/HOWTO/en-txt/Shadow-Password.txt.gz).

Furthermore, you are queried during installation whether you want to use MD5 hashed passwords. This is generally a very good idea since it allows longer passwords and better encryption. MD5 allows for passwords longer than 8 characters. This, if used wisely, can make it more difficult for attackers to brute-force the system's passwords. Regarding MD5 passwords, this is the default option when installing the latest password package. You can change this anytime after installation by doing dpkg-reconfigure -plow passwd. You can recognize md5 passwords in the /etc/shadow file by their $1$ prefix.

This, as a matter of fact, modifies all files under /etc/pam.d by substituting the password line and include md5 in it:

           password required pam_unix.so md5 nullok obscure min=6 max=16

If max is not set over 8 the change will not be useful at all. For more information on this read User authentication: PAM, Section 4.10.1.

Note: the default configuration in Debian, even when activating MD5 passwords, does not modify the previously set max value.


3.6 Run the minimum number of services required

Services are programmes such as ftp servers and web servers. Since they have to be listening for incoming connections that request the service, external computers can connect to yours. Services are sometimes vulnerable (i.e. can be compromised under a given attack) and are hence a security risk.

You should not install services which are not needed on your machine. Every installed service might introduce new, perhaps not obvious (or known), security holes on your computer.

As you may already know, when you install a given service the default behavior is to activate it. In a default Debian installation, with no services installed, the footprint of running services is quite low and it's even lower when talking about services offered to the network. The footprint in Debian 2.1 wasn't as tight as in Debian 2.2 (some inetd services were enabled by default) and in Debian 2.2 the rpc portmapper is enabled upon installation. Rpc is installed by default because it is needed for many services, for example NFS, to run on a given system. It can be easily removed, however, see Disabling daemon services, Section 3.6.1 on how to disable it.

When you install a new network-related service (daemon) in your Debian GNU/Linux system it can be enabled in two ways: through the inetd superdaemon (i.e. a line will be added to /etc/inetd.conf) or through a standalone program that binds itself to your network interfaces. Standalone programs are controlled through the /etc/init.d files, which are called at boot time through the SysV mechanism (or an alternative one) by using symlinks in /etc/rc?.d/* (for more information on how this is done read /usr/share/doc/sysvinit/README.runlevels.gz).

If you want to keep some services but use them rarely, use the update-commands, e.g. update-inetd and update-rc.d to remove them from the startup process.


3.6.1 Disabling daemon services

Disabling a daemon service is quite simple. There are different methods:

You can remove the links from /etc/rc${runlevel}.d/ manually or using update-rc.d (see update-rc.d(8)). For example, you can disable a service from executing in the multi-user runlevels by doing:

       update-rc.d stop XX 2 3 4 5 .

Please note that, if you are not using file-rc, update-rc.d -f _service_ remove will not work properly, since all links are removed, upon re-installation or upgrade of the package these links will be re-generated (probably not what you wanted). If you think this is not intuitive you are probably right (see Bug 67095). From the manpage:

       If any files /etc/rcrunlevel.d/[SK]??name already exist then
       update-rc.d does nothing.  This is so that the system administrator 
       can rearrange the  links,  provided that  they  leave  at  least one
       link remaining, without having their configuration overwritten.

If you are using file-rc all the information regarding services bootup is handled by a common configuration file and is maintained even if packages are removed from the system.

You can use the TUI (Text User Interface) provided by rcconf to do all these changes easily (rcconf works both for file-rc and normal System V runlevels).

Other (not recommended) methods of disabling services are: chmod 644 /etc/init.d/daemon (but that gives an error message when booting), or modifying the /etc/init.d/daemon script (by adding an exit 0 line at the beginning or commenting out the start-stop-daemon part in it). Since init.d files are config files, they will not get overwritten upon upgrade.

Unfortunately, unlike other (UNIX) operating systems, services in Debian cannot be disabled by modifying files in /etc/default/_servicename_.

FIXME: Add more information on handling daemons using file-rc


3.6.2 Disabling inetd services

You should stop all unneeded services on your system, like echo, chargen, discard, daytime, time, talk, ntalk and r-services (rsh, rlogin and rcp) which are considered HIGHLY insecure (use ssh instead). After disabling those, you should check if you really need the inetd daemon. Many people prefer to use daemons instead of calling services via inetd. Denial of Service possibilities exist against inetd, which can increase the machine's load tremendously. If you still want to run some kind of inetd service, switch to a more configurable inet daemon like xinetd or rlinetd.

You can disable services by editing /etc/inetd.conf directly, but Debian provides a better alternative: update-inetd (which comments the services in a way that it can easily be turned on again). You could remove the telnet daemon by executing this commands to change the config file and to restart the daemon (in this case the telnet service is disabled):

       /usr/sbin/update-inetd --disable telnet

If you do want services listening, but do not want to have them listen on all IP addresses of your host, you might want to use an undocumented feature on inetd. . Or use an alternate inetd daemon like xinetd.


3.7 Install the minimum amount of software required

Debian comes with a lot of software, for example the Debian 3.0 woody release includes almost 6 CD-ROMs of software and thousands of packages. With so much software, and even if the base system installation is quite reduced [1] you might get carried away and install more than is really needed for your system.

Since you already know what the system is for (don't you?) you should only install software that is really needed for it to work. Any unnecessary tool that is installed might be used by a user that wants to compromise the system or by an external intruder that has gotten shell access (or remote code execution through an exploitable service).

The presence, for example, of development utilities (a C compiler) or interpreted languages (such as perl - but see below -, python, tcl...) may help an attacker compromise the system even further:

Of course, an intruder with local shell access can download his own set of tools and execute them, and even the shell itself can be used to make complex programs. Removing unnecesary software will not help prevent the problem but will make it slightly more difficult for an attacker to proceed (and some might give up in this situation looking for easier targets). So, if you leave tools in a production system that could be used to remotely attack systems (see Remote vulnerability assesment tools, Section 8.1) you can expect an intruder to use them too if available.


3.7.1 Removing Perl

You must take into account that removing perl might not be too easy (as a matter of fact it can be quite difficult) in a Debian system since it is used by many system utilities. Also, the perl-base is Priority: required (that about says it all). It's still doable, but you will not be able to run any perl application in the system; you will also have to fool the package management system to think that the perl-base is installed even if it's not. [3]

Which utilities use perl? You can see for yourself:

       $ for i in /bin/* /sbin/* /usr/bin/* /usr/sbin/*; do [ -f $i ] && {
       type=`file $i | grep -il perl`; [ -n "$type" ] && echo $i; }; done

These include the following utilities in packages with priority required or important:

So, without Perl and, unless you remake these utilities in shell script, you will probably not be able to manage any packages (so you will not be able to upgrade the system, which is not a Good Thing).

If you are determined to remove Perl from the Debian base system, and you have spare time, submit bug reports to the previous packages including (as a patch) replacements for the utilities above written in shell script.


3.8 Read the debian security mailing lists

It is never wrong to take a look at either the debian-security-announce mailing list, where advisories and fixes to released packages are announced by the Debian security team, or at mailto:debian-security@lists.debian.org, where you can participate in discussions about things related to Debian security.

In order to receive important security update alerts, send an email to debian-security-announce-request@lists.debian.org with the word "subscribe" in the subject line. You can also subscribe to this moderated email list via the web page at http://www.debian.org/MailingLists/subscribe

This mailing list has very low volume, and by subscribing to it you will be immediately alerted of security updates for the Debian distribution. This allows you to quickly download new packages with security bug fixes, which is very important in maintaining a secure system. (See Execute a security update, Section 4.8 for details on how to do this.)


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ A ] [ B ] [ C ] [ D ] [ E ] [ F ] [ G ] [ next ]

Securing Debian Manual

2.6 10 October 2002Wed, 18 Sep 2002 14:09:35 +0200
Javier Fernández-Sanguino Peña jfs@computer.org