The Anatomy of a Vulnerability
Let's talk about vulnz :)
Ron Bowes (@iagox86)
Sharkfest 2015
Who am I?
As always, my views are my own and don't represent my company
What we're gonna talk about
Today's goal
What the heck is a vulnerability anyways?
This is a vulnerability
A vulnerability is...
How to recognize a vulnerability
A little more formally...
The "STRIDE" acronym/initialism:
We care because...
We (as an industry) care because...
Plus, it's just plain bad for people
Let's look at some real bugs!
Off-by-one bug
Off-by-one bug
Computer's memory
int func()
{
char str1[] = "this is string";
char str2[] = "this is moar string";
}
| 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0x8 | 0x9 | 0xA | 0xB | 0xC | 0xD | 0xE | 0xF |
0x00 | t | h | i | s | | i | s | | s | t | r | i | n | g | \0 | t |
0x10 | h | i | s | | i | s | | m | o | a | r | | s | t | r | i |
0x20 | n | g | \0 | ... | | | | | | | | | | | | |
Computer's memory
int func()
{
...
str1[10] = "!"
}
| 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0x8 | 0x9 | 0xA | 0xB | 0xC | 0xD | 0xE | 0xF |
0x00 | t | h | i | s | | i | s | | s | t | ! | i | n | g | \0 | t |
0x10 | h | i | s | | i | s | | m | o | a | r | | s | t | r | i |
0x20 | n | g | \0 | ... | | | | | | | | | | | | |
Computer's memory
int func()
{
...
str1[15] = "?"
}
| 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0x8 | 0x9 | 0xA | 0xB | 0xC | 0xD | 0xE | 0xF |
0x00 | t | h | i | s | | i | s | | s | t | ! | i | n | g | \0 | ? |
0x10 | h | i | s | | i | s | | m | o | a | r | | s | t | r | i |
0x20 | n | g | \0 | ... | | | | | | | | | | | | |
So what?
Vulnerable authentication function
int authenticate()
{
char password[8];
int socket = connect(authentication_server)
read(password, 9);
validate_authentication(socket, buffer);
}
Reading one byte too many
The result
password => "123456789"
| 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0x8 | 0x9 | 0xA | 0xB | 0xC | 0xD | 0xE | 0xF |
0x00 | p | a | s | s | w | o | r | d | S | S | S | S | | | | |
0x10 | | | | | | | | | | | | | | | | |
| 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0x8 | 0x9 | 0xA | 0xB | 0xC | 0xD | 0xE | 0xF |
0x00 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | S | S | S | | | | |
0x10 | | | | | | | | | | | | | | | | |
Overwrote part of socket!
The exploit
Here's the real exploit we used:
# Overwrite the socket with "0"� sys.stdout.write("XXXXXXXX\0")� sys.stdout.flush()�� # Wait for the service to try reading the data� time.sleep(2)�� # The server thinks it's reading the auth data,� # but it's actually reading this:� sys.stdout.write("\x6d\x2b\x59\x55")� sys.stdout.flush()
dnsmasq
What is dnsmasq?
DNS protocol
DNS protocol
[header]
Question 1: skullsecurity.org (type = ANY)
Answer 1: skullsecurity.org is at 206.220.196.59
Answer 2: skullsecurity.org's mail is handled by ASPMX2.GOOGLEMAIL.COM
Answer 3: skullsecurity.org has a TXT record "oh hai NSA"
Solution: pointers
Question 1: skullsecurity.org
Answer 1: [see q1] is at 206.220.196.59
Answer 2: [see q1]'s mail is handled by ASPMX2.GOOGLEMAIL.COM
Answer 3: [see q1] has a TXT record "oh hai NSA"
The problem…
Pointers to the rescue!
Question 1: evildomain.com
Answer 1: aaaa.[see A1]
Consequence?
Lesson
XSS in Red Hat Satellite Server
Let's talk Javascript for a sec
Same origin policy
Cross-site scripting
The problem…
XSS Example
<?php print "<h1>Welcome back, $username!</h1>"; ?>�
example.org/vulnpage?username=<script>...</script>
<h1>Welcome back, <script>...</script>!</h1>
Short break
Red Hat Satellite Server
The vulnerability
Vendor's response?
Ignoring researchers… what could go�wrong?
Seriously… if people are doing free work for you, listen to them and respect them!
Pass the hash
Let's talk about hashing first...
In other words...
Given a potato:
It's trivial to create hashbrowns:
In other words...
But given hashbrowns:
It's computationally difficult to build the potato:
?????
Password hashes...
Password hashes…
Problem…
(This is a gross oversimplification of how SMB works)
Advantages
Disadvantages
Result
DNSCat
DNS is cool
A full command and control tunnel
The result is obvious
Arbitrary data off any network?
Best backdoor ever!
So what?
dnscat2
Finding / killing bugs
Auditing code
The "dangerous" parts
Fuzzing
Fuzzer types
Common fuzzer tactics
The downside to fuzzers
Bug bounties
Education
Systemic protections
Most of all: be pro-active
Conclusion
Vulnerabilities are hard
Contact
Ron Bowes
(I posted the slides to Twitter)