SlideShare a Scribd company logo
1 of 89
Linux OS : Security and Hardening – An Overview
The Linux OS -The Linux OS -
Security and Hardening OverviewSecurity and Hardening Overview
for Developersfor Developers
Focus on Buffer OverflowFocus on Buffer Overflow
With a PoC on the ARM ProcessorWith a PoC on the ARM Processor
kaiwanTECHkaiwanTECH
http://kaiwantech.inhttp://kaiwantech.in
Linux OS : Security and Hardening – An Overview
Linux OS – Security and Hardening
● Agenda
– Basic Terminology
– Current State
● Linux kernel vulnerability stats
● “Security Vulnerabilities in Modern OS’s” - a few slides
– Tech Preliminary: the process Stack
– BOF Vulnerabilities
● What is BOF
● Why is it dangerous?
● [Demo: a PoC on the ARM processor]
Linux OS : Security and Hardening – An Overview
Linux OS – Security and Hardening
● Agenda (contd.)
– Modern OS Hardening Countermeasures
● Using Managed programming languages
● Compiler protection
● Libraries
● Executable space protection
● ASLR
● Better Testing
– Conclusion + Q&A
Mar 16, 2017 kaiwanTECH
4
Linux OS : Security and Hardening – An Overview
Basic Terminology
Source - Wikipedia
Vulnerability
In computer security, a vulnerability is a weakness which allows an
attacker to reduce a system's information assurance.
Vulnerability is the intersection of three elements: a system susceptibility
or flaw, attacker access to the flaw, and attacker capability to exploit the
flaw.
A software vulnerability is a security flaw, glitch, or weakness found
in software or in an operating system (OS) that can lead to security
concerns. An example of a software flaw is a buffer overflow.
Mar 16, 2017 kaiwanTECH
5
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
Source - Wikipedia
Exploit
In computing, an exploit is an attack on a computer system,
especially one that takes advantage of a particular vulnerability
that the system offers to intruders.
Used as a verb, the term refers to the act of successfully
making such an attack.
Mar 16, 2017 kaiwanTECH
6
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
Source: CVEdetails
What is an "Exposure"?
An information security exposure is a mistake in software
that allows access to information or capabilities that can be
used by a hacker as a stepping-stone into a system or
network.
Mar 16, 2017 kaiwanTECH
7
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
● What is CVE? [Source]
– “Common Vulnerabilities and Exposures (CVE®) is a dictionary of common names (i.e., CVE
Identifiers) for publicly known cybersecurity vulnerabilities. CVE's common identifiers make it
easier to share data across separate network security databases and tools, and provide a
baseline for evaluating the coverage of an organization’s security tools. ...”
– CVE is
● One name for one vulnerability or exposure
● One standardized description for each vulnerability or exposure
● A dictionary rather than a database
● How disparate databases and tools can "speak" the same language
● The way to interoperability and better security coverage
● A basis for evaluation among tools and databases
● Free for public download and use
● Industry-endorsed via the CVE Numbering Authorities, CVE Board, and CVE-Compatible
Products
Mar 16, 2017 kaiwanTECH
8
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
What is a CVE Identifier?
CVE Identifiers (also called "CVE names," "CVE numbers," CVE-IDs," and "CVEs")
are unique, common identifiers for publicly known information security vulnerabilities.
Each CVE Identifier includes the following:
●
CVE identifier number (i.e., "CVE-1999-0067").
●
Indication of "entry" or "candidate" status.
●
Brief description of the security vulnerability or exposure.
●
Any pertinent references (i.e., vulnerability reports and advisories or OVAL-ID).
●
CVE Identifiers are used by information security product/service vendors and
researchers as a standard method for identifying vulnerabilities and for cross-linking
with other repositories that also use CVE Identifiers.
CVE FAQs Page
Mar 16, 2017 kaiwanTECH
9
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
CVE Identifier –
Old and New Syntax
● Practically, from Jan 2015
Mar 16, 2017 kaiwanTECH
10
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
A CVE Example
● CVE-2014-0160 [aka “Heartbleed”]
● Description:
– The (1) TLS and (2) DTLS implementations in OpenSSL
1.0.1 before 1.0.1g do not properly handle Heartbeat
Extension packets, which allows remote attackers to
obtain sensitive information from process memory via
crafted packets that trigger a buffer over-read, as
demonstrated by reading private keys, related to
d1_both.c and t1_lib.c, aka the Heartbleed bug.
Mar 16, 2017 kaiwanTECH
11
Linux OS : Security and Hardening – An Overview
Mar 16, 2017 kaiwanTECH
12
Linux OS : Security and Hardening – An Overview
Basic Terminology
(contd.)
Most software security vulnerabilities fall into one of a
small set of categories:
● buffer overflows
● unvalidated input
● race conditions
● access-control problems
● weaknesses in authentication, authorization, or
cryptographic practices
Source
Mar 16, 2017 kaiwanTECH
13
Linux OS : Security and Hardening – An Overview
CWE - Common Weakness Enumeration - Types of Exploits
Mar 16, 2017 kaiwanTECH
14
Linux OS : Security and Hardening – An Overview
Linux kernel – Vulnerability Stats
Source (CVEdetails)
(1999 to date)
Mar 16, 2017 kaiwanTECH
15
Linux OS : Security and Hardening – An Overview
Linux kernel – Vulnerability Stats
Source (CVEdetails)
(1999 to date)
Mar 16, 2017 kaiwanTECH
16
Linux OS : Security and Hardening – An Overview
Security Vulnerabilities in Modern Operating
Systems
By Cisco, Canada, April 2014.
All rights with Cisco.
“The Common Exposures and Vulnerabilities database has
over 25 years of data on vulnerabilities in it. In this deck we
dig through that database and use it to map out trends and
general information on vulnerabilities in software in the last
quarter century. For more information please visit our
website: http://www.cisco.com/web/CA/index.html ”
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
17
Linux OS : Security and Hardening – An Overview
OS Security Vulnerabilities
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
18
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
19
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
20
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
21
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
22
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
23
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
24
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
25
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
26
Linux OS : Security and Hardening – An Overview
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
Mar 16, 2017 kaiwanTECH
27
Linux OS : Security and Hardening – An Overview
OS Security Vulnerabilities
Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
END “Security Vulnerabilities in Modern Operating Systems”
CISCO Presentation Slides
Mar 16, 2017 kaiwanTECH
28
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
What exactly is a buffer overflow (BOF)?
●
Prerequisite – an understanding of the process stack!
●
Lets write some simple ‘C’ code to understand this first-hand.
●
[An Aside: As we shall soon see, nowadays several mitigations/hardening technologies exist to
help prevent BOF attacks. So, sometimes the question (SO InfoSec) arises: “
Should I bother teaching buffer overflows any more?”:
Short answer, “YES”:
“… Yes. Apart from the systems where buffer overflows lead to successful exploits, full
explanations on buffer overflows are always a great way to demonstrate how you should think
about security. Instead on concentrating on how the application should run, see what can be done
in order to make the application derail.
Also, regardless of stack execution and how many screaming canaries you install, a buffer overflow is
a bug. All those security features simply alter the consequences of the bug: instead of a remote shell,
you "just" get an immediate application crash. Not caring about application crashes (in particular
crashes which can be triggered remotely) is, at best, very sloppy programming. ...”
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
29
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The Classic Case
Lets imagine that here is part of the (drastically
simplified) Requirement Spec for a console-based
app:
● Write a function ‘foo()’ that accepts the user’s
name, email id and employee number
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
30
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The Classic Case – function foo() implemented below by app
developer in ‘C’:
[...]
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
31
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● Why have a “stack” at all ?
– Humans write code using a 3rd
or 4th
generation
high-level language (well, most of us
anyway :-)
– The processor hardware does not ‘get’ what a
function is, what parameters and return values
are!
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
32
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The Classic Case – function foo() implemented below by app
developer in ‘C’:
[...]
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
A local buffer, hence allocated
on the process stack
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
33
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● So, what really, is this process stack ?
– it’s just memory treated with special semantics
– Uses a “PUSH / POP” model
– “Grows” towards lower (virtual) addresses; called a
“downward-growing stack”
● this attribute is processor-specific; it’s the case for most
modern CPUs, including x86, x86_64, ARM and ARM64)
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
34
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● Why have a “stack” at all ?
– The saviour: the compiler generates assembly
code which enables the function-calling-and-
return mechanism
– By making use of the stack!
● How exactly?
… Aha ...
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
35
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● The Stack
– When a program calls a function, the compiler
generates code to setup a call stack, which consists
of individual stack frames
– A stack frame can be visualized as a “block”
containing all the metadata necessary for the system
to process the “function” call and return
● Access it’s parameters, if any
● Allocate it’s local variables
● Execute it’s code (text)
● Return a value as required
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
36
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● The Stack Frame
– Hence, the stack frame will require a means to
– Locate the previous (caller’s) stack frame (achieved
via the SFP – Stack Frame Pointer)
– Gain access to the function’s parameters
– Store the address to which control must continue,
IOW, the RETurn address
– Allocate storage for the function’s local variables
– Turns out that the exact stack frame layout is very
processor-dependant (depends on it’s ABI, calling
conventions)
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
37
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● Recall our simple ‘C’ code:
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
38
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● Have it called from main()
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
}
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
39
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● When main() calls foo(), a stack frame is setup (as part
of the call stack)
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
}
Preliminaries – the STACK
Mar 16, 2017 kaiwanTECH
40
Linux OS : Security and Hardening – An Overview
Call StackCall Stack
..
..
..
Call StackCall Stack
..
..
..
Buffer Overflow (BOF)
● When main() calls foo(),
a stack frame is setup
(as part of the call stack)
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
} *va = virtual addresses
Stack Frame for
main()
Stack Frame for
main()
Stack Frame for
foo()
Stack Frame for
foo()
Preliminaries – the STACK
SP (top of the stack)
Lowest address
Increasing
va*
Mar 16, 2017 kaiwanTECH
41
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● When main() calls foo(), a stack frame is setup (as part
of the call stack)
static void foo(void)
{
char local[12];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
} *va = virtual addresses
Call Stack
.
.
.
Call Stack
.
.
.
Stack Frame for
main()
Stack Frame for
main()
Stack Frame for
foo()
Stack Frame for
foo()
Preliminaries – the STACK
SP (top of the stack)
Lowest address
Increasing
va*
Mar 16, 2017 kaiwanTECH
42
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● When main() calls foo(), a stack frame is setup (as part
of the call stack)
static void foo(void)
{
char local[12];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
} *va = virtual addresses
Call Stack
.
.
.
Call Stack
.
.
.
Stack Frame for
main()
Stack Frame for
main()
Stack Frame for
foo()
Stack Frame for
foo()
… Parameters ...
RET Address
SFP
… Local variables ...
… Parameters ...
RET Address
SFP
… Local variables ...
SFP = Saved Frame Pointer
Preliminaries – the STACK
Increasing
va*
SP (top of the stack)
Lowest address
Mar 16, 2017 kaiwanTECH
43
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Wikipedia on BOF
In computer security and programming, a buffer
overflow, or buffer overrun, is an anomaly
where a program, while writing data to a buffer,
overruns the buffer's boundary and overwrites
adjacent memory locations.
Mar 16, 2017 kaiwanTECH
44
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Recall:
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
}
A Simple BOF
Mar 16, 2017 kaiwanTECH
45
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
At runtime
static void foo(void)
{
char local[128];
printf(“Name: ”);
gets(local);
[...]
}
void main() {
foo();
}
A Simple BOF
params -none-
RET addr
SFP = main’s stack frame
… Local variables …
128 bytes
<empty>
foo() ‘s stack frame
4128bytes4
main() ‘s stack frame
Increasing
va*
SP (top of the stack)
Lowest address
Mar 16, 2017 kaiwanTECH
46
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Lets give it a spin-
$ gcc getdata.c -o getdata
[...]
$
$ printf "AAAABBBBCCCCDDDD" |./getdata
Name: Ok, about to exit...
$
A Simple BOF
Mar 16, 2017 kaiwanTECH
47
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Okay, step by step:
Step 1 of 4 :
Prepare to execute;
main() is called
$ gcc getdata.c -o getdata
[...]
$
$ printf "AAAABBBBCCCCDDDD"
| ./getdata
A Simple BOF
main() ‘s stack frame
params -none-
RET addr
SFP = main’s stack frame
… Local variables …
128 bytes
<empty>
4128bytes4
SP (top of the stack)
Lowest address
Increasing
va*
Mar 16, 2017 kaiwanTECH
48
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Okay, step by step:
Step 2 of 4 :
Input 16 characters into the
local buffer via the gets();
$ gcc getdata.c -o getdata
[...]
$
A Simple BOF
main() ‘s stack frame
foo() ‘s stack frame
params -none-
RET addr
SFP = main’s stack frame
… Local variables …
128 bytes
0x43434343 0x44444444
0x41414141 0x42424242
Increasing
va*
SP (top of the stack)
4128bytes4$ printf "AAAABBBBCCCCDDDD" |./getdata
16 chars
written into the stack
@ var ‘local’
All okay!All okay!All okay!All okay!
‘local’ 128 bytes
<empty>
Mar 16, 2017 kaiwanTECH
49
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Okay, step by step:
Step 3 of 4 :
Input 128+4+4 = 136 characters
into the local buffer via the gets();
thus Overflowing it!
$ gcc getdata.c -o getdata
[...]
$
$ printf "AAAABBBBCCCCDDDD"
AAAABBBBCCCCDDDD$
A Simple BOF – Action!
0x41414141 0x41414141
[...]
0x41414141 0x41414141
0x41414141 0x41414141
0x41414141 0x41414141
0x41414141 0x41414141
main() ‘s stack frame
foo() ‘s stack frame
params -none-
RET addr
SFP
SP (top of the stack)
4128bytes4perl -e 'print "A"x136' |./getdata ‘local’ 128 bytes
<empty>
136 chars
written into
the stack @ var ‘local’
Increasing
va*
Mar 16, 2017 kaiwanTECH
50
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Okay, step by step:
Step 4 of 4 :
Input 128+4+4 = 136 characters
into the local buffer via the gets();
thus Overflowing it!
$ gcc getdata.c -o getdata
[...]
$
$ printf "AAAABBBBCCCCDDDD"
AAAABBBBCCCCDDDD$
A Simple BOF – Action!
params -none-
RET addr = 0x41414141
SFP = 0x41414141
0x41414141 0x41414141
[...]
0x41414141 0x41414141
0x41414141 0x41414141
0x41414141 0x41414141
0x41414141 0x41414141
136 chars
(ASCII ‘A’ = 0x41)
written into
the var ‘local’
4128bytes4
main() ‘s stack frame
foo() ‘s stack frame
SP (top of the stack)
Why?
As the processor tries to return to the
designated RET address,
it attempts to access and
execute code at
virtual address 0x41414141
that isn’t really there or is illegal
perl -e 'print "A"x136' |./getdata
Segmentation fault
$
It segfaults !It segfaults !
Increasing
va*
OVERWRITESOVERWRITES
Mar 16, 2017 kaiwanTECH
51
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
A physical buffer
overflow: The
Montparnasse
derailment of 1895
Source: “Secure Programming HOWTO”, David Wheeler
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
52
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Okay, it crashed.
So what? … you say
No danger, just a bug
to be fixed...
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
53
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Okay, it crashed.
So what? … you say …
No danger, just a bug to be fixed…
It IS DANGEROUS !!!
Why??
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
54
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Recall why the app crashed (segfault-ed):
– The RETURN address was set to an incorrect/bogus/junk
value (0x41414141)
● Instead of just crashing the app, a hacker will craft the RET
address to a deliberate value – code that (s)he wants
executed!
● How exactly?
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
55
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Instead of running the app like this:
$ perl -e 'print "A"x136' | ./getdata
which would cause it to just segfault,
how about this:
$ perl -e 'print "A"x132 . "x49x8fx04x78"'
| ./getdata
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
56
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload, or ‘crafted buffer’ is:
payload = 128 A’s + <SFP value> + <RET addr>
= AAAAA...AAAA + AAAA + 0x498f0478
● As seen, given a local buffer of 128 bytes, the overflow spills into the
higher addresses of the stack
● In this case, the overflow is 4+4 bytes
● Which overwrites the
– SFP (Saved Frame Pointer – essentially pointer to prev stack frame),
and the
– RETurn address, on the process stack
● … thus causing control to be re-vectored to the RET address!
● We thus have Arbitrary Code Execution (which could
result in privilege escalation, a backdoor, etc)!
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
57
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be used to deploy an
attack in many forms:
● Direct code execution: executable machine code
“injected” onto the stack, with the RET address
arranged such that it points to this code
● Indirect code execution:
– To internal program function(s)
– To external library function(s)
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
58
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be deployed in many
forms:
● Direct executable machine code “injected” onto the
stack, with the RET address arranged such that it points
to this code
– What code?
– Typically, a variation of the machine language for:
seteuid(0);
execl(“/bin/sh”, “sh”, 0);
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
59
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be deployed in many
forms:
seteuid(0);
execve(“/bin/sh”, argv, 0);
● Collection of shellcode!
http://shell-storm.org/shellcode/
– Eg. 1 : setuid(0); execve(/bin/sh,0)
http://shell-storm.org/shellcode/files/shellcode-472.php
● Or, use the Google Hacking DB (GHDB), or
● Explot-DB (Offensive Security)
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
60
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be deployed in many
forms:
– Eg. 2 : adds a root user no-passwd to /etc/passwd
(84 bytes)
char shellcode[]=
"x31xc0x31xdbx31xc9x53x68x73x73x77"
"x64x68x63x2fx70x61x68x2fx2fx65x74"
"x89xe3x66xb9x01x04xb0x05xcdx80x89"
"xc3x31xc0x31xd2x68x6ex2fx73x68x68"
"x2fx2fx62x69x68x3ax3ax2fx3ax68x3a"
"x30x3ax30x68x62x6fx62x3ax89xe1xb2"
"x14xb0x04xcdx80x31xc0xb0x06xcdx80"
"x31xc0xb0x01xcdx80";
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
61
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be deployed in many forms:
● Indirect code execution:
– To internal program function(s)
– To external program function(s)
● Re-vector (forcibly change) the RET address such that control
is vectored to an - typically unexpected, out of the “normal”
flow of control - internal program function
<<
(Time permitting :-)
Demo of a BOF PoC on ARM Linux, showing
precisely this
>>
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
62
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be deployed in many
forms:
● Indirect code execution:
– To internal program function(s)
– To external library function(s)
● Revector (forcibly change) the RET address such
control is vectored to an - typically unexpected, out of
the “normal” flow of control - external library function
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
63
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
The payload or ‘crafted buffer’ can be deployed in many forms:
● Re-vector (forcibly change) the RET address such that control is
vectored to an - typically unexpected, out of the “normal” flow of
control - external library function
● What if we re-vector control to a Std C Library (glibc) function:
– Perhaps to, say, system(char *cmd);
– Can setup the parameter (pointer to a command string) on the stack
– !!! Just think of the possibilities !!! - in effect, one can execute anything
– that’s pretty much exactly what the Ret2Libc hack / exploit is.
–
A Simple BOF / Dangerous?
Mar 16, 2017 kaiwanTECH
64
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
● MUST-SEE! Real Life Examples - gathers a few actual
attacks of different kinds- phishing, password, crypto, input,
BOFs, etc
● A few ‘famous’ (public) Buffer Overflow (BOF) Exploits
– 02 Nov 1988: Morris Worm – first network ‘worm’; exploits a
BoF in fingerd (and DEBUG cmd in sendmail). Article and
Details
– 15 July 2001: Code Red and Code Red II ; CVE-2001-0500
– 07 Apr 2014: Heartbleed ; CVE-2014-0160
● The Risks Digest
BoF + Other Attacks in the Real-World
Mar 16, 2017 kaiwanTECH
65
Linux OS : Security and Hardening – An Overview
Buffer Overflow (BOF)
Interesting!
● Mar 2017:
Hard Drive LED Allows Data Theft From Air-Gapped PCs
● Gaming console hacks – due to BOF exploits
– Jan 2003:
Hacker breaks Xbox protection without mod-chip
– PlayStation 2 Homebrew
– Wii Twilight hack
● 10 of the worst moments in network security history
BoF + Other Attacks in the Real-World
Mar 16, 2017 kaiwanTECH
66
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
● A modern OS, like Linux, will / should implement a number of countermeasures or
“hardening” techniques against vulnerabilities, and hence, potential exploits
● Reduces the attack surface
● Common Hardening Countermeasures include-
● Using Managed programming languages
● Compiler protection
● Library protection
● Executable space protection
● [K]ASLR
● Better Testing
Mar 16, 2017 kaiwanTECH
67
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Using Managed programming languages
●
Programming in C/C++ is widespread and popular
●
Pros- powerful, ‘close to the metal’, fast
●
Cons-
– Programmer handles memory
– Cause of many (most) memory bugs
– Which lead to insecure exploitable software
●
A ‘managed’ language uses a framework (eg .NET) and/or a virtual machine construct
●
Using a ‘managed’ language (Java, C#) greatly alleviates the burden of memory
management from the programmer to the ‘runtime’
●
Reality –
– Many languages are implemented in C/C++
– Real projects are usually a mix of managed and unmanaged code (eg. Android: Java
@app layer + C/C++/JNI/DalvikVM @middleware + C/Assembly @kernel/drivers layers)
● [Aside: ‘C’ outdated? See the TIOBE Index for Programming languages]
Mar 16, 2017 kaiwanTECH
68
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Compiler-level Protection
● Stack BOF Protection
– Early implementations include
● StackGuard (1997)
● ProPolice (IBM, 2001)
– GCC patches for stack-smashing protection
– GCC
● -fstack-protector flag (RedHat, 2005), and
● -fstack-protector-all flag
● -fstack-protector-strong flag (Google, 2012); gcc 4.9 onwards
● Early in Android (1.5 onwards) – all Android binaries include
this flag
Mar 16, 2017 kaiwanTECH
69
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Compiler-level Protection
● From Wikipedia:
“All Fedora packages are compiled with -fstack-protector since Fedora Core 5, and -fstack-
protector-strong since Fedora 20.[19]cite_ref-20cite_ref-20[20]
Most packages in Ubuntu are compiled with -fstack-protector since 6.10.[21]
Every Arch Linux package is compiled with -fstack-protector since 2011.[22]
All Arch Linux packages built since 4 May 2014 use -fstack-protector-strong.[23]
Stack protection is only used for some packages in Debian,[24] and only for the FreeBSD
base system since 8.0.[25] ...”
● How is the ‘-fstack-protector<-xxx>’ flag protection actually achieved?
– Typical stack frame layout:
[… local vars …] [CTLI] [RET addr] ; where [CTLI] is control information
(like the SFP)
– A random value, called a “canary”, is placed by the compiler in the stack
metadata, typically between the local variables and the RET address
– [… local vars …] [canary] [CTLI] [RET addr]
Mar 16, 2017 kaiwanTECH
70
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Compiler-level Protection
● How is the ‘-fstack-protector<-xxx>’ flag protection actually achieved?
[contd.]
– Before a function returns, the canary is checked (by instructions inserted by
the compiler into the function epilogue)
[… local vars …] [canary] [CTLI] [RET addr]
– If the canary has changed, it’s determined that an attack is underway (it
might be an unintentional bug too), and the process is aborted (if it occurs
in kernel-space, the Linux kernel panics!)
– The overhead is considered minimal
– [Exercise: try a BOF program. (Re)compile it with -fstack-protector gcc flag
and retry (remember, requires >= gcc-4.9)]
Mar 16, 2017 kaiwanTECH
71
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Compiler-level Protection
●
(Some) mitigation against a format-string attack:
– Use the GCC flags -Wformat-security -Werror=format-security
– Android
●
Oct 2008- disables use of “%n” format specifier
●
2.3 (Gingerbread) onwards uses the -Wformat-security and the -Werror=format-
security GCC flags for all binaries
● Using GCC _FORTIFY_SOURCE
– Lightweight protection against BOF in typical libc functions
– Wrappers around the following ‘typically dangerous’ functions:
● memcpy, mempcpy, memmove, memset, strcpy, stpcpy, strncpy, strcat,
strncat, sprintf, vsprintf, snprintf, vsnprintf, gets
– Must be used in conjunction with optimization directive:
-On -D_FORTIFY_SOURCE=n ; (n>=1)
– Eg. gcc prog.c -O2 -D_FORTIFY_SOURCE=2 -o prog -Wall <...>
– More details available here.
Mar 16, 2017 kaiwanTECH
72
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Compiler-level Protection
● (Full) Relro – Read-Only Relocation
– Marks the linker Global Offset Table (GOT) as RO
– Achieved by compiling with the linker options: -Wl,-z,now
– Android v4.4.1 onwards
● Address Sanitizer (ASan)
– ASan: “a programming tool that detects memory corruption bugs such as buffer overflows or
accesses to a dangling pointer (use-after-free). AddressSanitizer is based on compiler
instrumentation and directly-mapped shadow memory. AddressSanitizer is currently implemented
in Clang (starting from version 3.1[1]) and GCC (starting from version 4.8[2]). On average, the
instrumentation increases processing time by about 73% and memory usage by 340%.[3]”
– “Address sanitizer is nothing short of amazing; it does an excellent job at detecting nearly all buffer
over-reads and over-writes (for global, stack, or heap values), use-after-free, and double-free. It
can also detect use-after-return and memory leaks” Source
– Usage: just compile with the GCC flag: -fsanitize=address
● [SO] What is the most hardened set of options for GCC compiling
Mar 16, 2017 kaiwanTECH
73
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Libraries
● BOF exploits – how does one attack?
● By studying real running apps, looking for a weakness to
exploit (enumeration)
– f.e. the infamous libc gets() (and similar) function(s) in [g]libc!
● It’s mostly by exploiting these common memory bugs that an
exploit can be crafted and executed
● Thus, it’s Really Important that developers re-learn: we Must
Avoid using std lib functions which are not bounds-checked
– gets, sprintf, strcpy, scanf, etc
– Replaced with fgets, snprintf, strncpy, etc
Mar 16, 2017 kaiwanTECH
74
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Libraries
● Best to make use of “safe” libraries, especially for string handling
● Obviously, a major goal is to prevent security vulnerabilities
● Examples include
– The Better String Library
– Safe C Library
– Simple Dynamic String library
– Libsafe
– Also see:
Ch 6 “Library Solutions in C/C++Library Solutions in C/C++”, Secure Programming for UNIX and
● Source - Cisco Application Developer Security Guide
“… In recent years, web-based vulnerabilities have surpassed traditional buffer overflow attacks both in terms of
absolute numbers as well as the rate of growth. The most common forms of web-based attacks, such as cross-site
scripting (XSS) and SQL injection, can be mitigated with proper input validation.
Cisco strongly recommends that you incorporate the Enterprise Security API (ESAPI) Toolkit from the Open Web
Application Security Project (OWASP) for input validation of web-based applications. ESAPI comes with a set of
well-defined security API, along with ready-to-deploy reference implementations.”
Mar 16, 2017 kaiwanTECH
75
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Executable Space Protection
● The most common attack vector
– Inject shellcode onto the stack (or heap), typically via a BOF vuln
– Arrange to have the shellcode execute, thus gaining privilege (or a
backdoor)
● Modern processors have the ability to ‘mark’ a page with an NX (No
eXecute) bit
– So if we ensure that all pages of data regions like the stack, heap, BSS, etc
are marked as NX, then the shellcode holds no danger!
– The typical BOF (‘stack smashing’) attack relies on memory being
readable, writeable and executeable (rwx)
● MS calls it DEP (Data Execution Prevention)
Mar 16, 2017 kaiwanTECH
76
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Executable Space Protection
● Linux kernel
– Supports the NX bit from v2.6.8 onwards
– On processors that have the hardware capability
● Includes x86, x86_64 and x86_64 running in 32-bit mode
● x86_32 requires PAE to support NX
● (However) For CPUs that do not natively support NX, 32-bit Linux has
software that emulates the NX bit, thus protecting non-executable pages
● Check for NX hardware support (on Linux):
grep -w nx -q /proc/cpuinfo && echo "Yes" || echo
"Nope"
● A commit by Kees Cook (v2.6.38) ensures that even if NX support is
turned off in the BIOS, that is ignored by the OS and protection remains
Mar 16, 2017 kaiwanTECH
77
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Executable Space Protection
● Ref: https://en.wikipedia.org/wiki/NX_bit
● (More on) Processors supporting the NX bit
– Intel markets it as XD (eXecute Disable)
– AMD as ‘EVP’ - Enhanced Virus Protection
– ARM as XN – eXecute Never
– Android: As of Android 2.3 and later, architectures which support it have
non-executable pages by default, including non-executable stack and
heap.[1][2][3]
● ARMv6 onwards (new PTE format with XN bit)
● PowerPC
● Itanium, Alpha, SunSparc, etc too support it
Mar 16, 2017 kaiwanTECH
78
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
ASLR – Address Space Layout Randomization
● NX (or DEP) protects a system by not allowing arbitrary code execution on
non-text pages (stack/heap/data/BSS/etc)
● But it cannot protect against attacks that invoke legal code – like [g]libc
functions, system calls (as they’re in a valid text segment and are thus marked
as r-x in their resp PTE entries)
● In fact, this is the attack vector for what is commonly called Ret2Libc and ROP-
style attacks
● How can these be prevented?
– ASLR : by randomizing the layout of the process VAS (virtual address
space), an attacker cannot know (or guess) in advance the location (virtual
address) of glibc code, system call code, etc
– Hence, launching this attack inherently fails
Mar 16, 2017 kaiwanTECH
79
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
ASLR – Address Space Layout Randomization
● Note though:
– (K)ASLR is a statistical protection not an absolute one; it just adds an
additional layer of difficulty (depending on the # random bits available) for
an attacker, but does not inherently prevent attacks in any way
– Also, even with full ASLR support, a particular process may not have it’s
VAS randomized
– Why? Because this requires compile-time support - within the binary
executable too: the binary must be built as a Position independent
Executable (PIE)
● Process ASLR – turned On by compiling source with the -fPIE and -pie gcc
flags
● Information leakage (for eg. a known kernel pointer value) can completely
comprise the ASLR schema (example).
Mar 16, 2017 kaiwanTECH
80
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Better Testing
● Of course, most Q&A teams (as well as conscientious developers) will
devise, implement and run an impressive array of test cases for the
given product or project
● However, it’s usually the case that most of these fall into the positive
test-cases bracket (checks that the test yields the desired outcome)
● This approach will typically fail to find bugs and vulnerabilities that an
attacker probes for
– We have to adopt an “attacker” mindset (“set a thief to catch a thief”)
– We need to develop an impressive array of thorough negative test-
cases (which check whether the program-under-test fails correctly
and gracefully)
Mar 16, 2017 kaiwanTECH
81
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Better Testing
● A typical example:
the user is to pass a simple integer value:
– Have test cases been written to check that it’s within
designated bounds?
– Both positive and negative (integer overflow – IOF - bugs
are heavily exploited! ;
see SO: How is integer overflow exploitable?)
● From OWASP: “Arithmetic operations cause a number to either grow
too large to be represented in the number of bits allocated to it, or too
small. This could cause a positive number to become negative or a
negative number to become positive, resulting in
unexpected/dangerous behavior.”
Mar 16, 2017 kaiwanTECH
82
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Better Testing
● Food for thought
ptr = calloc(var_a*var_b, sizeof(int));
● What if it overflows??
– Did you write a validity check for the parameter to calloc?
– Old libc bug- an IOF could result in a much smaller buffer being
allocated via calloc() !
● Static analysis could / should catch a bug like this
● Dynamic analysis - take Valgrind’s MemCheck tool (of
course, Valgrind will only work on dynamic memory,
not compile-time memory)
Mar 16, 2017 kaiwanTECH
83
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Better Testing
● IOF
– Google wrote a safe_iop (integer operations) library for Android
(from first rel)
– However, as of Android 4.2.2, it appears to be used in a very limited
fashion and is out-of-date too
● Fuzzing
– “Fuzz testing or fuzzing is a software testing technique used to
discover coding errors and security loopholes in software, operating
systems or networks by inputting massive amounts of random data,
called fuzz, to the system in an attempt to make it crash.” Source
Mar 16, 2017 kaiwanTECH
84
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Better Testing
● Mostly-positive testing is practically useless
for secure software
● Thorough Negative Testing is a MUST
● Fuzzing
– especially effective in finding security-related bugs
– Bugs that cause a program to crash (in the normal
case)
Mar 16, 2017 kaiwanTECH
85
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
● Experience shows that having several hardening
techniques in place is far superior to having just 1 or 2
● Depth-of-Defense is critical
● For example, take ASLR and NX (or XN):
– Only NX, no ASLR: security bypassed via ROP-based
attacks
– Only ASLR, no NX: security bypassed via code injection
techniques like heap spraying
– Both full ASLR and NX: difficult to bypass by an attacker
Mar 16, 2017 kaiwanTECH
86
Linux OS : Security and Hardening – An Overview
Modern OS Hardening Countermeasures
Linux kernel – security patches into mainline
– Not so simple; the proverbial “tip of the iceberg”
– As far as security and hardening is concerned,
projects like GRSecurity, PaX and OpenWall have shown what
can be regarded as the “right” way forward
– However, the reality is that there continues to be serious resistance
from the kernel community to merging in similar patchsets
– [Why? Some legitimate-
● Info hiding - many apps / debuggers rely on pointers, information
from /proc, /sysfs, etc
● Debugging – breakpoints into code - don’t work with NX on
● Boot issues on some processors when NX used (being solved now)]
● More info available: Making attacks a little harder, LWN, Nov 2010
Mar 16, 2017 kaiwanTECH
87
Linux OS : Security and Hardening – An Overview
Conclusion
Basic principle of attack
First, a program with an exploitable vulnerability – local or remote - must be found.
This process is called Reconnaissance / footprinting / enumeration.
(Dynamic approach- attackers will often ‘fuzz’ a program to determine how it behaves;
static- use tools to disassemble/decompile (objdump,strings,IDA Pro,etc) the program
and search for vulnerable patterns. Use vuln scanners).
[Quick Tip: Check out nmap, Exploit-DB, the GHDB (Google Hacking Database) and
the Metasploit pen(etration)-testing framework].
A string containing shellcode is passed as input to the vulnerable program. It
overflows a buffer (a BOF), causing the shellcode to be executed (arbitrary code
execution). The shellcode provides some means of access (a backdoor, or simply a
direct shell) to the target system for the attacker.
Stealth- the target system should be unaware it’s been attacked (log cleaning, hiding).
Mar 16, 2017 kaiwanTECH
88
Linux OS : Security and Hardening – An Overview
Conclusion
ADVANCED-
Defeat protections?
●
ROP (Return Oriented Programming)
● Defeats ASLR, NX
– Not completely; modern Linux PIE executables and library PIC code
●
Uses “gadgets” to alter and control PC execution flow
●
A gadget is an existing piece of machine code that is leveraged to piece
together a sequence of statements
– it’s a non-linear programming technique!
– Each gadget ends with a :
●
X86: ‘ret’
● RISC (ARM): pop {rX, …, pc}
● Sophisticated, harder to pull off
●
But do-able!
…
Questions?
Linux OS : Security and Hardening – An Overview
Thank You!
kaiwanTECHkaiwanTECH
http://kaiwantech.inhttp://kaiwantech.in

More Related Content

What's hot

2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security OverviewShawn Wells
 
Threats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxThreats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxAmitesh Bharti
 
Introduction To Linux Security
Introduction To Linux SecurityIntroduction To Linux Security
Introduction To Linux SecurityMichael Boman
 
Basic Linux Security
Basic Linux SecurityBasic Linux Security
Basic Linux Securitypankaj009
 
Linux Operating System Vulnerabilities
Linux Operating System VulnerabilitiesLinux Operating System Vulnerabilities
Linux Operating System VulnerabilitiesInformation Technology
 
Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014
Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014
Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014Michael Boelen
 
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
Kernel Recipes 2013 - Linux Security Modules: different formal conceptsKernel Recipes 2013 - Linux Security Modules: different formal concepts
Kernel Recipes 2013 - Linux Security Modules: different formal conceptsAnne Nicolas
 
Unix Security
Unix SecurityUnix Security
Unix Securityreplay21
 
File System Implementation & Linux Security
File System Implementation & Linux SecurityFile System Implementation & Linux Security
File System Implementation & Linux SecurityGeo Marian
 
Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0
Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0
Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0Security Bootcamp
 
Linux Network Security
Linux Network SecurityLinux Network Security
Linux Network SecurityAmr Ali
 
Understanding SELinux For the Win
Understanding SELinux For the WinUnderstanding SELinux For the Win
Understanding SELinux For the Winbmbouter
 
MR201406 A Re-introduction to SELinux
MR201406 A Re-introduction to SELinuxMR201406 A Re-introduction to SELinux
MR201406 A Re-introduction to SELinuxFFRI, Inc.
 
Inside Out Hacking - Bypassing Firewall
Inside Out Hacking - Bypassing FirewallInside Out Hacking - Bypassing Firewall
Inside Out Hacking - Bypassing Firewallamiable_indian
 
Linux Security Overview
Linux Security OverviewLinux Security Overview
Linux Security OverviewKernel TLV
 
Secure and Simple Sandboxing in SELinux
Secure and Simple Sandboxing in SELinuxSecure and Simple Sandboxing in SELinux
Secure and Simple Sandboxing in SELinuxJames Morris
 

What's hot (20)

2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
 
Threats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxThreats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in Linux
 
Introduction To Linux Security
Introduction To Linux SecurityIntroduction To Linux Security
Introduction To Linux Security
 
Basic Linux Security
Basic Linux SecurityBasic Linux Security
Basic Linux Security
 
Security and Linux Security
Security and Linux SecuritySecurity and Linux Security
Security and Linux Security
 
Linux Operating System Vulnerabilities
Linux Operating System VulnerabilitiesLinux Operating System Vulnerabilities
Linux Operating System Vulnerabilities
 
Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014
Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014
Lynis - Hardening and auditing for Linux, Mac and Unix - NLUUG May 2014
 
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
Kernel Recipes 2013 - Linux Security Modules: different formal conceptsKernel Recipes 2013 - Linux Security Modules: different formal concepts
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
 
Unix Security
Unix SecurityUnix Security
Unix Security
 
File System Implementation & Linux Security
File System Implementation & Linux SecurityFile System Implementation & Linux Security
File System Implementation & Linux Security
 
Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0
Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0
Nguyen Duc Thinh - Docker security in Dev Ops environment 2.0
 
Linux Network Security
Linux Network SecurityLinux Network Security
Linux Network Security
 
Understanding SELinux For the Win
Understanding SELinux For the WinUnderstanding SELinux For the Win
Understanding SELinux For the Win
 
Introduction To SELinux
Introduction To SELinuxIntroduction To SELinux
Introduction To SELinux
 
SELinux Basic Usage
SELinux Basic UsageSELinux Basic Usage
SELinux Basic Usage
 
MR201406 A Re-introduction to SELinux
MR201406 A Re-introduction to SELinuxMR201406 A Re-introduction to SELinux
MR201406 A Re-introduction to SELinux
 
Inside Out Hacking - Bypassing Firewall
Inside Out Hacking - Bypassing FirewallInside Out Hacking - Bypassing Firewall
Inside Out Hacking - Bypassing Firewall
 
Selinux
SelinuxSelinux
Selinux
 
Linux Security Overview
Linux Security OverviewLinux Security Overview
Linux Security Overview
 
Secure and Simple Sandboxing in SELinux
Secure and Simple Sandboxing in SELinuxSecure and Simple Sandboxing in SELinux
Secure and Simple Sandboxing in SELinux
 

Viewers also liked

DDoS Attacks and Countermeasures
DDoS Attacks and CountermeasuresDDoS Attacks and Countermeasures
DDoS Attacks and Countermeasuresthaidn
 
VoIP: Attacks & Countermeasures in the Corporate World
VoIP: Attacks & Countermeasures in the Corporate WorldVoIP: Attacks & Countermeasures in the Corporate World
VoIP: Attacks & Countermeasures in the Corporate WorldJason Edelstein
 
Bone Loss in Long-Duration Spaceflight: Measurements and Countermeasures
Bone Loss in Long-Duration Spaceflight: Measurements and CountermeasuresBone Loss in Long-Duration Spaceflight: Measurements and Countermeasures
Bone Loss in Long-Duration Spaceflight: Measurements and CountermeasuresAmerican Astronautical Society
 
Certified Information Security Professional (CISP)
Certified Information Security Professional (CISP)Certified Information Security Professional (CISP)
Certified Information Security Professional (CISP)vjgarciaq
 
Digital Astroturfing: Definition, typology, and countermeasures.
Digital Astroturfing: Definition, typology, and countermeasures.Digital Astroturfing: Definition, typology, and countermeasures.
Digital Astroturfing: Definition, typology, and countermeasures.Marko Kovic
 
Iis Security Programming Countermeasures
Iis Security Programming CountermeasuresIis Security Programming Countermeasures
Iis Security Programming Countermeasuresguestc27cd9
 
Return oriented programming
Return oriented programmingReturn oriented programming
Return oriented programminghybr1s
 
Designing Countermeasures For Tomorrows Threats
Designing Countermeasures For Tomorrows ThreatsDesigning Countermeasures For Tomorrows Threats
Designing Countermeasures For Tomorrows ThreatsDarwish Ahmad
 
Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"
Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"
Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"Alonso Caballero
 
Google Hacking for Cryptographic Secrets
Google Hacking for Cryptographic SecretsGoogle Hacking for Cryptographic Secrets
Google Hacking for Cryptographic SecretsDr. Emin İslam Tatlı
 
Irregularity Countermeasures in Massively Parallel BigData Processors
Irregularity Countermeasures in Massively Parallel BigData ProcessorsIrregularity Countermeasures in Massively Parallel BigData Processors
Irregularity Countermeasures in Massively Parallel BigData ProcessorsTokyo University of Science
 
Owasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root CausesOwasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root CausesMarco Morana
 
[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...
[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...
[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...CODE BLUE
 
Secure routing in wsn-attacks and countermeasures
Secure routing in  wsn-attacks and countermeasuresSecure routing in  wsn-attacks and countermeasures
Secure routing in wsn-attacks and countermeasuresMuqeed Abdul
 
Web application security: Threats & Countermeasures
Web application security: Threats & CountermeasuresWeb application security: Threats & Countermeasures
Web application security: Threats & CountermeasuresAung Thu Rha Hein
 
Root cause analysis apr 2010
Root cause analysis apr 2010Root cause analysis apr 2010
Root cause analysis apr 2010Michael Sahota
 
Webinar Gratuito: Técnicas Antiforenses Básicas
Webinar Gratuito: Técnicas Antiforenses BásicasWebinar Gratuito: Técnicas Antiforenses Básicas
Webinar Gratuito: Técnicas Antiforenses BásicasAlonso Caballero
 
Java ist doch schon sicher?!
Java ist doch schon sicher?!Java ist doch schon sicher?!
Java ist doch schon sicher?!BridgingIT GmbH
 

Viewers also liked (20)

DDoS Attacks and Countermeasures
DDoS Attacks and CountermeasuresDDoS Attacks and Countermeasures
DDoS Attacks and Countermeasures
 
Seminar Presentation
Seminar PresentationSeminar Presentation
Seminar Presentation
 
VoIP: Attacks & Countermeasures in the Corporate World
VoIP: Attacks & Countermeasures in the Corporate WorldVoIP: Attacks & Countermeasures in the Corporate World
VoIP: Attacks & Countermeasures in the Corporate World
 
Bone Loss in Long-Duration Spaceflight: Measurements and Countermeasures
Bone Loss in Long-Duration Spaceflight: Measurements and CountermeasuresBone Loss in Long-Duration Spaceflight: Measurements and Countermeasures
Bone Loss in Long-Duration Spaceflight: Measurements and Countermeasures
 
Certified Information Security Professional (CISP)
Certified Information Security Professional (CISP)Certified Information Security Professional (CISP)
Certified Information Security Professional (CISP)
 
Digital Astroturfing: Definition, typology, and countermeasures.
Digital Astroturfing: Definition, typology, and countermeasures.Digital Astroturfing: Definition, typology, and countermeasures.
Digital Astroturfing: Definition, typology, and countermeasures.
 
Iis Security Programming Countermeasures
Iis Security Programming CountermeasuresIis Security Programming Countermeasures
Iis Security Programming Countermeasures
 
Return oriented programming
Return oriented programmingReturn oriented programming
Return oriented programming
 
Designing Countermeasures For Tomorrows Threats
Designing Countermeasures For Tomorrows ThreatsDesigning Countermeasures For Tomorrows Threats
Designing Countermeasures For Tomorrows Threats
 
Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"
Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"
Webinar Gratuito: "Herramientas Graficas en Kali Linux 2.0"
 
Google Hacking for Cryptographic Secrets
Google Hacking for Cryptographic SecretsGoogle Hacking for Cryptographic Secrets
Google Hacking for Cryptographic Secrets
 
Irregularity Countermeasures in Massively Parallel BigData Processors
Irregularity Countermeasures in Massively Parallel BigData ProcessorsIrregularity Countermeasures in Massively Parallel BigData Processors
Irregularity Countermeasures in Massively Parallel BigData Processors
 
Owasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root CausesOwasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root Causes
 
[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...
[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...
[CB16] Air-Gap security: State-of-the-art Attacks, Analysis, and Mitigation b...
 
Security Site Surveys and Risk Assessments
Security Site Surveys and Risk AssessmentsSecurity Site Surveys and Risk Assessments
Security Site Surveys and Risk Assessments
 
Secure routing in wsn-attacks and countermeasures
Secure routing in  wsn-attacks and countermeasuresSecure routing in  wsn-attacks and countermeasures
Secure routing in wsn-attacks and countermeasures
 
Web application security: Threats & Countermeasures
Web application security: Threats & CountermeasuresWeb application security: Threats & Countermeasures
Web application security: Threats & Countermeasures
 
Root cause analysis apr 2010
Root cause analysis apr 2010Root cause analysis apr 2010
Root cause analysis apr 2010
 
Webinar Gratuito: Técnicas Antiforenses Básicas
Webinar Gratuito: Técnicas Antiforenses BásicasWebinar Gratuito: Técnicas Antiforenses Básicas
Webinar Gratuito: Técnicas Antiforenses Básicas
 
Java ist doch schon sicher?!
Java ist doch schon sicher?!Java ist doch schon sicher?!
Java ist doch schon sicher?!
 

Similar to Security, Hack1ng and Hardening on Linux - an Overview

In-kernel Analytics and Tracing with eBPF for OpenStack Clouds
In-kernel Analytics and Tracing with eBPF for OpenStack CloudsIn-kernel Analytics and Tracing with eBPF for OpenStack Clouds
In-kernel Analytics and Tracing with eBPF for OpenStack CloudsPLUMgrid
 
Vulnerability Management Nirvana - Seattle Agora - 18Mar16
Vulnerability Management Nirvana - Seattle Agora - 18Mar16Vulnerability Management Nirvana - Seattle Agora - 18Mar16
Vulnerability Management Nirvana - Seattle Agora - 18Mar16Kymberlee Price
 
Open Security - Chad Cravens
Open Security - Chad CravensOpen Security - Chad Cravens
Open Security - Chad CravensIT-oLogy
 
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)Steve Poole
 
SoftwareSecurity.ppt
SoftwareSecurity.pptSoftwareSecurity.ppt
SoftwareSecurity.pptssuserfb92ae
 
Lessons Learned from Porting HelenOS to RISC-V
Lessons Learned from Porting HelenOS to RISC-VLessons Learned from Porting HelenOS to RISC-V
Lessons Learned from Porting HelenOS to RISC-VMartin Děcký
 
Security Content Automation Protocol and Web Application Security
Security Content Automation Protocol and Web Application SecuritySecurity Content Automation Protocol and Web Application Security
Security Content Automation Protocol and Web Application SecurityMichael Smith
 
Securing your web apps before they hurt the organization
Securing your web apps before they hurt the organizationSecuring your web apps before they hurt the organization
Securing your web apps before they hurt the organizationAntonio Fontes
 
SCAP for openSUSE
SCAP for openSUSESCAP for openSUSE
SCAP for openSUSEKazuki Omo
 
Vulnerability Intelligence and Assessment with vulners.com
Vulnerability Intelligence and Assessment with vulners.comVulnerability Intelligence and Assessment with vulners.com
Vulnerability Intelligence and Assessment with vulners.comAlexander Leonov
 
ADVANCED PENETRATION TESTING.pdf
ADVANCED PENETRATION TESTING.pdfADVANCED PENETRATION TESTING.pdf
ADVANCED PENETRATION TESTING.pdfCert Hippo
 
Empowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOpsEmpowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOpsIBM Security
 
Empowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOpsEmpowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOpsBlack Duck by Synopsys
 
2010-12 SCAP Explained
2010-12 SCAP Explained 2010-12 SCAP Explained
2010-12 SCAP Explained Raleigh ISSA
 
Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...
Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...
Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...iotcloudserve_tein
 
OWASP Secure Coding Quick Reference Guide
OWASP Secure Coding Quick Reference GuideOWASP Secure Coding Quick Reference Guide
OWASP Secure Coding Quick Reference GuideAryan G
 
Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...
Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...
Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...Black Duck by Synopsys
 

Similar to Security, Hack1ng and Hardening on Linux - an Overview (20)

Dependency check
Dependency checkDependency check
Dependency check
 
In-kernel Analytics and Tracing with eBPF for OpenStack Clouds
In-kernel Analytics and Tracing with eBPF for OpenStack CloudsIn-kernel Analytics and Tracing with eBPF for OpenStack Clouds
In-kernel Analytics and Tracing with eBPF for OpenStack Clouds
 
Vulnerability Management Nirvana - Seattle Agora - 18Mar16
Vulnerability Management Nirvana - Seattle Agora - 18Mar16Vulnerability Management Nirvana - Seattle Agora - 18Mar16
Vulnerability Management Nirvana - Seattle Agora - 18Mar16
 
Open Security - Chad Cravens
Open Security - Chad CravensOpen Security - Chad Cravens
Open Security - Chad Cravens
 
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
 
SoftwareSecurity.ppt
SoftwareSecurity.pptSoftwareSecurity.ppt
SoftwareSecurity.ppt
 
Lessons Learned from Porting HelenOS to RISC-V
Lessons Learned from Porting HelenOS to RISC-VLessons Learned from Porting HelenOS to RISC-V
Lessons Learned from Porting HelenOS to RISC-V
 
Security Content Automation Protocol and Web Application Security
Security Content Automation Protocol and Web Application SecuritySecurity Content Automation Protocol and Web Application Security
Security Content Automation Protocol and Web Application Security
 
Securing your web apps before they hurt the organization
Securing your web apps before they hurt the organizationSecuring your web apps before they hurt the organization
Securing your web apps before they hurt the organization
 
SCAP for openSUSE
SCAP for openSUSESCAP for openSUSE
SCAP for openSUSE
 
Vulnerability Intelligence and Assessment with vulners.com
Vulnerability Intelligence and Assessment with vulners.comVulnerability Intelligence and Assessment with vulners.com
Vulnerability Intelligence and Assessment with vulners.com
 
ADVANCED PENETRATION TESTING.pdf
ADVANCED PENETRATION TESTING.pdfADVANCED PENETRATION TESTING.pdf
ADVANCED PENETRATION TESTING.pdf
 
Attacking antivirus
Attacking antivirusAttacking antivirus
Attacking antivirus
 
Empowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOpsEmpowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOps
 
Empowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOpsEmpowering Application Security Protection in the World of DevOps
Empowering Application Security Protection in the World of DevOps
 
2010-12 SCAP Explained
2010-12 SCAP Explained 2010-12 SCAP Explained
2010-12 SCAP Explained
 
Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...
Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...
Introduction to DevOps and DevOpsSec with Secure Design by Prof.Krerk (Chulal...
 
Bsides SP 2022 - EPSS - Final.pptx
Bsides SP 2022 - EPSS - Final.pptxBsides SP 2022 - EPSS - Final.pptx
Bsides SP 2022 - EPSS - Final.pptx
 
OWASP Secure Coding Quick Reference Guide
OWASP Secure Coding Quick Reference GuideOWASP Secure Coding Quick Reference Guide
OWASP Secure Coding Quick Reference Guide
 
Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...
Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...
Open Source Insight: SCA for DevOps, DHS Security, Securing Open Source for G...
 

Recently uploaded

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 

Recently uploaded (20)

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 

Security, Hack1ng and Hardening on Linux - an Overview

  • 1. Linux OS : Security and Hardening – An Overview The Linux OS -The Linux OS - Security and Hardening OverviewSecurity and Hardening Overview for Developersfor Developers Focus on Buffer OverflowFocus on Buffer Overflow With a PoC on the ARM ProcessorWith a PoC on the ARM Processor kaiwanTECHkaiwanTECH http://kaiwantech.inhttp://kaiwantech.in
  • 2. Linux OS : Security and Hardening – An Overview Linux OS – Security and Hardening ● Agenda – Basic Terminology – Current State ● Linux kernel vulnerability stats ● “Security Vulnerabilities in Modern OS’s” - a few slides – Tech Preliminary: the process Stack – BOF Vulnerabilities ● What is BOF ● Why is it dangerous? ● [Demo: a PoC on the ARM processor]
  • 3. Linux OS : Security and Hardening – An Overview Linux OS – Security and Hardening ● Agenda (contd.) – Modern OS Hardening Countermeasures ● Using Managed programming languages ● Compiler protection ● Libraries ● Executable space protection ● ASLR ● Better Testing – Conclusion + Q&A
  • 4. Mar 16, 2017 kaiwanTECH 4 Linux OS : Security and Hardening – An Overview Basic Terminology Source - Wikipedia Vulnerability In computer security, a vulnerability is a weakness which allows an attacker to reduce a system's information assurance. Vulnerability is the intersection of three elements: a system susceptibility or flaw, attacker access to the flaw, and attacker capability to exploit the flaw. A software vulnerability is a security flaw, glitch, or weakness found in software or in an operating system (OS) that can lead to security concerns. An example of a software flaw is a buffer overflow.
  • 5. Mar 16, 2017 kaiwanTECH 5 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) Source - Wikipedia Exploit In computing, an exploit is an attack on a computer system, especially one that takes advantage of a particular vulnerability that the system offers to intruders. Used as a verb, the term refers to the act of successfully making such an attack.
  • 6. Mar 16, 2017 kaiwanTECH 6 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) Source: CVEdetails What is an "Exposure"? An information security exposure is a mistake in software that allows access to information or capabilities that can be used by a hacker as a stepping-stone into a system or network.
  • 7. Mar 16, 2017 kaiwanTECH 7 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) ● What is CVE? [Source] – “Common Vulnerabilities and Exposures (CVE®) is a dictionary of common names (i.e., CVE Identifiers) for publicly known cybersecurity vulnerabilities. CVE's common identifiers make it easier to share data across separate network security databases and tools, and provide a baseline for evaluating the coverage of an organization’s security tools. ...” – CVE is ● One name for one vulnerability or exposure ● One standardized description for each vulnerability or exposure ● A dictionary rather than a database ● How disparate databases and tools can "speak" the same language ● The way to interoperability and better security coverage ● A basis for evaluation among tools and databases ● Free for public download and use ● Industry-endorsed via the CVE Numbering Authorities, CVE Board, and CVE-Compatible Products
  • 8. Mar 16, 2017 kaiwanTECH 8 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) What is a CVE Identifier? CVE Identifiers (also called "CVE names," "CVE numbers," CVE-IDs," and "CVEs") are unique, common identifiers for publicly known information security vulnerabilities. Each CVE Identifier includes the following: ● CVE identifier number (i.e., "CVE-1999-0067"). ● Indication of "entry" or "candidate" status. ● Brief description of the security vulnerability or exposure. ● Any pertinent references (i.e., vulnerability reports and advisories or OVAL-ID). ● CVE Identifiers are used by information security product/service vendors and researchers as a standard method for identifying vulnerabilities and for cross-linking with other repositories that also use CVE Identifiers. CVE FAQs Page
  • 9. Mar 16, 2017 kaiwanTECH 9 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) CVE Identifier – Old and New Syntax ● Practically, from Jan 2015
  • 10. Mar 16, 2017 kaiwanTECH 10 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) A CVE Example ● CVE-2014-0160 [aka “Heartbleed”] ● Description: – The (1) TLS and (2) DTLS implementations in OpenSSL 1.0.1 before 1.0.1g do not properly handle Heartbeat Extension packets, which allows remote attackers to obtain sensitive information from process memory via crafted packets that trigger a buffer over-read, as demonstrated by reading private keys, related to d1_both.c and t1_lib.c, aka the Heartbleed bug.
  • 11. Mar 16, 2017 kaiwanTECH 11 Linux OS : Security and Hardening – An Overview
  • 12. Mar 16, 2017 kaiwanTECH 12 Linux OS : Security and Hardening – An Overview Basic Terminology (contd.) Most software security vulnerabilities fall into one of a small set of categories: ● buffer overflows ● unvalidated input ● race conditions ● access-control problems ● weaknesses in authentication, authorization, or cryptographic practices Source
  • 13. Mar 16, 2017 kaiwanTECH 13 Linux OS : Security and Hardening – An Overview CWE - Common Weakness Enumeration - Types of Exploits
  • 14. Mar 16, 2017 kaiwanTECH 14 Linux OS : Security and Hardening – An Overview Linux kernel – Vulnerability Stats Source (CVEdetails) (1999 to date)
  • 15. Mar 16, 2017 kaiwanTECH 15 Linux OS : Security and Hardening – An Overview Linux kernel – Vulnerability Stats Source (CVEdetails) (1999 to date)
  • 16. Mar 16, 2017 kaiwanTECH 16 Linux OS : Security and Hardening – An Overview Security Vulnerabilities in Modern Operating Systems By Cisco, Canada, April 2014. All rights with Cisco. “The Common Exposures and Vulnerabilities database has over 25 years of data on vulnerabilities in it. In this deck we dig through that database and use it to map out trends and general information on vulnerabilities in software in the last quarter century. For more information please visit our website: http://www.cisco.com/web/CA/index.html ” Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 17. Mar 16, 2017 kaiwanTECH 17 Linux OS : Security and Hardening – An Overview OS Security Vulnerabilities Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 18. Mar 16, 2017 kaiwanTECH 18 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 19. Mar 16, 2017 kaiwanTECH 19 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 20. Mar 16, 2017 kaiwanTECH 20 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 21. Mar 16, 2017 kaiwanTECH 21 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 22. Mar 16, 2017 kaiwanTECH 22 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 23. Mar 16, 2017 kaiwanTECH 23 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 24. Mar 16, 2017 kaiwanTECH 24 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 25. Mar 16, 2017 kaiwanTECH 25 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 26. Mar 16, 2017 kaiwanTECH 26 Linux OS : Security and Hardening – An Overview Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014
  • 27. Mar 16, 2017 kaiwanTECH 27 Linux OS : Security and Hardening – An Overview OS Security Vulnerabilities Source: Security Vulnerabilities in Modern Operating Systems, Cisco, Apr 2014 END “Security Vulnerabilities in Modern Operating Systems” CISCO Presentation Slides
  • 28. Mar 16, 2017 kaiwanTECH 28 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) What exactly is a buffer overflow (BOF)? ● Prerequisite – an understanding of the process stack! ● Lets write some simple ‘C’ code to understand this first-hand. ● [An Aside: As we shall soon see, nowadays several mitigations/hardening technologies exist to help prevent BOF attacks. So, sometimes the question (SO InfoSec) arises: “ Should I bother teaching buffer overflows any more?”: Short answer, “YES”: “… Yes. Apart from the systems where buffer overflows lead to successful exploits, full explanations on buffer overflows are always a great way to demonstrate how you should think about security. Instead on concentrating on how the application should run, see what can be done in order to make the application derail. Also, regardless of stack execution and how many screaming canaries you install, a buffer overflow is a bug. All those security features simply alter the consequences of the bug: instead of a remote shell, you "just" get an immediate application crash. Not caring about application crashes (in particular crashes which can be triggered remotely) is, at best, very sloppy programming. ...” Preliminaries – the STACK
  • 29. Mar 16, 2017 kaiwanTECH 29 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The Classic Case Lets imagine that here is part of the (drastically simplified) Requirement Spec for a console-based app: ● Write a function ‘foo()’ that accepts the user’s name, email id and employee number Preliminaries – the STACK
  • 30. Mar 16, 2017 kaiwanTECH 30 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The Classic Case – function foo() implemented below by app developer in ‘C’: [...] static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } Preliminaries – the STACK
  • 31. Mar 16, 2017 kaiwanTECH 31 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● Why have a “stack” at all ? – Humans write code using a 3rd or 4th generation high-level language (well, most of us anyway :-) – The processor hardware does not ‘get’ what a function is, what parameters and return values are! Preliminaries – the STACK
  • 32. Mar 16, 2017 kaiwanTECH 32 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The Classic Case – function foo() implemented below by app developer in ‘C’: [...] static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } A local buffer, hence allocated on the process stack Preliminaries – the STACK
  • 33. Mar 16, 2017 kaiwanTECH 33 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● So, what really, is this process stack ? – it’s just memory treated with special semantics – Uses a “PUSH / POP” model – “Grows” towards lower (virtual) addresses; called a “downward-growing stack” ● this attribute is processor-specific; it’s the case for most modern CPUs, including x86, x86_64, ARM and ARM64) Preliminaries – the STACK
  • 34. Mar 16, 2017 kaiwanTECH 34 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● Why have a “stack” at all ? – The saviour: the compiler generates assembly code which enables the function-calling-and- return mechanism – By making use of the stack! ● How exactly? … Aha ... Preliminaries – the STACK
  • 35. Mar 16, 2017 kaiwanTECH 35 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● The Stack – When a program calls a function, the compiler generates code to setup a call stack, which consists of individual stack frames – A stack frame can be visualized as a “block” containing all the metadata necessary for the system to process the “function” call and return ● Access it’s parameters, if any ● Allocate it’s local variables ● Execute it’s code (text) ● Return a value as required Preliminaries – the STACK
  • 36. Mar 16, 2017 kaiwanTECH 36 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● The Stack Frame – Hence, the stack frame will require a means to – Locate the previous (caller’s) stack frame (achieved via the SFP – Stack Frame Pointer) – Gain access to the function’s parameters – Store the address to which control must continue, IOW, the RETurn address – Allocate storage for the function’s local variables – Turns out that the exact stack frame layout is very processor-dependant (depends on it’s ABI, calling conventions) Preliminaries – the STACK
  • 37. Mar 16, 2017 kaiwanTECH 37 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● Recall our simple ‘C’ code: static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } Preliminaries – the STACK
  • 38. Mar 16, 2017 kaiwanTECH 38 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● Have it called from main() static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } Preliminaries – the STACK
  • 39. Mar 16, 2017 kaiwanTECH 39 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● When main() calls foo(), a stack frame is setup (as part of the call stack) static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } Preliminaries – the STACK
  • 40. Mar 16, 2017 kaiwanTECH 40 Linux OS : Security and Hardening – An Overview Call StackCall Stack .. .. .. Call StackCall Stack .. .. .. Buffer Overflow (BOF) ● When main() calls foo(), a stack frame is setup (as part of the call stack) static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } *va = virtual addresses Stack Frame for main() Stack Frame for main() Stack Frame for foo() Stack Frame for foo() Preliminaries – the STACK SP (top of the stack) Lowest address Increasing va*
  • 41. Mar 16, 2017 kaiwanTECH 41 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● When main() calls foo(), a stack frame is setup (as part of the call stack) static void foo(void) { char local[12]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } *va = virtual addresses Call Stack . . . Call Stack . . . Stack Frame for main() Stack Frame for main() Stack Frame for foo() Stack Frame for foo() Preliminaries – the STACK SP (top of the stack) Lowest address Increasing va*
  • 42. Mar 16, 2017 kaiwanTECH 42 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● When main() calls foo(), a stack frame is setup (as part of the call stack) static void foo(void) { char local[12]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } *va = virtual addresses Call Stack . . . Call Stack . . . Stack Frame for main() Stack Frame for main() Stack Frame for foo() Stack Frame for foo() … Parameters ... RET Address SFP … Local variables ... … Parameters ... RET Address SFP … Local variables ... SFP = Saved Frame Pointer Preliminaries – the STACK Increasing va* SP (top of the stack) Lowest address
  • 43. Mar 16, 2017 kaiwanTECH 43 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Wikipedia on BOF In computer security and programming, a buffer overflow, or buffer overrun, is an anomaly where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent memory locations.
  • 44. Mar 16, 2017 kaiwanTECH 44 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Recall: static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } A Simple BOF
  • 45. Mar 16, 2017 kaiwanTECH 45 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) At runtime static void foo(void) { char local[128]; printf(“Name: ”); gets(local); [...] } void main() { foo(); } A Simple BOF params -none- RET addr SFP = main’s stack frame … Local variables … 128 bytes <empty> foo() ‘s stack frame 4128bytes4 main() ‘s stack frame Increasing va* SP (top of the stack) Lowest address
  • 46. Mar 16, 2017 kaiwanTECH 46 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Lets give it a spin- $ gcc getdata.c -o getdata [...] $ $ printf "AAAABBBBCCCCDDDD" |./getdata Name: Ok, about to exit... $ A Simple BOF
  • 47. Mar 16, 2017 kaiwanTECH 47 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Okay, step by step: Step 1 of 4 : Prepare to execute; main() is called $ gcc getdata.c -o getdata [...] $ $ printf "AAAABBBBCCCCDDDD" | ./getdata A Simple BOF main() ‘s stack frame params -none- RET addr SFP = main’s stack frame … Local variables … 128 bytes <empty> 4128bytes4 SP (top of the stack) Lowest address Increasing va*
  • 48. Mar 16, 2017 kaiwanTECH 48 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Okay, step by step: Step 2 of 4 : Input 16 characters into the local buffer via the gets(); $ gcc getdata.c -o getdata [...] $ A Simple BOF main() ‘s stack frame foo() ‘s stack frame params -none- RET addr SFP = main’s stack frame … Local variables … 128 bytes 0x43434343 0x44444444 0x41414141 0x42424242 Increasing va* SP (top of the stack) 4128bytes4$ printf "AAAABBBBCCCCDDDD" |./getdata 16 chars written into the stack @ var ‘local’ All okay!All okay!All okay!All okay! ‘local’ 128 bytes <empty>
  • 49. Mar 16, 2017 kaiwanTECH 49 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Okay, step by step: Step 3 of 4 : Input 128+4+4 = 136 characters into the local buffer via the gets(); thus Overflowing it! $ gcc getdata.c -o getdata [...] $ $ printf "AAAABBBBCCCCDDDD" AAAABBBBCCCCDDDD$ A Simple BOF – Action! 0x41414141 0x41414141 [...] 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 main() ‘s stack frame foo() ‘s stack frame params -none- RET addr SFP SP (top of the stack) 4128bytes4perl -e 'print "A"x136' |./getdata ‘local’ 128 bytes <empty> 136 chars written into the stack @ var ‘local’ Increasing va*
  • 50. Mar 16, 2017 kaiwanTECH 50 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Okay, step by step: Step 4 of 4 : Input 128+4+4 = 136 characters into the local buffer via the gets(); thus Overflowing it! $ gcc getdata.c -o getdata [...] $ $ printf "AAAABBBBCCCCDDDD" AAAABBBBCCCCDDDD$ A Simple BOF – Action! params -none- RET addr = 0x41414141 SFP = 0x41414141 0x41414141 0x41414141 [...] 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 0x41414141 136 chars (ASCII ‘A’ = 0x41) written into the var ‘local’ 4128bytes4 main() ‘s stack frame foo() ‘s stack frame SP (top of the stack) Why? As the processor tries to return to the designated RET address, it attempts to access and execute code at virtual address 0x41414141 that isn’t really there or is illegal perl -e 'print "A"x136' |./getdata Segmentation fault $ It segfaults !It segfaults ! Increasing va* OVERWRITESOVERWRITES
  • 51. Mar 16, 2017 kaiwanTECH 51 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) A physical buffer overflow: The Montparnasse derailment of 1895 Source: “Secure Programming HOWTO”, David Wheeler A Simple BOF / Dangerous?
  • 52. Mar 16, 2017 kaiwanTECH 52 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Okay, it crashed. So what? … you say No danger, just a bug to be fixed... A Simple BOF / Dangerous?
  • 53. Mar 16, 2017 kaiwanTECH 53 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Okay, it crashed. So what? … you say … No danger, just a bug to be fixed… It IS DANGEROUS !!! Why?? A Simple BOF / Dangerous?
  • 54. Mar 16, 2017 kaiwanTECH 54 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Recall why the app crashed (segfault-ed): – The RETURN address was set to an incorrect/bogus/junk value (0x41414141) ● Instead of just crashing the app, a hacker will craft the RET address to a deliberate value – code that (s)he wants executed! ● How exactly? A Simple BOF / Dangerous?
  • 55. Mar 16, 2017 kaiwanTECH 55 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Instead of running the app like this: $ perl -e 'print "A"x136' | ./getdata which would cause it to just segfault, how about this: $ perl -e 'print "A"x132 . "x49x8fx04x78"' | ./getdata A Simple BOF / Dangerous?
  • 56. Mar 16, 2017 kaiwanTECH 56 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload, or ‘crafted buffer’ is: payload = 128 A’s + <SFP value> + <RET addr> = AAAAA...AAAA + AAAA + 0x498f0478 ● As seen, given a local buffer of 128 bytes, the overflow spills into the higher addresses of the stack ● In this case, the overflow is 4+4 bytes ● Which overwrites the – SFP (Saved Frame Pointer – essentially pointer to prev stack frame), and the – RETurn address, on the process stack ● … thus causing control to be re-vectored to the RET address! ● We thus have Arbitrary Code Execution (which could result in privilege escalation, a backdoor, etc)! A Simple BOF / Dangerous?
  • 57. Mar 16, 2017 kaiwanTECH 57 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be used to deploy an attack in many forms: ● Direct code execution: executable machine code “injected” onto the stack, with the RET address arranged such that it points to this code ● Indirect code execution: – To internal program function(s) – To external library function(s) A Simple BOF / Dangerous?
  • 58. Mar 16, 2017 kaiwanTECH 58 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be deployed in many forms: ● Direct executable machine code “injected” onto the stack, with the RET address arranged such that it points to this code – What code? – Typically, a variation of the machine language for: seteuid(0); execl(“/bin/sh”, “sh”, 0); A Simple BOF / Dangerous?
  • 59. Mar 16, 2017 kaiwanTECH 59 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be deployed in many forms: seteuid(0); execve(“/bin/sh”, argv, 0); ● Collection of shellcode! http://shell-storm.org/shellcode/ – Eg. 1 : setuid(0); execve(/bin/sh,0) http://shell-storm.org/shellcode/files/shellcode-472.php ● Or, use the Google Hacking DB (GHDB), or ● Explot-DB (Offensive Security) A Simple BOF / Dangerous?
  • 60. Mar 16, 2017 kaiwanTECH 60 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be deployed in many forms: – Eg. 2 : adds a root user no-passwd to /etc/passwd (84 bytes) char shellcode[]= "x31xc0x31xdbx31xc9x53x68x73x73x77" "x64x68x63x2fx70x61x68x2fx2fx65x74" "x89xe3x66xb9x01x04xb0x05xcdx80x89" "xc3x31xc0x31xd2x68x6ex2fx73x68x68" "x2fx2fx62x69x68x3ax3ax2fx3ax68x3a" "x30x3ax30x68x62x6fx62x3ax89xe1xb2" "x14xb0x04xcdx80x31xc0xb0x06xcdx80" "x31xc0xb0x01xcdx80"; A Simple BOF / Dangerous?
  • 61. Mar 16, 2017 kaiwanTECH 61 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be deployed in many forms: ● Indirect code execution: – To internal program function(s) – To external program function(s) ● Re-vector (forcibly change) the RET address such that control is vectored to an - typically unexpected, out of the “normal” flow of control - internal program function << (Time permitting :-) Demo of a BOF PoC on ARM Linux, showing precisely this >> A Simple BOF / Dangerous?
  • 62. Mar 16, 2017 kaiwanTECH 62 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be deployed in many forms: ● Indirect code execution: – To internal program function(s) – To external library function(s) ● Revector (forcibly change) the RET address such control is vectored to an - typically unexpected, out of the “normal” flow of control - external library function A Simple BOF / Dangerous?
  • 63. Mar 16, 2017 kaiwanTECH 63 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) The payload or ‘crafted buffer’ can be deployed in many forms: ● Re-vector (forcibly change) the RET address such that control is vectored to an - typically unexpected, out of the “normal” flow of control - external library function ● What if we re-vector control to a Std C Library (glibc) function: – Perhaps to, say, system(char *cmd); – Can setup the parameter (pointer to a command string) on the stack – !!! Just think of the possibilities !!! - in effect, one can execute anything – that’s pretty much exactly what the Ret2Libc hack / exploit is. – A Simple BOF / Dangerous?
  • 64. Mar 16, 2017 kaiwanTECH 64 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) ● MUST-SEE! Real Life Examples - gathers a few actual attacks of different kinds- phishing, password, crypto, input, BOFs, etc ● A few ‘famous’ (public) Buffer Overflow (BOF) Exploits – 02 Nov 1988: Morris Worm – first network ‘worm’; exploits a BoF in fingerd (and DEBUG cmd in sendmail). Article and Details – 15 July 2001: Code Red and Code Red II ; CVE-2001-0500 – 07 Apr 2014: Heartbleed ; CVE-2014-0160 ● The Risks Digest BoF + Other Attacks in the Real-World
  • 65. Mar 16, 2017 kaiwanTECH 65 Linux OS : Security and Hardening – An Overview Buffer Overflow (BOF) Interesting! ● Mar 2017: Hard Drive LED Allows Data Theft From Air-Gapped PCs ● Gaming console hacks – due to BOF exploits – Jan 2003: Hacker breaks Xbox protection without mod-chip – PlayStation 2 Homebrew – Wii Twilight hack ● 10 of the worst moments in network security history BoF + Other Attacks in the Real-World
  • 66. Mar 16, 2017 kaiwanTECH 66 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures ● A modern OS, like Linux, will / should implement a number of countermeasures or “hardening” techniques against vulnerabilities, and hence, potential exploits ● Reduces the attack surface ● Common Hardening Countermeasures include- ● Using Managed programming languages ● Compiler protection ● Library protection ● Executable space protection ● [K]ASLR ● Better Testing
  • 67. Mar 16, 2017 kaiwanTECH 67 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Using Managed programming languages ● Programming in C/C++ is widespread and popular ● Pros- powerful, ‘close to the metal’, fast ● Cons- – Programmer handles memory – Cause of many (most) memory bugs – Which lead to insecure exploitable software ● A ‘managed’ language uses a framework (eg .NET) and/or a virtual machine construct ● Using a ‘managed’ language (Java, C#) greatly alleviates the burden of memory management from the programmer to the ‘runtime’ ● Reality – – Many languages are implemented in C/C++ – Real projects are usually a mix of managed and unmanaged code (eg. Android: Java @app layer + C/C++/JNI/DalvikVM @middleware + C/Assembly @kernel/drivers layers) ● [Aside: ‘C’ outdated? See the TIOBE Index for Programming languages]
  • 68. Mar 16, 2017 kaiwanTECH 68 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Compiler-level Protection ● Stack BOF Protection – Early implementations include ● StackGuard (1997) ● ProPolice (IBM, 2001) – GCC patches for stack-smashing protection – GCC ● -fstack-protector flag (RedHat, 2005), and ● -fstack-protector-all flag ● -fstack-protector-strong flag (Google, 2012); gcc 4.9 onwards ● Early in Android (1.5 onwards) – all Android binaries include this flag
  • 69. Mar 16, 2017 kaiwanTECH 69 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Compiler-level Protection ● From Wikipedia: “All Fedora packages are compiled with -fstack-protector since Fedora Core 5, and -fstack- protector-strong since Fedora 20.[19]cite_ref-20cite_ref-20[20] Most packages in Ubuntu are compiled with -fstack-protector since 6.10.[21] Every Arch Linux package is compiled with -fstack-protector since 2011.[22] All Arch Linux packages built since 4 May 2014 use -fstack-protector-strong.[23] Stack protection is only used for some packages in Debian,[24] and only for the FreeBSD base system since 8.0.[25] ...” ● How is the ‘-fstack-protector<-xxx>’ flag protection actually achieved? – Typical stack frame layout: [… local vars …] [CTLI] [RET addr] ; where [CTLI] is control information (like the SFP) – A random value, called a “canary”, is placed by the compiler in the stack metadata, typically between the local variables and the RET address – [… local vars …] [canary] [CTLI] [RET addr]
  • 70. Mar 16, 2017 kaiwanTECH 70 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Compiler-level Protection ● How is the ‘-fstack-protector<-xxx>’ flag protection actually achieved? [contd.] – Before a function returns, the canary is checked (by instructions inserted by the compiler into the function epilogue) [… local vars …] [canary] [CTLI] [RET addr] – If the canary has changed, it’s determined that an attack is underway (it might be an unintentional bug too), and the process is aborted (if it occurs in kernel-space, the Linux kernel panics!) – The overhead is considered minimal – [Exercise: try a BOF program. (Re)compile it with -fstack-protector gcc flag and retry (remember, requires >= gcc-4.9)]
  • 71. Mar 16, 2017 kaiwanTECH 71 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Compiler-level Protection ● (Some) mitigation against a format-string attack: – Use the GCC flags -Wformat-security -Werror=format-security – Android ● Oct 2008- disables use of “%n” format specifier ● 2.3 (Gingerbread) onwards uses the -Wformat-security and the -Werror=format- security GCC flags for all binaries ● Using GCC _FORTIFY_SOURCE – Lightweight protection against BOF in typical libc functions – Wrappers around the following ‘typically dangerous’ functions: ● memcpy, mempcpy, memmove, memset, strcpy, stpcpy, strncpy, strcat, strncat, sprintf, vsprintf, snprintf, vsnprintf, gets – Must be used in conjunction with optimization directive: -On -D_FORTIFY_SOURCE=n ; (n>=1) – Eg. gcc prog.c -O2 -D_FORTIFY_SOURCE=2 -o prog -Wall <...> – More details available here.
  • 72. Mar 16, 2017 kaiwanTECH 72 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Compiler-level Protection ● (Full) Relro – Read-Only Relocation – Marks the linker Global Offset Table (GOT) as RO – Achieved by compiling with the linker options: -Wl,-z,now – Android v4.4.1 onwards ● Address Sanitizer (ASan) – ASan: “a programming tool that detects memory corruption bugs such as buffer overflows or accesses to a dangling pointer (use-after-free). AddressSanitizer is based on compiler instrumentation and directly-mapped shadow memory. AddressSanitizer is currently implemented in Clang (starting from version 3.1[1]) and GCC (starting from version 4.8[2]). On average, the instrumentation increases processing time by about 73% and memory usage by 340%.[3]” – “Address sanitizer is nothing short of amazing; it does an excellent job at detecting nearly all buffer over-reads and over-writes (for global, stack, or heap values), use-after-free, and double-free. It can also detect use-after-return and memory leaks” Source – Usage: just compile with the GCC flag: -fsanitize=address ● [SO] What is the most hardened set of options for GCC compiling
  • 73. Mar 16, 2017 kaiwanTECH 73 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Libraries ● BOF exploits – how does one attack? ● By studying real running apps, looking for a weakness to exploit (enumeration) – f.e. the infamous libc gets() (and similar) function(s) in [g]libc! ● It’s mostly by exploiting these common memory bugs that an exploit can be crafted and executed ● Thus, it’s Really Important that developers re-learn: we Must Avoid using std lib functions which are not bounds-checked – gets, sprintf, strcpy, scanf, etc – Replaced with fgets, snprintf, strncpy, etc
  • 74. Mar 16, 2017 kaiwanTECH 74 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Libraries ● Best to make use of “safe” libraries, especially for string handling ● Obviously, a major goal is to prevent security vulnerabilities ● Examples include – The Better String Library – Safe C Library – Simple Dynamic String library – Libsafe – Also see: Ch 6 “Library Solutions in C/C++Library Solutions in C/C++”, Secure Programming for UNIX and ● Source - Cisco Application Developer Security Guide “… In recent years, web-based vulnerabilities have surpassed traditional buffer overflow attacks both in terms of absolute numbers as well as the rate of growth. The most common forms of web-based attacks, such as cross-site scripting (XSS) and SQL injection, can be mitigated with proper input validation. Cisco strongly recommends that you incorporate the Enterprise Security API (ESAPI) Toolkit from the Open Web Application Security Project (OWASP) for input validation of web-based applications. ESAPI comes with a set of well-defined security API, along with ready-to-deploy reference implementations.”
  • 75. Mar 16, 2017 kaiwanTECH 75 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Executable Space Protection ● The most common attack vector – Inject shellcode onto the stack (or heap), typically via a BOF vuln – Arrange to have the shellcode execute, thus gaining privilege (or a backdoor) ● Modern processors have the ability to ‘mark’ a page with an NX (No eXecute) bit – So if we ensure that all pages of data regions like the stack, heap, BSS, etc are marked as NX, then the shellcode holds no danger! – The typical BOF (‘stack smashing’) attack relies on memory being readable, writeable and executeable (rwx) ● MS calls it DEP (Data Execution Prevention)
  • 76. Mar 16, 2017 kaiwanTECH 76 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Executable Space Protection ● Linux kernel – Supports the NX bit from v2.6.8 onwards – On processors that have the hardware capability ● Includes x86, x86_64 and x86_64 running in 32-bit mode ● x86_32 requires PAE to support NX ● (However) For CPUs that do not natively support NX, 32-bit Linux has software that emulates the NX bit, thus protecting non-executable pages ● Check for NX hardware support (on Linux): grep -w nx -q /proc/cpuinfo && echo "Yes" || echo "Nope" ● A commit by Kees Cook (v2.6.38) ensures that even if NX support is turned off in the BIOS, that is ignored by the OS and protection remains
  • 77. Mar 16, 2017 kaiwanTECH 77 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Executable Space Protection ● Ref: https://en.wikipedia.org/wiki/NX_bit ● (More on) Processors supporting the NX bit – Intel markets it as XD (eXecute Disable) – AMD as ‘EVP’ - Enhanced Virus Protection – ARM as XN – eXecute Never – Android: As of Android 2.3 and later, architectures which support it have non-executable pages by default, including non-executable stack and heap.[1][2][3] ● ARMv6 onwards (new PTE format with XN bit) ● PowerPC ● Itanium, Alpha, SunSparc, etc too support it
  • 78. Mar 16, 2017 kaiwanTECH 78 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures ASLR – Address Space Layout Randomization ● NX (or DEP) protects a system by not allowing arbitrary code execution on non-text pages (stack/heap/data/BSS/etc) ● But it cannot protect against attacks that invoke legal code – like [g]libc functions, system calls (as they’re in a valid text segment and are thus marked as r-x in their resp PTE entries) ● In fact, this is the attack vector for what is commonly called Ret2Libc and ROP- style attacks ● How can these be prevented? – ASLR : by randomizing the layout of the process VAS (virtual address space), an attacker cannot know (or guess) in advance the location (virtual address) of glibc code, system call code, etc – Hence, launching this attack inherently fails
  • 79. Mar 16, 2017 kaiwanTECH 79 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures ASLR – Address Space Layout Randomization ● Note though: – (K)ASLR is a statistical protection not an absolute one; it just adds an additional layer of difficulty (depending on the # random bits available) for an attacker, but does not inherently prevent attacks in any way – Also, even with full ASLR support, a particular process may not have it’s VAS randomized – Why? Because this requires compile-time support - within the binary executable too: the binary must be built as a Position independent Executable (PIE) ● Process ASLR – turned On by compiling source with the -fPIE and -pie gcc flags ● Information leakage (for eg. a known kernel pointer value) can completely comprise the ASLR schema (example).
  • 80. Mar 16, 2017 kaiwanTECH 80 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Better Testing ● Of course, most Q&A teams (as well as conscientious developers) will devise, implement and run an impressive array of test cases for the given product or project ● However, it’s usually the case that most of these fall into the positive test-cases bracket (checks that the test yields the desired outcome) ● This approach will typically fail to find bugs and vulnerabilities that an attacker probes for – We have to adopt an “attacker” mindset (“set a thief to catch a thief”) – We need to develop an impressive array of thorough negative test- cases (which check whether the program-under-test fails correctly and gracefully)
  • 81. Mar 16, 2017 kaiwanTECH 81 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Better Testing ● A typical example: the user is to pass a simple integer value: – Have test cases been written to check that it’s within designated bounds? – Both positive and negative (integer overflow – IOF - bugs are heavily exploited! ; see SO: How is integer overflow exploitable?) ● From OWASP: “Arithmetic operations cause a number to either grow too large to be represented in the number of bits allocated to it, or too small. This could cause a positive number to become negative or a negative number to become positive, resulting in unexpected/dangerous behavior.”
  • 82. Mar 16, 2017 kaiwanTECH 82 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Better Testing ● Food for thought ptr = calloc(var_a*var_b, sizeof(int)); ● What if it overflows?? – Did you write a validity check for the parameter to calloc? – Old libc bug- an IOF could result in a much smaller buffer being allocated via calloc() ! ● Static analysis could / should catch a bug like this ● Dynamic analysis - take Valgrind’s MemCheck tool (of course, Valgrind will only work on dynamic memory, not compile-time memory)
  • 83. Mar 16, 2017 kaiwanTECH 83 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Better Testing ● IOF – Google wrote a safe_iop (integer operations) library for Android (from first rel) – However, as of Android 4.2.2, it appears to be used in a very limited fashion and is out-of-date too ● Fuzzing – “Fuzz testing or fuzzing is a software testing technique used to discover coding errors and security loopholes in software, operating systems or networks by inputting massive amounts of random data, called fuzz, to the system in an attempt to make it crash.” Source
  • 84. Mar 16, 2017 kaiwanTECH 84 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Better Testing ● Mostly-positive testing is practically useless for secure software ● Thorough Negative Testing is a MUST ● Fuzzing – especially effective in finding security-related bugs – Bugs that cause a program to crash (in the normal case)
  • 85. Mar 16, 2017 kaiwanTECH 85 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures ● Experience shows that having several hardening techniques in place is far superior to having just 1 or 2 ● Depth-of-Defense is critical ● For example, take ASLR and NX (or XN): – Only NX, no ASLR: security bypassed via ROP-based attacks – Only ASLR, no NX: security bypassed via code injection techniques like heap spraying – Both full ASLR and NX: difficult to bypass by an attacker
  • 86. Mar 16, 2017 kaiwanTECH 86 Linux OS : Security and Hardening – An Overview Modern OS Hardening Countermeasures Linux kernel – security patches into mainline – Not so simple; the proverbial “tip of the iceberg” – As far as security and hardening is concerned, projects like GRSecurity, PaX and OpenWall have shown what can be regarded as the “right” way forward – However, the reality is that there continues to be serious resistance from the kernel community to merging in similar patchsets – [Why? Some legitimate- ● Info hiding - many apps / debuggers rely on pointers, information from /proc, /sysfs, etc ● Debugging – breakpoints into code - don’t work with NX on ● Boot issues on some processors when NX used (being solved now)] ● More info available: Making attacks a little harder, LWN, Nov 2010
  • 87. Mar 16, 2017 kaiwanTECH 87 Linux OS : Security and Hardening – An Overview Conclusion Basic principle of attack First, a program with an exploitable vulnerability – local or remote - must be found. This process is called Reconnaissance / footprinting / enumeration. (Dynamic approach- attackers will often ‘fuzz’ a program to determine how it behaves; static- use tools to disassemble/decompile (objdump,strings,IDA Pro,etc) the program and search for vulnerable patterns. Use vuln scanners). [Quick Tip: Check out nmap, Exploit-DB, the GHDB (Google Hacking Database) and the Metasploit pen(etration)-testing framework]. A string containing shellcode is passed as input to the vulnerable program. It overflows a buffer (a BOF), causing the shellcode to be executed (arbitrary code execution). The shellcode provides some means of access (a backdoor, or simply a direct shell) to the target system for the attacker. Stealth- the target system should be unaware it’s been attacked (log cleaning, hiding).
  • 88. Mar 16, 2017 kaiwanTECH 88 Linux OS : Security and Hardening – An Overview Conclusion ADVANCED- Defeat protections? ● ROP (Return Oriented Programming) ● Defeats ASLR, NX – Not completely; modern Linux PIE executables and library PIC code ● Uses “gadgets” to alter and control PC execution flow ● A gadget is an existing piece of machine code that is leveraged to piece together a sequence of statements – it’s a non-linear programming technique! – Each gadget ends with a : ● X86: ‘ret’ ● RISC (ARM): pop {rX, …, pc} ● Sophisticated, harder to pull off ● But do-able! … Questions?
  • 89. Linux OS : Security and Hardening – An Overview Thank You! kaiwanTECHkaiwanTECH http://kaiwantech.inhttp://kaiwantech.in