Handout for Aix Security
Total Page:16
File Type:pdf, Size:1020Kb
10/16/2013 BASIC AIX S ECURITY Jaqui Lynch [email protected] Presentation can be found at: http://www.circle4.com/papers/aixsecurity- oct2013.pdf AGENDA Basics Security Intro Permissions Checklists Tools that can help OpenSSL, OpenSSH TCP Wrappers Snort, stunnel Logging, finding Rootkits Incident Handling and laws AIX v6 and v7 PowerSC Questions 2 1 10/16/2013 SECURITY TYPES Physical Local Keep system patched!!! Microcode/firmware BIOS on HMC and consoles Operating Systems Files and filesystems Passwords Kernel Network 3 LEVELS & T YPES OF ATTACKS Levels Types • Embarrassment (replace Root access break-in banners, home page, etc) Replacement of materials • Denial of service (syn-flood Damage done connections) • Ping of Death Just looking • Stealing proprietary code Theft of proprietary information • Pornography Denial of service • Harassment or threats - stalking Worms and Trojans • Email Spam or bulk subscribes • Hate mail • Buffer Overflow 4 2 10/16/2013 SANS T OP 10 V ULNERABILITIES FROM 2004 •U1 BIND Domain Name System •U2 Remote Procedure Calls (RPC) •U3 Apache Web Server •U4 General UNIX Authentication Accounts with No Passwords or Weak Passwords •U5 Clear Text Services •U6 Sendmail •U7 Simple Network Management Protocol (SNMP) •U8 Secure Shell (SSH) •U9 Misconfiguration of Enterprise Services NIS/NFS •U10 Open Secure Sockets Layer (SSL) •Sadly this has not changed much •Many of these are also turned on by default 5 SANS T OP 20 C RITICAL SECURITY CONTROLS HTTP :// WWW .SANS .ORG /CRITICAL -SECURITY -CONTROLS /# THREATINDEX Critical Control 1: Inventory of Authorized and Unauthorized Devices Critical Control 2: Inventory of Authorized and Unauthorized Software Critical Control 3: Secure Configurations for Hardware and Software on Mobile Devices, Laptops, Workstations, and Servers Critical Control 4: Continuous Vulnerability Assessment and Remediation Critical Control 5: Malware Defenses Critical Control 6: Application Software Security Critical Control 7: Wireless Device Control Critical Control 8: Data Recovery Capability Critical Control 9: Security Skills Assessment and Appropriate Training to Fill Gaps Critical Control 10: Secure Configurations for Network Devices such as Firewalls, Routers, and Switches Critical Control 11: Limitation and Control of Network Ports, Protocols, and Services Critical Control 12: Controlled Use of Administrative Privileges Critical Control 13: Boundary Defense Critical Control 14: Maintenance, Monitoring, and Analysis of Audit Logs Critical Control 15: Controlled Access Based on the Need to Know Critical Control 16: Account Monitoring and Control Critical Control 17: Data Loss Prevention Critical Control 18: Incident Response and Management Critical Control 19: Secure Network Engineering Critical Control 20: Penetration Tests and Red Team Exercises 6 3 10/16/2013 UNIX S ECURITY BASICS Permissions UID GID Dangerous Accounts Superuser SUID Sticky bit Umask Backups 7 PERMISSIONS r read w write x execute s SUID or SGID t sticky bit e Encrypted aaa bbb ccc aaa file's owner permissions bbb users who are in the file's group ccc everyone else on the system (except uid 0) Permissions apply to devices, named sockets, files, directories and FIFOs. 8 4 10/16/2013 OCTAL PERMISSIONS 4000 SUID on execution 0040 Read by group 2000 SGID on execution 0020 Write by group 1000 Sticky Bit 0010 Execute by group 0400 Read by owner 0004 Read by other 0200 Write by owner 0002 Write by other 0100 Execute by owner 0001 Execute by other 755 Anyone can copy or run the program - Only the owner can change it +r +w +x +s SUID if u+, SGID if g+ +t Add sticky bit 9 FILE SECURITY ls -l shows: -rwxr-xr-x 1 jaqui jgroup 4320 Feb 9 12:19 files - file's type (- for file, D for directory) rwxr-xr-x file's permissions if rwxr-xr-xe then file is encrypted 1 no. of hard links the file has jaqui name of the files owner (if a number then this is the Uid) Jgroup name of the group (if a number then this is the Gid) 4320 size of file in bytes Feb 9 12:19 file's modification time files the file's name ls -l Shows modification time for file ls -lu Shows last accessed time It is possible in AIX to code noatime on a filesystem The above two times can be changed with a command so you should check: ls -lc Shows last modification time of the inode 10 5 10/16/2013 FILE SECURITY # ls -l messages -rw-r--r-- 1 root system 1215 Oct 14 19:11 messages # ls -lu messages -rw-r--r-- 1 root system 1215 Oct 13 23:59 messages # ls -lc messages -rw-r--r-- 1 root system 1215 Oct 14 19:11 messages Then tail messages and: # ls -l messages -rw-r--r-- 1 root system 1215 Oct 14 19:11 messages # ls -lu messages -rw-r--r-- 1 root system 1215 Oct 14 19:23 messages # ls -lc messages -rw-r--r-- 1 root system 1215 Oct 14 19:11 messages 11 UMASK Specifies the permissions you do not want given by default to newly created files and directories. By default on most systems: New files are 666 (anyone can read/write) New programs are 777 (all rwx) root should be 022 and all others 077 Common Umask Values Umask User Group Other 0000 rwx rwx rwx 0002 rwx rwx r-x 0007 rwx rwx --- 0022 rwx r-x r-x 0037 rwx r-x --- 0077 rwx --- --- 12 6 10/16/2013 UMASK EXAMPLES Default umask of 022 $touch file1 $mkdir firj1 $ ls -al total 8 drwxr-xr-x 3 jaqui system 256 Oct 14 19:31 . drwxr-xr-x 18 root system 4096 Oct 14 19:30 .. drwxr-xr-x 2 jaqui staff 256 Oct 14 19:31 dirj1 -rw-r--r-- 1 jaqui staff 0 Oct 14 19:30 file1 $umask 007 $touch file2 $mkdir dirj2 $ ls -al total 8 drwxr-xr-x 4 jaqui system 256 Oct 14 19:31 . drwxr-xr-x 18 root system 4096 Oct 14 19:30 .. drwxr-xr-x 2 jaqui staff 256 Oct 14 19:31 dirj1 drwxrwx--- 2 jaqui staff 256 Oct 14 19:31 dirj2 -rw-r--r-- 1 jaqui staff 0 Oct 14 19:30 file1 -rw-rw---- 1 jaqui staff 0 Oct 14 19:31 file2 13 SUID, SGID, S TICKY BIT SUID Sets UID to program's owner at execution SGID Sets GID to program's group at execution Also used to share files in a directory All files and subdirectories will inherit the group Sticky If set on a dir then only root or owner can delete or rename (see /tmp drwxrwxrwt) Old usage was: Causes program to be left in swap space after termination. Used for programs that were executed frequently - outmoded. The su command is an SUID program. To find them: find / -perm -004000 -o -perm -002000 \) -type f -print or ncheck -s filesystem-name 14 7 10/16/2013 EXAMPLE OF STICKY BIT Use of sticky bit # ls -al /tmp drwxrwxrwt 19 bin bin 4096 Oct 14 19:10 . # pwd /usr/local # mkdir jaquidir # ls -al jaquidir total 8 drwxr-xr-x 2 root system 256 Oct 14 19:16 . drwxr-xr-x 18 root system 4096 Oct 14 19:16 .. # chmod 777 jaquidir # ls -al jaquidir total 8 drwxrwxrwx 2 root system 256 Oct 14 19:16 . # chown jaqui.sshd jaquidir # ls -al jaquidir total 8 drwxrwxrwx 2 jaqui sshd 256 Oct 14 19:16 . # chmod +t jaquidir # ls -al jaquidir total 8 drwxrwxrwt 2 jaqui sshd 256 Oct 14 19:16 . drwxr-xr-x 18 root system 4096 Oct 14 19:16 .. You can do this with one step – chmod 1777 jaquidir 15 ACLS –ACCESS CONTROL LISTS acledit /usr/local/jaquidir Extended permissions: aclget /usr/local/jaquidir extended permissions: enabled * permit rw- u:dhs * ACL_type AIXC deny r-- u:chas, g:system * attributes: specify r-- u:john, g:gateway, g:mail base permissions permit rw- g:account, g:finance owner(jaqui): rwx group(system): r-x others: r-x Other commandsL extended permissions disabled aclget aclput # ls -al /usr/local/jaquidir drwxr-xr-x 2 jaqui system 256 Oct 14 acledit 19:47 . drwxr-xr-x 18 root system 4096 Oct 14 aclconvert 19:30 .. aclgettypes http://publib.boulder.ibm.com/infocenter/pseries/v5r 3/index.jsp?topic=/com.ibm.aix.security/doc/security /access_control_list_aixc.htm 16 8 10/16/2013 FILES TO CLEAN OUT Backup file first – I use filename-JLdate /etc/services Password and group files Know who is in there and why /etc/inetd.conf Delete services – don’t just comment them out Check whenever you install maintenance /etc/inittab /etc/rc.tcpip Do you need sendmail, ATM, SNMP? /etc/rc.local and other rc files Don’t make changes to inittab to add things Instead kick off an rc.local from inittab and make your changes to rc.local 17 CHECKLIST 1/3 Individual accounts only including for applications All accounts must have GOOD passwords Disable tftp if possible Use /etc/tftpaccess.ctl to control access Remove .rhost and core files nightly Ensure /etc/passwd can't be read anonymously by UUCP or TFTP Check the SU log regularly Only allow root to login at the console (force su or sudo) if at all Set console as only trusted location for root Set umask to 033 or 077 (077 = rwx --- ---) Scan regularly for SUID/SGID files & for crack Change default password on all system default accounts Get rid of guest Disable dormant or temporarily inactive accounts or set them to /bin/false as a login shell Make regular backups & check restores regularly Export filesystems that have programs as read-only Check last login when you login 18 9 10/16/2013 CHECKLIST 2/3 System directories - not world or group writable /etc/hosts.equiv and hosts.lpd should be rwx r-- r– and preferably empty Remove the + and all comments from your /etc/hosts.equiv and lpd files Disable unused network services, especially finger, cmsd, ttdbserver Ensure sendmail or Postfix is at latest version Do not run sendmail unless you are a mailserver or relay Instead set it up in cron to run the queues hourly Make sure ftpd is current and disabled (try secure FTP or SFTP in SSH) Ensure anonymous FTP & tftp can't get the /etc/passwd file Make sure /etc/ftpusers contains root, uucp, bin, etc Scan periodically for hidden directories (".