s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
8. Securing Your DomainThis section deals with setting up security for your new domain. The emphasis is on user-transparent features. If your security is too obtrusive, and interferes strongly with the actions of the users, the users will develop their own workarounds which may compromise the entire domain. The best way to avoid this is to make the security as transparent as possible, and to encourage users to come to you first when they have difficulties which might be related to the security measures of the site. A certain flexibility in attitude is important. I know from personal experience that if the security policy is too rigid, the users will simply set up their own network tunnels through the firewall so they can log in from outside the domain. It's better that remote login procedures, or whatever the users are trying to do, be set up, inspected, and approved by you.
This section deals with securing your network against outside attack, and against casual snooping from within. Securing your site against determined attack from validated users within the private network is a more difficult and involved task, and is beyond the scope of this document.
One of the security considerations used in this section is protecting against the ``hostile router''. The router provided by your ISP may be a remotely configurable computer in its own right, with the administrative password held by your provider. There have been security problems in the past when the router's manufacturer override password (the one used when your ISP forgets the password they programmed in) has become known to system crackers. When possible, you should design your security around the assumption that the router is potentially hostile. That is, it could be using any IP number in your public or private network blocks, it could be redirecting traffic on outgoing packets to another site, and it could be recording anything which goes through.
8.1 Configuring Your FirewallThis section deals with configuring an ipchains-based masquerading, forwarding, filtering router. You should probably read the IPCHAINS-HOWTO document first, then look here for additional hints. That HOWTO describes the steps necessary to compile a kernel with masquerading support, and describes the use of the ipchains binary in detail. You should enable firewalling on all machines with exposed IP numbers.
Check your startup scripts to make sure that the sequence is as follows on the private network gateway machine:
So, as an example, on a Slackware-based system, the firewall
configuration should come between the execution of
One common problem with ipchains-based firewalls is the tedium of
making sure that your rules are correctly set for packets arriving
from the loopback interface, or arriving from either of the internal
or external interfaces on the firewall machine. These locally-sourced
packets can be blocked by a firewall. All too often, this is fixed by
a sort of shotgun debugging approach, whereby the rules for the
firewall are tweaked until all applications seem to run properly on
the firewall host again. Unfortunately, this can sometimes result in a
firewall which has unintended holes. With ipchains it is possible to
write a firewall script which is easily debugged, and which avoids
many of the packet source problems. Here is a sample script,
Notice that the firewall can be used not only to block incoming
packets, but also outgoing packets which might leak information about
your private network, such as rwho and netbios packets.
As noted earlier, the portmapper rules are a bit different, because
the portmap daemons register themselves with the portmapper and are
told which ports to listen on. The ports used by a particular daemon
may change as you change the RPC services used, or change their order
of startup. The following script,
We didn't have to worry about whether packets coming in were
legitimate packets from the private network, the portmap chain is only
checked when the packets come in from the outside.
This firewall configuration logs most suspicious packets through klogd with the kern.info logging priority. It will log normal connection attempts, as well as all known ``stealth'' probes.
Now, we put these all together. We'd like to make sure that there isn't a small window of vulnerability while the system is starting up, so you should configure your startup sequence as follows:
This assumes that eth1 is the interface on the externally visible IP
number. If any of the ipchains rule sets fail to install, a warning is
issued and that interface is taken off line. The ``outside'' chain is set
to deny all packets before the network service daemons are started,
because the firewalling rules are not yet in place for the portmapped
services. Once the portmapped services are firewalled, the ``outside''
chain is restored to its proper behaviour.
8.2 Configuring OpenSSH or SSH1At the time of this writing, OpenSSH, like SSH1, now offers a
configuration setting which allows you to insert scp,
ssh, and slogin as binaries named rcp,
rsh, and rlogin, with transparent fall-through in
the ssh client programs to the original rsh, rcp, or
rlogin when the remote site isn't running
sshd. Making an invocation of rsh run, instead, the
ssh client program is, in my opinion, important for keeping
the security easy to use and out of the way of the users. Everybody's
scripts, rdist configurations, and so on will continue to
work without modification if the remote site is running sshd,
but data will be sent encrypted, with strong host authentication. The
converse will not always be true. Specifically, if the remote machine
is not running sshd, the rsh program will echo a
diagnostic to the screen warning that the connection is
unencrypted. This message breaks rdist, and possibly other
programs. The message cannot be suppressed with command line or
compile time switches. For rdist, one solution is to invoke
the program with
Obtain ssh1 from the
ssh web site, or OpenSSH from the
OpenSSH web site, and compile it to replace the unencrypted
r-programs (rsh, rlogin, and rcp). First,
copy those three files to
Install the binaries, and configure according to the directions. On
the private network gateway machine, make sure that the sshd
configuration has the following entries defined:
You will have to do further configuration of other entries in the
/etc/sshd_config file, but try not to change these
fields. Once you have all of the entries in the file set to your
satisfaction, copy this entire file into a new file,
/etc/sshd_config.ext , for the external
network. Change two fields in the new file: the ``ListenAddress'' should
be changed to the private network gateway's external IP number
(10.1.1.9 in our fred.example.com case), and ``PasswordAuthentication''
should be set to ``no'' in /etc/sshd_config.ext . In
your network services startup script, start sshd twice, once with
and once with
This will create two running sshd daemons. The one operating on the
internal interface will allow logins with passwords, but the external
interface will require an RSA key validation before anybody can log
on.
Next, turn off incoming telnet and shell services in the inetd configuration file (note that the firewall configuration listed in section Configuring Your Firewall already prevents access from outside, but it's best to defend in depth, don't rely on everything working correctly).
People who want to be able to log in from home, or from out of town, will need an RSA key. Make sure they know how to do this, so they don't spend their energies trying to figure out another way to do it, like running a telnetd on an unprivileged port on your firewall machine.
An RSA key is generated by the command:
You will be prompted for a pass phrase. This should not be
blank. A person with access to the file
new_rsa_key , and knowledge of the pass phrase, has
everything necessary to pass an RSA authentication challenge. The
pass phrase can be an ``unguessable'' password, or a long sentence, but
make it something non-trivial. The file new_rsa_key
can be copied to a floppy disk, or onto a laptop, and, along with the
pass phrase, can be used to log into accounts which are set to grant
access to that particular RSA key.
To configure an account to allow access by a particular RSA key,
simply create a
Only one thing remains to make the RSA key mechanism as gentle as
possible to the users. If a user is forced to enter the pass phrase
more than once or twice in a session, they are likely to become bored
and take security matters into their own hands. Under Linux, arrange
their login shell to be invoked under ssh-agent. For
instance, if the company laptop used on business trips runs
xdm, and drops users into an X session, go into the
into lines of the form:
In my xdm setup, there are three such lines which should be altered in
that one file. Now, when the user logs onto the laptop, he enters the
command
at any prompt, enters the pass phrase when prompted, and all windows
will have pass phrase-free access to the account on the private network
gateway until the user logs off his X session on the laptop.
Run sshd on all of the machines on your private network, as well as on
any exposed hosts. For machines other than the private network gateway
machine, the ListenAddress entry in
then run make-ssh-known-hosts and distribute the
/etc/ssh_known_hosts file among all of the machines
on the private and public networks.
Disable incoming telnet and the unencrypted r-services. Don't delete the telnet binary, it's useful for things other than simple telnet sessions on port 23. You should allow password authentication on the private network, and disable it on the exposed machines, requiring an RSA key to log onto the exposed hosts.
It is convenient for the users if the hosts on the private network are
mentioned in each other's
One difficulty arises when a user logged onto a machine on the private
network wants to log onto a box on an exposed IP number. You can't use
8.3 Configuring XIn the user's continuing quest to prove that he values convenience over security, it has become common for people to put
commands right into their X initialization scripts. This grants X
server access to everybody in the world. Now the random outsider can
change your root window graphic to something embarrassing while your
boss is showing his mother around your office. Alternately, this
outsider can quietly monitor every keystroke you issue, and dump the
contents of your screen to his desktop. Needless to say, this doesn't
bode well for passwords used to log into other sites, or for sensitive
documents being edited on screen. The xhost protocol itself is
inherently limited, as it is not possible to grant permissions to use
the screen on a user basis, only on a machine basis.
Enter xauth authentication. If you have xdm you probably already are running xauth authentication, but xhost still works, and might still be what people are using to run X processes between machines. Once again, the goal is to make the security easy enough to use that the users aren't tempted to run the xhost command anymore.
The sshd setup described in section Configuring SSH1, with the ``X11Forwarding'' flag set, is actually simpler to use than the xhost technique. Once you have logged into your terminal, you can simply rlogin to a remote machine, and run netscape, xv, or whatever you like, without having to set the $DISPLAY variable name or allow explicit permissions. During ssh login, it configures the system in a way transparent to the end user, and even encrypts all of your X packets before they go over the network.
If you are unable to use the sshd X11 forwarding for some reason, you should use xauth when you want to authorize other machines to have access to your X server. Document this for the users, or create specialized shell scripts to help them out. The relevant command to authorize a particular login, ``jpublic'', on machine ``barney'' to have access to your X server is:
This sequence is not necessary to authorize X connections from
machines which share a common NFS-mounted home directory. The xauth
key will be immediately available to that user on all machines which
mount the same home directory.
I'd be tempted to delete xhost from your machines entirely. If it causes problems with any programs, you will at least know that those programs had poorly-designed security. It's simple enough to build a shell script as a drop-in replacement for xhost which uses the xauth sequence listed above.
Note that if rsh is not the encrypting ssh program, the xauth key is sent plaintext. Anybody who holds the plaintext of the key can access your server, so you do not gain much security if you don't use ssh for these transactions. Note, also, that if the users' home directories are exported via NFS (the Network File System), the xauth key is available in plaintext to anybody able to snoop those NFS packets, regardless of whether you're running ssh on your systems.
8.4 Configuring Disk SharingWith email coming to a central machine, the read/send from any host setup described here is very convenient, but some care has to be taken to protect against trivial snooping by bored local users. NFS without AUTH_DES implemented is inherently insecure. NFS relies on the client machine to authenticate access, there is no password verification on the server to make sure that the client should be permitted to access the private files of a particular user. A Windows box can be configured to read NFS-exported volumes as any numeric uid, completely bypassing UNIX file permissions. Consequently, NFS exports should only be made to machines which are always Linux (or UNIX) boxes under your direct control, and never ones which can be dual-booted into Windows. If you want to export the mail spool directory, or any other directory, to machines which can sometimes be used as Windows boxes, export them with samba, setting the authentication mode to ``security=USER''. Connecting the machines on your network with a switch rather than a hub will also help, as it leaves very little of interest for sniffers on Windows machines. Ultimately, though, it's very difficult to secure any disk sharing over the network at the time of this writing.
Why bother, if you can't really secure the network disks? Mostly it's an issue of credible defense. If you leave a sheet of paper on your desk with confidential information, and somebody in the office reads it, he can argue that he didn't realize what the paper was, his natural curiosity just got the better of him when he saw it sitting on the desk. If the sheet of paper were in a filing cabinet or desk drawer, it's an entirely different story. The purpose of taking some basic network security measures internally is to ensure that nobody ``accidentally'' compromises security.
Next Previous Contents |