Linux Security Ideas and Tips



Similar documents
Nixu SNS Security White Paper May 2007 Version 1.2

Host Hardening. OS Vulnerability test. CERT Report on systems vulnerabilities. (March 21, 2011)

Security Advice for Instances in the HP Cloud

Linux Boot Camp. Our Lady of the Lake University Computer Information Systems & Security Department Kevin Barton Artair Burnett

URL:

Deployment - post Xserve

Linux Server Configuration Guidelines

Protecting Host from Net

How To Install Storegrid Server On Linux On A Microsoft Ubuntu 7.5 (Amd64) Or Ubuntu (Amd86) (Amd77) (Orchestra) (For Ubuntu) (Permanent) (Powerpoint

Secure Shell Demon setup under Windows XP / Windows Server 2003

SSL Tunnels. Introduction

SSH, SCP, SFTP, Denyhosts. Süha TUNA Res. Assist.

Installing QuickBooks Enterprise Solutions Database Manager On Different Linux Servers

Nagios XI - NRPE Troubleshooting and Common Solutions

EGI/PRACE/EUDAT Joint Security Training Urpo Kaila ACCESS CONTROLS SECURITY MONITORING SECURITY WORKSHOP

Deploying Ubuntu Server Edition. Training Course Overview. (Ubuntu LTS)

Hardened Hosting. Quintin Russ. OWASP New Zealand Chapter th December 2011

How To Set Up A Network Map In Linux On A Ubuntu 2.5 (Amd64) On A Raspberry Mobi) On An Ubuntu (Amd66) On Ubuntu 4.5 On A Windows Box

SSH and FTP on Ubuntu WNYLUG Neal Chapman 09/09/2009

Recommended File System Ownership and Privileges

GL550 - Enterprise Linux Security Administration

Linux: 20 Iptables Examples For New SysAdmins

CloudPassage Halo Technical Overview

SYSTEM ADMINISTRATION MTAT LECTURE 8 SECURITY

BF2CC Daemon Linux Installation Guide

ENTERPRISE LINUX SECURITY ADMINISTRATION

Network Infrastructure Security Recommendations

Linux Operating System Security

Small Systems Solutions is the. Premier Red Hat and Professional. VMware Certified Partner and Reseller. in Saudi Arabia, as well a competent

Cloud.com CloudStack Community Edition 2.1 Beta Installation Guide

Installing Booked scheduler on CentOS 6.5

TECHNICAL NOTE. Technical Note P/N REV 03. EMC NetWorker Simplifying firewall port requirements with NSR tunnel Release 8.

CCM 4350 Week 11. Security Architecture and Engineering. Guest Lecturer: Mr Louis Slabbert School of Science and Technology.

Firewalling and Network Security I -Linux. Jeff Muday Academic Computing Specialist Wake Forest University

Track 2 Workshop PacNOG 7 American Samoa. Firewalling and NAT

Install Cacti Network Monitoring Tool on CentOS 6.4 / RHEL 6.4 / Scientific Linux 6.4

GestióIP IPAM v3.0 IP address management software Installation Guide v0.1

J-202. IT 4823 Information Security Administration. Linux Security Model. Linux Security. In Room. Linux Security April 23

How to install PowerChute Network Shutdown on VMware ESXi 3.5, 4.0 and 4.1

CloudPassage Halo Technical Overview

GL-550: Red Hat Linux Security Administration. Course Outline. Course Length: 5 days

Linux System Administration. System Administration Tasks

IBM WebSphere Application Server Version 7.0

How To Set Up An Ip Firewall On Linux With Iptables (For Ubuntu) And Iptable (For Windows)

Using New Relic to Monitor Your Servers

SERVER HARDENING. Presented by: Daniel Waymel and Corrin Thompson at TexSAW 2014 at the University of Texas at Dallas

SCP - Strategic Infrastructure Security

How to Tunnel Remote Desktop using SSH (Cygwin) for Windows XP (SP2)

Worms, Trojan Horses and Root Kits

Desktop : Ubuntu Desktop, Ubuntu Desktop Server : RedHat EL 5, RedHat EL 6, Ubuntu Server, Ubuntu Server, CentOS 5, CentOS 6

Foreword Credits Preface Part I. Legal and Ethics 1. Legal and Ethics Issues 1.1 Core Issues 1.2 Computer Trespass Laws: No "Hacking" Allowed 1.

Lab Objectives & Turn In

Securing Linux Servers

Red Hat System Administration 1(RH124) is Designed for IT Professionals who are new to Linux.

NRPE Documentation CONTENTS. 1. Introduction... a) Purpose... b) Design Overview Example Uses... a) Direct Checks... b) Indirect Checks...

Real Time Performance of a Security Hardened RedHawk Linux System During Denial of Service Attacks

PARALLELS SERVER BARE METAL 5.0 README

Introduction to Operating Systems

RemotelyAnywhere. Security Considerations

This Release Notes document is for F-Secure Linux Security.

Unit objectives IBM Power Systems

Linux System Administration on Red Hat

OnCommand Performance Manager 1.1

Host/Platform Security. Module 11

Project 2: Penetration Testing (Phase II)

ENTERPRISE LINUX SECURITY ADMINISTRATION

Pen Test Tips 2. Shell vs. Terminal

Linux FTP Server Setup

Computer Security: Principles and Practice

Acronis Backup & Recovery 10 Server for Linux. Quick Start Guide

Project 2: Firewall Design (Phase I)

Wolfr am Lightweight Grid M TM anager USER GUIDE

Securing Linux. Presented by: Darren Mobley

Secure Network Filesystem (Secure NFS) By Travis Zigler

without the fixed perimeters of legacy security.

Security Power Tools

Computer Science and Engineering Linux Cisco VPN Client Installation and Setup Guide

Cybernetic Proving Ground

Security Maintenance Practices. IT 4823 Information Security Administration. Patches, Fixes, and Revisions. Hardening Operating Systems

Forensic analysis of a Linux web server

Connectivity using ssh, rsync & vsftpd

Network Security and Firewall 1

How to Secure RHEL 6.2 Part 2

Nessus Agents. October 2015

Syncplicity On-Premise Storage Connector

Railo Installation on CentOS Linux 6 Best Practices

INUVIKA OVD INSTALLING INUVIKA OVD ON UBUNTU (TRUSTY TAHR)

Security Best Practice

SNMP Manager User s Manual

GL254 - RED HAT ENTERPRISE LINUX SYSTEMS ADMINISTRATION III

COURCE TITLE DURATION LPI-202 Advanced Linux Professional Institute 40 H.

Hacking Database for Owning your Data

Preparing for the Installation

QuickBooks Enterprise Solutions. Linux Database Server Manager Installation and Configuration Guide

Parallels Plesk Automation

LOCKSS on LINUX. Installation Manual and the OpenBSD Transition 02/17/2011

FREQUENTLY ASKED QUESTIONS

Configuring MailArchiva with Insight Server

AlienVault Unified Security Management (USM) 4.x-5.x. Deploying HIDS Agents to Linux Hosts

INASP: Effective Network Management Workshops

Transcription:

Linux Security Ideas and Tips Hugh Brown Sr. Systems Administrator ITS Enterprise Infrastructure University of Iowa October 8, 2014 Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 1 / 27

Introduction Who am I? Linux User and Sysadmin for 15+ years Worked in big business, small business and university environments Taught Linux courses for the UI My assumptions: You are running Linux in a server capacity You are only running a handful of systems You aren t managing 100s of Linux systems The command line isn t scary Specifics may be Redhat centric Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 2 / 27

Overview ˆ Where to get Linux ˆ Minimalism ˆ Baseline ˆ Patching ˆ Least privilege ˆ User management ˆ Remote access and ssh hardening ˆ Packet Filtering ˆ Logging ˆ AV protection ˆ Secure applications ˆ Further reading Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 3 / 27

Where to get Linux Redhat: https://helpdesk.its.uiowa.edu/software/signin.htm CentOS: http://www.centos.org/ Fedora: http://fedoraproject.org SuSE: $$ https://www.suse.com opensuse: http://www.opensuse.org Ubuntu: http://www.ubuntu.com Debian: http://www.debian.org Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 4 / 27

Minimalism Install the minimum you need, add software/packages as necessary Use package manager to remove any extras that you don t need Fewer packages/applications means less to patch later Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 5 / 27

Minimalism: Disabling unneeded services Disable unnecessary services - Don t install them in the first place How to determine what s listening: n e t s t a t vanp grep LISTEN Proto Recv Q Send Q L o c a l A d d r e s s F o r e i g n A d d r e s s S t a t e PID/ Program name t c p 0 0 1 2 7. 0. 0. 1 : 5 0 3 7 0. 0. 0. 0 : * LISTEN 5464/ adb t c p 0 0 0. 0. 0. 0 : 1 1 1 0. 0. 0. 0 : * LISTEN 2017/ r p c b i n d t c p 0 0 0. 0. 0. 0 : 2 2 0. 0. 0. 0 : * LISTEN 10260/ s s h d t c p 0 0 0. 0. 0. 0 : 4 9 2 1 8 0. 0. 0. 0 : * LISTEN 9997/ r p c. s t a t d t c p 0 0 0. 0. 0. 0 : 2 4 8 0 0 0. 0. 0. 0 : * LISTEN 11677/ s y n e r g y s t c p 0 0 0. 0. 0. 0 : 4 0 0. 0. 0. 0 : * LISTEN 10260/ s s h d t c p 0 0 1 2 7. 0. 0. 1 : 6 3 1 0. 0. 0. 0 : * LISTEN 10073/ cupsd t c p 0 0 1 2 7. 0. 0. 1 : 2 5 0. 0. 0. 0 : * LISTEN 10349/ master t c p 0 0 : : : 1 1 1 : : : * LISTEN 2017/ r p c b i n d t c p 0 0 : : : 5 0 1 6 2 : : : * LISTEN 9997/ r p c. s t a t d t c p 0 0 : : : 2 2 : : : * LISTEN 10260/ s s h d t c p 0 0 : : : 4 4 : : : * LISTEN 10260/ s s h d t c p 0 0 : : 1 : 6 3 1 : : : * LISTEN 10073/ cupsd t c p 0 0 : : 1 : 2 5 : : : * LISTEN 10349/ master What/where is that program: man -k <program> ls -l /proc/<pid>/exe Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 6 / 27

Baseline After install, and initial configuration: determine what normal is Which processes are running as which users (ps)? Which ports are they listening on (netstat/fuser/lsof)? Scheduled tasks (cron/at) Disk utilization (df) Log entries (logwatch, checking logs manually) Memory usage (top, vmstat) CPU usage (top, mpstat) Accounts on the system (/etc/passwd) Account access (who is normally logged in: w, last) Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 7 / 27

Patching One of the foremost ways to keep your system secure is to patch regularly. Schedule a time to do patching (monthly or better) Allow for emergency patching for critical vulnerabilities Evaluate patches: local exploit vs. remote exploit Software inventory on a system (what to patch) Subscribe to appropriate information sources to find out when patches are available Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 8 / 27

Patching: Post Patching Linux won t (usually) prompt you to reboot If you updated glibc or the kernel, you ll need to reboot Otherwise, restart services as needed. How do you find out which services need to be restarted: needs r e s t a r t i n g # p a r t o f yum u t i l s package l s o f grep i n o d e grep l i b # RHEL5 l s o f grep DEL grep l i b # RHEL6 will output a list of all processes which have deleted files with the name lib in them. COMMAND PID USER FD TYPE DEVICE SIZE /OFF NODE NAME sudo 664 r o o t DEL REG 253,0 1742367 / u s r / l i b 6 4 / l i b n s s u t i l 3. so sudo 664 r o o t DEL REG 253,0 1742397 / u s r / l i b 6 4 / l i b n s s 3. so f i r e f o x 3528 hbrown DEL REG 253,0 1742367 / u s r / l i b 6 4 / l i b n s s u t i l 3. so f i r e f o x 3528 hbrown DEL REG 253,0 1742397 / u s r / l i b 6 4 / l i b n s s 3. so cupsd 10073 r o o t DEL REG 253,0 1742367 / u s r / l i b 6 4 / l i b n s s u t i l 3. so cupsd 10073 r o o t DEL REG 253,0 1742397 / u s r / l i b 6 4 / l i b n s s 3. so s s h d 10260 r o o t DEL REG 253,0 1742367 / u s r / l i b 6 4 / l i b n s s u t i l 3. so s s h d 10260 r o o t DEL REG 253,0 1742397 / u s r / l i b 6 4 / l i b n s s 3. so qmgr 10357 p o s t f i x DEL REG 253,0 1742367 / u s r / l i b 6 4 / l i b n s s u t i l 3. so qmgr 10357 p o s t f i x DEL REG 253,0 1742397 / u s r / l i b 6 4 / l i b n s s 3. so Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 9 / 27

Patching: Campus Resources Satellite server: Redhat products https://rhnsat.uiowa.edu Details: http://its.uiowa.edu/campus-software-program/red-hat-linux-campus Spacewalk server: Fedora and CentOS http://spacewalk.its.uiowa.edu Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 10 / 27

Least Privilege Only give an application/user the minimally needed permissions to get the job done Most processes don t need to run as root, don t let them (when possible) Binding to a port between 1 and 1024 is root only Don t give out the root password Don t ever do chmod 777 (unless you really mean it) Evaluate Setuid programs and determine if any user will need to run them Limit sudo privileges to just the needed commands Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 11 / 27

Least Privilege: Setuid The setuid permission coupled with root ownership allows any user to run that command with root privileges. Finding setuid programs: /usr/bin/find / -user root -perm -4000 -print Remove: chmod u-s /path/to/binary Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 12 / 27

Least Privilege: Setuid Valid Uses Potentially valid uses for setuid programs Reading files that would otherwise be protected /bin/sudo needs to read /etc/sudoers to validate commands Writing files to locations that are protected /usr/bin/crontab stores a user s crontab in /var/spool/cron Creating a raw socket (ping/traceroute) Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 13 / 27

Least Privilege: Sudo Sudo can be used to give selective permission for performing a limited number of tasks as root Using hbrown ALL=(ALL) ALL in sudoers is full root access, be selective. Allowing vi /my/config via sudo is full root access. Allow sudoedit /my/config instead. Using sudo for select functions is a good thing. Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 14 / 27

Permissions Tips for troubleshooting permissions: Check to see if SELinux is enabled: getenforce cat /proc/<pid>/status and look for Uid/Gid to see which user a process is running as Check from / down to wherever it is the app is trying to write instead of the other way round Use strace to do a system trace strace -fvvvto output.strace -s 2048 -u <username> <cmd> Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 15 / 27

User Management Avoid shared/service accounts with passwords that everyone logs in with - Use sudo access to a service account when needed Use directory based user accounts (for builtin account expiration/password rules) Collect logs of user account activity on a different system (wtmp, /var/log/secure) Remove.ssh/authorized_keys for users that are gone/disabled. Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 16 / 27

User Management: Kerberos Authentication against AD Authorization against AD is an on going project. For now, you ll need to populate the /etc/passwd file with an entry for each user Authentication is possible now http://its.uiowa.edu/support/article/100409 Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 17 / 27

Remote access ssh is a wonderful tool, hackers think so too. Ideas for securing it: Edit your /etc/ssh/sshd_config - Disable root login (PermitRootLogin no) - Disable Password authentication and only use keys (PasswordAuthentication no) - Leave X11Forwarding turned off (X11Forwarding no) Edit your /etc/ssh/ssh_config - Enable hashed known_hosts files (HashKnownHosts yes) - Disable X11Trusted (ForwardX11Trusted no) Run it on a different port than 22 Use iptables to rate limit access and only allow trusted IPs/nets. Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 18 / 27

Packet Filtering An easy way to keep the bad actors out is to refuse to respond - Use host based firewalls - iptables/ip6tables - Use TCP Wrappers Scan your system regularly to make sure those filters are working. Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 19 / 27

Packet Filtering: Host based firewalls Use a local host based firewall Make sure you have ip6tables configured if you are using IPv6 Remember that iptables uses a first match paradigm Make sure you have a line that rejects/drops traffic at the end Test your rules with nmap from both on and off campus Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 20 / 27

Packet Filtering: TCP Wrappers TCP Wrappers is a classic lightweight application firewall. Rules are in /etc/hosts.allow and /etc/hosts.deny Make use of it to fine tune what you protect It s a second layer of defense behind your host based firewall (ip*tables) Use ldd <path/to/binary> grep libwrap to see if your application supports it The daemon name for the hosts.allow file is usually the name of the binary. Check documentation to be sure. Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 21 / 27

Packet Filtering: Scanning Scan your systems regularly to make sure the view from the outside is normal Request a scan from the Security Office http://itsecurity.uiowa.edu/scan/networkscan-form.shtml Use nmap judiciously against your own systems Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 22 / 27

Logging There s lots of useful information to be had in /var/log. Attackers know that and clean it out to hide what they ve done Use a central logging host to gather that information Use some sort of log analysis suite (or logwatch) to help you wade through it Use logging to help you determine normal Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 23 / 27

AV Protection AV? We don t need no AV on Linux! Sometimes your Linux server is serving up files to MS Windows hosts. Running AV on those Linux systems is a must ClamAV http://www.clamav.net Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 24 / 27

Secure Your Applications Look for best practice guides for any application you deploy An Example: Apache Host Access to protect phpmyadmin <D i r e c t o r y / u s r / s h a r e /phpmyadmin > Order deny, a l l o w Deny from a l l Allow from uiowa. edu Allow from 1 2 8. 2 5 5. </D i r e c t o r y > Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 25 / 27

Secure Your Applications: Apache Allow/Deny Ordering http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order Match Match Allow only Match Deny only No match Match both Allow & Deny Allow,Deny result Request allowed Request denied Default to second directive: Denied Final match controls: Denied Match Match Allow only Match Deny only No match Match both Allow & Deny Deny,Allow result Request allowed Request denied Default to second directive: Allowed Final match controls: Allowed Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 26 / 27

Further reading UNIX and Linux System Administration Handbook http://www.admin.com The Linux Command Line http://linuxcommand.org/tlcl.php Hugh Brown (University of Iowa) Linux Security Ideas and Tips October 8, 2014 27 / 27