Linux Security & Auditing: K. K. Mookhey Founder-CTO Network Intelligence India Pvt. LTD
Linux Security & Auditing: K. K. Mookhey Founder-CTO Network Intelligence India Pvt. LTD
K. K. Mookhey
Founder-CTO
Network Intelligence India Pvt. Ltd.
www.nii.co.in 1
© Network Intelligence India Pvt. Ltd.
Agenda
History of Linux
Linux Distributions
Business drivers for Linux
Linux Architecture
Physical Security
Operating System Security
Network Security
File System Security
User and Group Security
Application Security
Linux Security Tools
www.nii.co.in 2
© Network Intelligence India Pvt. Ltd.
History of Linux
Linus Benedict Torvalds writes an open-source
operating system in 1991
Primary purpose is as a research project
At that time, no other open-source Unix
flavors available. All are proprietary and costly.
Linux became hugely popular among the
student and research community
Today it is a viable alternative for enterprise
applications.
www.nii.co.in 3
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 4
© Network Intelligence India Pvt. Ltd.
Linux – Distributions
The Linux kernel and associated utilities are packaged
and distributed by a number of firms:
Red Hat
Mandrake
Debian
SuSE
Changes:
Most free distributions are no longer ‘free’
Red Hat has stopped after Fedora
Mandrake requires payment for security patches
SUSE has been bought over by Novell
Debian, Slackware still free
www.nii.co.in 5
© Network Intelligence India Pvt. Ltd.
Linux Attack
Portscanner
Identifies open ports
Identifies running services
Identifies Operating System
Vulnerability Scanner
Identifies versions and vendor of services
Determines vulnerabilities in those
Vulnerability Databases
www.SecurityFocus.com/bid
Feed in vendor, software and version number
Check the vulnerabilities and see if any exploits available
Portscan Report – Superscan
Portscan Report - Nmap
www.nii.co.in 6
© Network Intelligence India Pvt. Ltd.
LINUX SECURITY
www.nii.co.in 7
© Network Intelligence India Pvt. Ltd.
Linux Architecture
Linux Kernel – the actual code that
interfaces between user applications and
hardware resources
Hardware controllers – used by the kernel
to interact with hardware
Operating System Services – software
other than the kernel that are considered part
of the OS: X Windows system, command shell
User Applications – software other than
kernel and services: text editors, browsers,
etc.
www.nii.co.in 8
© Network Intelligence India Pvt. Ltd.
Diagrammatically (GNU-LINUX)
KERNEL – LINUX
Hardware Controllers
www.nii.co.in 9
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 10
© Network Intelligence India Pvt. Ltd.
Kernel Security
One of the most important ways to keep Linux
secure is to ensure a patched kernel
Check your kernel version
uname –a
Third-party kernel patches for enhanced
security:
Linux Intrusion Detection System – for ensuring
integrity of critical files
Secure Linux Patch – prevent common buffer
overflows, and simple security measures
International Kernel Patch – kernel-level strong
encryption to be built-in
www.nii.co.in 11
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 12
© Network Intelligence India Pvt. Ltd.
Bastille-Linux snapshot
www.nii.co.in 13
© Network Intelligence India Pvt. Ltd.
Boot Security
Boot configuration is decided by LILO (Linux
Loader) or GRUB (Grand Unified Boot Loader)
Check that only one OS is configured to load
If required ensure there is an entry for
password= in lilo.conf
Also, ensure permissions are 600
Demo
www.nii.co.in 14
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 15
© Network Intelligence India Pvt. Ltd.
Cron and At
Cron is used to schedule regular jobs.
At is used to schedule one time job in the
future
Both can be misused to install time-bombs on
the system, which may suddenly cause the
system to malfunction
Can be restricted using files /etc/cron.allow,
cron.deny, at.allow and at.deny
DEMO
cron.allow contains root
cron.deny contains ALL
www.nii.co.in 16
© Network Intelligence India Pvt. Ltd.
Linux Auditing
Linux auditing is done using syslogd
Configuration file is /etc/syslog.conf
Format is:
Facility.Priority Action to be taken
Facility – the application/program that is generating
the logs
Priority – Emerg, alert, crit, err, warning, notice, info,
debug, none
Action – send it to a file, send it to console, send it via
email, send it to another system (loghost)
Segregation of responsibilities – send logs to another
system, where the security administrator has control
www.nii.co.in 17
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 18
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 19
© Network Intelligence India Pvt. Ltd.
Network Security
Services are started by /etc/rc.d scripts and
xinetd
chkconfig --list
chkconfig levels {numbers} {service} on|off
Xinetd services are configured by individual
files in /etc/xinetd.d/
Open network connections
netstat –antp
Use the –p option to see which processes are
responsible for which open ports
Also lsof can be used
www.nii.co.in 20
© Network Intelligence India Pvt. Ltd.
Network Services
Possibly not required:
NFS and related services: autofs, nfs, nfsserver,
nfslock
Unused networking services: routed, gated, ratvf,
snmpd, named, dhcpd, dhclient, dhrelay, nscd, smb
Mail Services: Sendmail, postfix
Optional network and local services: atd, ldap,
kudzu, rhnsd, ypbind, apache, quota, quotad,
myself, etc.
Printing services: lpr, cups, lprng
www.nii.co.in 21
© Network Intelligence India Pvt. Ltd.
Xinetd
Logic change from earlier inetd.conf file
Builds in controls similar to TCPWrappers and
more:
Access_control: which hosts are allowed to connect
and at what times
Logging: which data gets logged
Resource utilization: limits on maximum
connections supported, CPU usage, etc.
Others
www.nii.co.in 22
© Network Intelligence India Pvt. Ltd.
Trusted Hosts
Entries in /etc/hosts.equiv and /etc/hosts.lpd
are critical
They allow users from those hosts to connect
without supplying a password!
Also, users can create .rhosts and .netrc files
in their home directories, which function
similarly. Find these as well
www.nii.co.in 23
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 24
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 25
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 26
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 27
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 28
© Network Intelligence India Pvt. Ltd.
Root Security
No user must login directly as ‘root’
Administrators must login with their own accounts,
and then use ‘su’ to become root.
This ensures accountability
Viable alternative is the ‘sudo’ utility, which allows:
Listing of privileged accounts
Actions that can be taken by these accounts
Download from http://www.courtesan.com/sudo/intro.html
Time out of logged in user, so he has to re-authenticate in
order to use ‘sudo’
www.nii.co.in 29
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 30
© Network Intelligence India Pvt. Ltd.
Unix Permissions
Permissions are visible in the ls –l output:
Example
First character identified type of file
D = directory
- = file
S = socket
L = link (shortcut)
P = pipe
Next three identify read, write and execute
for owner, next three identify for group, and
last three for everyone else
www.nii.co.in 31
© Network Intelligence India Pvt. Ltd.
Unix Permissions
These letters are added up:
For instances:
- rw- r-- r--
It’s a file
Owner can Read (4) and Write (2)
Group can Read (4)
Everyone else can Read (4)
So permissions on this file are 644
Conversely permissions, like 700 represent
-rwx --- ---
www.nii.co.in 32
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 33
© Network Intelligence India Pvt. Ltd.
File Integrity
File Integrity can be verified:
Size and timestamp – can be modified to fool
the auditor
MD5 hashes – secured method, but tedious
File Integrity Software:
Must be used immediately after the installation
Create a database of MD5 hashes of all critical files
Monitor changes to these files and send alerts
Tripwire – commercial, scalable, central console
AIDE – open-source, reasonably enterprise-level
www.nii.co.in 34
© Network Intelligence India Pvt. Ltd.
Application Security
Linux systems can be used as
File Servers – Samba – Windows-compatible file
server
Print Servers –lpd, cups, etc.
Mail Server – Sendmail (historically insecure),
Qmail, Postfix
VPN Server – FreeS/WAN
Databases – PostgreSQL, MySQL (free), Oracle,
Sybase, DB2 (commercial)
DNS Servers – BIND
LDAP Servers
Time Servers
www.nii.co.in 35
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 36
© Network Intelligence India Pvt. Ltd.
Important Directives
Directory: access control based on source IP address
or domain name for various files and folders of the
website, using Allow and Deny keywords
Also, within this directive, various options can be set.
Recommended to set Options None
Denial of Service and Buffer Overflow attacks can be
prevented by LimitRequest* and Rlimit* directives
CGI security is most important, to ensure scripts
cannot be misused for compromising the server
Apache uses various modules for added functionality.
These must be reduced to a minimum
Banner of Apache must be changed
Apache must be run in ‘chroot’ environment
www.nii.co.in 37
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 38
© Network Intelligence India Pvt. Ltd.
www.nii.co.in 39
© Network Intelligence India Pvt. Ltd.
Conclusion
Linux is not secure in default configuration
Security can be added to a very high level, but must be
balanced with functionality
The correct Linux distribution must be chosen, and
minimum installation done
Patches must be diligently applied
Syslog logs must be exported and analyzed periodically
Network Services must be kept to a minimum
User and groups must be periodically audited
File/folder access control lists must be set
File Integrity software may be used in high-security
installations
Application-specific security measures are also a must
www.nii.co.in 40
© Network Intelligence India Pvt. Ltd.
References
The Unix Auditor’s Practical Handbook –
K. K. Mookhey
http://www.nii.co.in/research/papers.html
Practical Unix and Internet Security –
Simson Garfinkel and Gene Spafford
Linux Security Benchmark
-http://www.cisecurity.org/
Linux Security and Controls – ISACA & K.
K. Mookhey – to be available at ISACA
bookstore in 2nd quarter
www.nii.co.in 41
© Network Intelligence India Pvt. Ltd.
About NetIntel
IT Security Consultancy Firm
Penetration Testing
Security Auditing
Security Training – Unix, Windows,
Databases, Ethical Hacking, Intrusion
Detection, etc.
BS7799 Consultancy
Application Security Audit
Business Continuity Management
Security Implementation & Design
www.nii.co.in 42
© Network Intelligence India Pvt. Ltd.
THANK YOU
Questions
www.nii.co.in 43