5 Operating System Security
5 Operating System Security
Security
Prevention Strategies
• The 2010 Australian Signals Directorate (ASD) lists the “Top 35 Mitigation Strategies”.
a planned process designed to counter this What access the system has to
threat
The categories of users of the
information stored on other
system, the privileges they
hosts, such as file or database
have, and the types of
servers, and how this is
information they can access
managed
• Process must:
o Assess risks and plan the system deployment How the users are
How access to the information
stored on the system is
o
authenticated
Secure the underlying OS and then the key applications managed
• When performing the initial installation the supplied defaults should not be
used
o Default configuration set to maximize ease of use & functionality rather than security
o If additional packages are needed later they can be installed when required
• System planning process should consider:
o Categories of users on the system
Encryption Technology
Is a key
enabling If secure network Cryptographic file
technology that services are systems are
Must be If secure network
may be used to provided using services are another use of
secure data both configured and
appropriate TLS or IPsec provided using SSH, encryption
in transit and suitable public and appropriate server
when stored cryptographic
private keys must and client keys must
keys created, be created
signed, and be generated for
secured each of them
Security Maintenance
• Process of maintaining security is continuous
• Security maintenance includes:
o Monitoring and analyzing logging information
o Performing regular backups
o Recovering from security compromises
o Regularly testing system security
o Using appropriate software maintenance processes to patch and update all critical software,
and to monitor and revise configuration as needed
Stored locally or
transported to a
Automated analysis is remote siite
Logging preferred
Backup & archive
Linux/Unix Security
• Patch management
• Keeping security patches up to date is a widely recognized and critical control for maintaining security
• chroot jail
• Restricts the server’s view of the file system to just a specified portion
• Uses chroot system call to confine a process by mapping the root of the filesystem to some other
directory
• File directories outside the chroot jail aren’t visible or reachable
• Main disadvantage is added complexity
Windows Security
Patch management
“Windows Update” and “Windows Server Update Service” assist with regular maintenance and should be
used
Third party applications also provide automatic update support
Windows systems also define User Account Control (UAC) Low Privilege Service
privileges Combination of share and Accounts
• Provided in Vista and later Assists
NTFS permissions may be
• System wide and granted to user with ensuring users with admin • Used for long-lived service
used to provide additional rights only use them when
accounts processes such as file, print, and
security and granularity when required, otherwise accesses system DNS services
accessing files on a shared as normal user
resource
Windows Security
Other security controls
• Essential that anti-virus, anti-spyware, personal firewall, and other malware and attack detection and
handling software packages are installed and configured
• Current generation Windows systems include basic firewall and malware countermeasure capabilities
• Important to ensure the set of products in use are compatible
• Free, easy to use tool that checks for compliance with Microsoft’s security recommendations
Application virtualization
Full virtualization
Allows
applications
written for
one Multiple Virtual machine monitor
environment
to execute on
full
operating
(VMM)
some other
operating system
system instances Coordinates access
execute in between each of the
Hypervisor guests and the actual
parallel physical hardware
resources
Virtualization Security Issues
• Security concerns include:
o Guest OS isolation
• Ensuring that programs executing within a guest OS may only access & use resources allocated to it
o Guest OS monitoring by the hypervisor
• Which has privileged access to the programs and data in each guest OS
o Virtualized environment security
• Particularly image and snapshot management which attackers may attempt to view or modify
o Organizations using virtualization should:
• Carefully plan the security of the virtualized system
• Secure all elements of a full virtualization solution and maintain their security
• Ensure that the hypervisor is properly secured
• Restrict and protect administrator access to the virtualization solution
• Should be
o Secured using a process similar to securing an operating system, Installed in an isolated environment, Configured so that it is updated
automatically, Monitored for any signs of compromise & Accessed only by authorized administration
• May support both local and remote administration so must be configured appropriately
• Remote administration access should be considered and secured in the design of any network firewall and IDS
capability in use
• Ideally administration traffic should use a separate network with very limited access provided from outside the
organization
Linux Security
Linux
• Created in 1991 by Linus Torvalds
• Has evolved into one of the world's most popular operating systems
o Free, Open-sourced
o Available in a wide variety of distributions targeted at almost every usage scenario imaginable
Thus, Linux security (and UNIX security in general) is a game of “root takes
all”
Discretionary Access Controls (DAC)
Prior to being executed a program’s file-permissions restrict who can execute, access, or
change it
When running, a process normally runs as the identity of the user and group of the
person or process that executed it
If a running process attempts to read, write, or execute some other object the
kernel will first evaluate that object’s permissions against the process’s user and
group identity
The system superuser account has the ability to both take ownership and change the
permissions of all objects in the system
Permissions
DAC
Linux treats everything as a file.
Although we think of a directory as a container of files, in UNIX a directory is actually itself a file
containing a list of other files.
Similarly, the CD-ROM drive attached to your system seems tangible enough, but to the Linux kernel,
it too is a file: the "special" device-file /dev/cdrom.
To send data from or write data to the CD-ROM drive, the Linux kernel actually reads to and writes
from this special file.
Other special files, such as named pipes, act as input/output (I/O) "conduits," allowing one process or
program to pass data to another.
These examples illustrate how in Linux/UNIX, nearly everything is represented by a file. Once you
understand this, it's much easier to understand why file-system security is such a big deal (and how it
works).
Users, Groups, and Permissions
• There are two things on a UNIX system that aren’t represented by files:
o User accounts
o Group accounts
• User account
o Represents someone or something capable of using files
o Can be associated with both actual human beings and processes
• Group account
o A list of user accounts
o Each user account is defined with a main group membership, but may belong to as many groups as you
need it to
• conductors:x:100:
• pianists:x:102:maestro,volodya
crash@localhost:/extreme_casseroles> rm pineapple_mushroom_suprise.txt
rm: cannot remove `pineapple_mushroom_suprise.txt': Operation not permitted
Setuid and Setgid
• Each permission has a numeric value and the permissions in each digit-place are
additive
o The digit represents the sum of all permission-bits you wish to set
• Basic numeric values are 4 for read, 2 for write, and 1 for execute
o These values represent bits in a binary stream and are therefore all powers of 2
o If user permissions are set to “7” this represents 4(value for read) plus 2 (the value for write and 1 (the value for execute)
If a setuid root program can be exploited or abused in some way, then otherwise unprivileged users may be able to use that program to
wield unauthorized root privileges --- possibly opening a root shell (a command-line session running with root privileges
Running setuid root is necessary for programs that need to be run by unprivileged users yet must provide such users with access to
privileged functions --- for example, changing their password, which requires changes to protected system files
A root-owned program should only have its setuid bit set if absolutely necessary
OS Installation: Software Selection and Initial Setup
• System log daemons receive log data from a variety of sources, sort by
facility and severity, and then write the log messages to log files
• Both syslogd and Syslog-NG install with default settings for what gets logged and
where
o You should decide what combination of local and remote logging to perform
o If logs remain local to the system that generates them they may be tampered with by an attacker
o If some or all log data are transmitted over the network to some central log-server audit trails can be more
effectively preserved but log data may also be exposed to network eavesdroppers
Other System Security Tools
Bastille Tripwire Snort Nessus
A utility that maintains
A powerful free A modular security
A comprehensive a database of
Intrusion Detection scanner that probes for
system-hardening characteristics of crucial
System (IDS) that common system and
utility that educates as system files and reports
detects common application
it secures all changes made to
network-based attacks vulnerabilities
them
It’s possible for a service’s parent process to run as root in order to bind to a privileged port and then spawn a new child process that
runs as an unprivileged user each time an incoming connection is made
Ideally the unprivileged users and groups used by a given network daemon should be dedicated for that purpose
• This kernel-mode component performs access checks, generates audit log entries, and manipulates user rights (also
called privileges)
• Ultimately every permission check is performed by the SRM
• Most modern Oss include SRM type functionality that performs privileged permission checks
• SRMs tend to be small in size so their correctness can be verified
• Resides in a user-mode process named lsass.exe and is responsible for enforcing local security policy
• It also issues security tokens to accounts so they log on to the system
• Security policy: Password & Auditing & Privilege settings - which accounts can perform privileged operations
• Is a database that stores accounts data and relevant security information about local principals and local groups
• When a user logs on to a computer using a local account the SAM process takes the logon information and performs a lookup against
the SAM database
• If the credentials match the user can log on to the system
• The SAM file is binary rather than text, and passwords are stored using the MD4 hash algorithm
• On Windows Vista and later, the SAM stores password information using a password-based key derivation function (PBKCS) which
is substantially more robust against password guessing attacks than MD4
• Microsoft’s LDAP directory included with Windows Server 2000 and later
• All currently supported client versions of Windows, including Windows XP and Windows 7, can communicate with AD to
perform security operations including account logon
• A Windows client will authenticate using AD when the user logs on to the computer using a domain account rather than a
local account
Using PowerShell for Security Administration
Windows versions since 7 include an incredibly flexible scripting language named PowerShell. PowerShell provides
rich access to Windows computers, and that includes access to security settings. Using PowerShell it is possible to
create bespoke management tools for your organization.
2) Commands in PowerShell are called cmdlets, and have a consistent verb-noun syntax.
3) Like all scripting environments, PowerShell supports piping output from one command to another. But unlike other
scripting environments, PowerShell pipes objects not text. This allows for very rich data processing, filtering and
analysis.
In Windows, a username can be in one of two formats. The first, named the SAM format, is supported by all versions of
Windows and is of the form DOMAIN\Username. The second is called User Principal Name (UPN) and looks more like
an RFC822 e-mail address: [email protected].
If the user enters just a username, then the domain in which the machine resides is pre-pended to the user name. So if
Blake’s PC is in the Development domain, and he enters ‘Blake’ as his logon account, he is actually logging on using
Development\Blake if SAM accounts are used, or [email protected] if UPN names are used.
Assuming the user logs on correctly, a token is generated by the operating system and assigned to the user. A token
contains the user’s SID, group membership information, and privileges. Groups are also represented using SIDs.
The user’s token is assigned to every process run by the user. It is used to perform access checks,
discussed subsequently.
Privileges in Windows
• Privileges are system-wide permissions assigned to user accounts
• Some privileges are deemed “dangerous”, which means a malicious account that is granted
such a privilege can cause damage
• Examples of dangerous privileges include:
o Act as part of operating system privilege
• This is the most dangerous privilege in Windows and is granted only the Local System account; even administrators are not
granted this privilege
o Debug programs privilege
• This privilege basically means a user can run any code he or she wants in any running process
o Backup files and directories privilege
• Any process running with this privilege will bypass all access control list checks
The process of
Account defenses One of the Windows
hardening is the
simplest and Server 2003 is a
The defenses process of 80/20 rule – if
effective ways server and not a
shoring up the feature is
with Windows Network defenses defenses, not used by 80%
to reduce attack client platform,
can be grouped This process is surface is to the Web
reducing the of the
called Attack replace browser
into four broad amount of
Surface
population then
anonymous Internet
categories Memory corruption functionality
Reduction
the feature
networking Explorer was
defenses exposed to should be
protocols with stripped of all
untrusted users, disabled by
authenticated mobile code
and disabling default
networking support by
Browser defenses less-used
protocols default
features
Windows Hardening
Account Defenses Low Privilege Accounts
• The Local Service account and the
Principle of least privilege dictates that users
should operate with just enough privilege to Network service account allow a
get the tasks done, and no more
service local or network access, but
processes running with these
accounts operate at a much lower
Windows XP and Windows Server 2003 add
privilege level
a feature named “Secondary Logon” which o Neither of these accounts are members of the local
allows a user account to right click an administrator's group
application, select “run as….”, and then enter
another user account and password to run
the application
Note the stacks EBP (extended base pointer) and EIP (extended instruction
pointer). When the function returns, it must continue execution at the next
instruction after the instruction that called this function.
The CPU does this by taking the values off stack & populating the EBP &
EIP registers.
If the attacker can overflow the buffer on the stack, they can overrun the
data used to populate the EBP & EIP registers with values & change the
application’s execution flow.
The source code for Windows XP SP2 is compiled with a special compiler switch /GS, once the code is compiled with
this option, the stack is laid out as shown in Figure 26.2b
A cookie has been inserted between stack data and function return address. This random value is checked when the
function exits, and if the cookie is corrupted, the application is halted.
Buffers on the stack are placed in higher memory than nonbuffers, such as function pointers, C++ objects, and scalar
values to make it harder for some attacks to succeed.
By switching the order around, the attacker must take advantage of a buffer underrun, which is rarer, to successfully
corrupt the function pointer. There are variants of the buffer overrun that will still corrupt a function pointer, such as
corrupting a stack frame in higher memory.
No EXecute
• Named NX by Advanced Micro Devices (AMD), Data Execution Prevention (DEP) by Microsoft,
and eXecution Disable (XD) by Intel,
• Requires CPU support that helps prevent code from executing in data segments. Most modern Intel
CPUs support this capability today, and all current AMD CPUs support NX. ARM-based CPUs also
support NX.
• DEP support was first introduced in Windows XP SP2 and is a critically important defense in
Windows, especially when used with address space layout randomization (ASLR).
• The goal of NX is to prevent data executing. Most buffer overrun exploits enter a computer system
as data, and then those data are executed.
• The stack randomization defense is where Windows randomizes the stack base address by 0-31
pages for a thread.
• Normally, a page is 4k bytes in size. Once the page is chosen, a random offset is chosen within the
page, and the stack starts from that spot.
• The purpose of randomization is to remove some of the predictability from the attacker.
• Attackers love predictability because it makes it more likely that an attack will be successful.
Heap-Based Buffer Overrun Detection
• Heap-based buffer overruns are exploitable and can lead to code execution
• The first heap defense, added to XP SP2, is to add a random value to each heap block and
detect that this cookie has not been tampered with
o If the cookie has changed the heap has been corrupted and the application could be forced to crash
o Note: the application crash is not due to instability in the application caused by data corruption, rather the heap manager detects
the corruption and fails the application
o The process of shutting down an application in this manner is often called “failstop”
• The second defense is heap integrity checking
o When heap blocks are freed, metadata in the heap data structures are checked for validity, and if the data are compromised, either
the heap block is leaked or the application crashes
• At a very high level, EFS works by generating a random file encryption Key (FEK) and storing that key,
encrypted using the user’s encryption key. This key is protected using the Data Protection API (DPAPI) in
Windows, and the key used by DPAPI is derived from the user’s password.
• BitLocker Drive Encryption helps mitigate is data disclosure on stolen laptops. BitLocker encrypts the entire
volume with using AES, and the encryption key is stored either on a USB drive or within a Trusted Platform
Module (TPM) chip on the computer motherboard.
• When booting a system that requires the USB device, the device must be present so the keys can be read by the
computer, after which BitLocker decrypts the hard drive on the fly, with no perceptible performance degradation.
The downside to using a USB device is that if the device is lost, the user loses the encryption keys and cannot
decrypt. Thankfully, BitLocker can integrate with Active Directory to store the encryption keys, and BitLocker
also supports key recovery.
• Perhaps the most important aspect of BitLocker is that, like most security settings in Windows, BitLocker policy
can be set as a policy for a single computer and that policy ‘pushed’ to computers that use Active Directory.
BitLocker is the first technology in Windows to use a TPM chip