The following is a brief compendium of what we at Auburn Univeristy College of Engineering use to secure our NIS networks. We had a mix of about 65% NIS, 35% NIS+ network before dropping NIS+ due to reliability problems and setting all machines to use NIS. The following is our implementation of securing NIS using various vendor patches and free utilities from around the world.
NIS has a reputation of being extremely insecure. If you implement these steps it will lose most if not all of the reasons for this, and you will retain all the administrative advantages of NIS without the security risks. We use NIS on SunOS4 and on Solaris 2.X machines and are a predominantly Sun shop. All other machines may have slightly different results and implementations. Hopefully others will find this useful, though. Here's a list of reasons why you should follow these steps.
Router Modifications
Most sites have a router connecting themselves with the outside world. If you have control of this router make sure you do the following to things, or everything else below could be completely useless. (Note, implementation details and configuration is router specific, and we can't help configure your particular brand of router.)Replacing Daemons
Installing Vendor Patches
Restricting Access
Blocking TCP Attacks
Shadow Passwords
SunOS4 instructions:
cd /var/yp
mkdir security
chown root security
chmod 700 security
root:##root:0:0::/:/bin/csh
The format for the shadow password map is then follows the form
of
username:password:::::
Where password is what
you removed from the passwd file. The 5 remaining colons will never have
anything in them. They are used by C2 security for mandatory security
accesses, but that is irrelevant here. The following awk script will
generate a passwd.adjunct file.
nawk -F\: '{printf("%s:%s:::::\n", $1, $2)}' passwd > security/passwd.adjunct
And the following script will fix your passwd file.
nawk -F\: '{printf("%s:##%s:%s:%s:%s:%s:%s\n", $1, $1, $3, $4, $5, $6, $7)}' passwd > passwd.new
Check the file passwd.new for any errors before replacing passwd
with this new file. Now is also the perfect time to check for users that
have no password and replace the emtpy password entry with a "*" in the
passwd.adjunct file.
# mkdir /etc/security
# chmod 700 /etc/security
Then fill the file with something
like this:
root:ZbAirHUqwr9w:::::
nobody:*:::::
daemon:*:::::
sys:*:::::
bin:*:::::
audit:*:::::
sync:*:::::
AUpwdauthd:*:::::
AUyppasswdd:*:::::
+::::::
Obviously, your root password will be taken our of your
/etc/passwd file. The above password is nonsense anyway. If you want a
different root password for each machine, make sure the root entry above
has a valid password. If you want an identical root password for all
your machines which comes out of NIS, delete the root line above all
together.
AUpwdauthd:##AUpwdauthd:10:10::/lost+found:/bin/true
AUyppasswdd:##AUyppasswdd:11:10::/lost+found:/bin/true
Lost+found can be replaced with the name of any local directory.
AUpwdauthd:*:::::
AUyppasswdd:*:::::
# # start up authentication daemon if present and if adjunct file exists # if [ -f /usr/etc/rpc.pwdauthd -a -f /etc/security/passwd.adjunct ]; then rpc.pwdauthd & echo -n ' pwdauthd' fi
c2secure: -@if [ -f $(DIR)/security/passwd.adjunct ]; then \ if [ ! $(NOPUSH) ]; then $(MAKE) $(MFLAGS) -k \ passwd.adjunct.time group.adjunct.time; \ else $(MAKE) $(MFLAGS) -k NOPUSH=$(NOPUSH) \ passwd.adjunct.time group.adjunct.time; \ fi; \ fi
if [ -f /usr/etc/rpc.yppasswdd ]; then rpc.yppasswdd /var/yp/dbdir/passwd /var/yp/dbdir/security/passwd.adjunct -nosingle -noshell -nogecos -m passwd.adjunct > /dev/console echo -n ' yppasswdd' fi
Solaris2 instructions
(with corrections contributed by Rick
Parsons)
cd /var/yp mkdir security chown root security chmod 700 security
username:##username:2120:2120:Joe User:/:/bin/csh
The format for the shadow password map is then follows the form of
username:crypt:::::
Where crypt is the encrypted password string that you removed from the passwd file. The 5 remaining colons will never have anything in them. They are used by C2 security for mandatory security accesses, but that is irrelevant here. The following awk script will generate a passwd.adjunct file.
nawk -F\: '{printf("%s:%s:::::\n", $1, $2)}' passwd > security/passwd.adjunct
And the following script will fix your passwd file.
nawk -F\: '{printf("%s:##%s:%s:%s:%s:%s:%s\n", $1, $1, $3, $4, $5, $6, $7)}'
passwd > passwd.new
Check the file passwd.new for any errors before replacing passwd with this new file. Now is also the perfect time to check for users that have no password and replace the empty password entry with a "*" in the passwd.adjunct file. Also, you'll need to adjust your new account add script to automatically add an entry to the /etc/security/passwd.adjunct file. This passwd map should NOT contain root or other administrative usernames, these should be in the local passwd file protected by the standard shadow mechanism.
AUpwdauthd:##AUpwdauthd:10:10::/var/tmp:/bin/true AUyppasswdd:##AUyppasswdd:11:10::/var/tmp:/bin/true
/var/tmp can be replaced with the name of any local directory.
AUpwdauthd:*:::::
AUyppasswdd:*::::
c2secure: -@if [ -f $(DIR)/security/passwd.adjunct ]; then \ if [ ! $(NOPUSH) ]; then $(MAKE) $(MFLAGS) -k \ passwd.adjunct.time group.adjunct.time; \ else $(MAKE) $(MFLAGS) -k NOPUSH=$(NOPUSH) \ passwd.adjunct.time group.adjunct.time; \ fi; \ fi
TCP Wrappers Addendum
portmap: 255.255.255.255 0.0.0.0 portmap: 129.129.1.0/255.255.255.0 portmap: 129.129.2.0/255.255.255.0 ... ... portmap: 129.129.10.0/255.255.255.0Note: the first line is not always necessary, but it's safe to include it. It is necessary on NIS slaves and masters that have to answer ypbind broadcast requests on the local network. The second approach is to just put a broad mask for your entire Class B network. Sometimes this is easier than doing every single subnet one at a time. (That would make for a HUGE /etc/hosts.allow file, 1 per machine. Obviously, this would be impractical. Here's an example of the latter approach.
portmap: 255.255.255.255 0.0.0.0 portmap: 129.129.0.0/255.255.0.0
If you have any questions/comments, feel free to send me email or comments.