41
Exploring CVE-2015-7547, a Skeleton key in DNS Jaime Cochran, Marek Vavrusa

in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Exploring CVE-2015-7547, a Skeleton key in DNS

Jaime Cochran, Marek Vavrusa

Page 2: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What is this about?

● Vulnerability in glibc DNS clients● Similar to CVE-2015-0235 GHOST● 2015-07-13 reported● 2016-02-16 disclosed + fixed● PoC on the same day

Page 3: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Why is it the Skeleton key?

Page 4: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

In bulk of the attacks, attackers target servers

DoS, malicious queries

Page 5: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

In bulk of the attacks, attackers target servers

DoS, malicious queries

Page 6: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Or they trick clients

RecursiveSpoofed answers

Sends queries

Gets answers

Page 7: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Sometimes both

RecursiveSpoofed answers

Sends queries

Gets answers

Page 8: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

But don’t talk with clients directly

Page 9: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Who is the client anyway?

● Every software using DNS (browsers, ssh)● Most of the languages use the C interface

(getaddrinfo, gethostbyname)● Not really varied implementations

Page 10: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What if they could?

Page 11: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

How did we carry out the attack

Page 12: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Attack scenario in PoC

A + AAAA ?

>=2084, TC=1

>=2048

TCP: AAAA ?

Page 13: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Attack scenario in PoC

A + AAAA ?

>=2084, TC=1

>=2048

TCP: AAAA ?

Page 14: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

The three conditions

>=2084

>=2048

1. Trigger buffer resize

2. Force a partial retry

3. Deliver payload

Page 15: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What if there’s a proxy or forwarder?

A + AAAA ?

>=2084, TC=1

>=2048

TCP: AAAA ?

Forwarder

Bad upstream

Page 16: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What if there’s a proxy or forwarder?

A + AAAA ?

>=2084, TC=1

>=2048

TCP: AAAA ?

Forwarder

Bad upstream

Page 17: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What if there’s a proxy or forwarder?A + AAAA ?

>=2084, RST

>=2048

TCP: AAAA ?

Scrubbing forwarder

Bad upstreamTC=1

TCP: A + AAAA ?

Page 18: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

But what about caching recursives?

Page 19: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Caching and recursion breaks the conditions

A + AAAA ?

>=2084, TC=1

RecursiveSubrequests?

Maybe queries?

Violates RFC1035 UDP size limits

TTL=0

Page 20: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Caching and recursion breaks the conditions

A + AAAA ? RecursiveSubrequests?

Maybe queries?>=2084, RST

TC=1

TCP: A + AAAA ?

TTL=0

Page 21: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What does the attacker control?

● TTL, can circumvent caching● Timing, can stall and reorder answers● Client-recursive protocol, via oversize

answers

Page 22: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Caching and recursion breaks the conditions

A + AAAA ?Recursive

Subrequests?

Maybe queries?>=2084

TC=1

TCP: A + AAAA ?

A: TTL=0, AAAA: stall

RST

Force close connection between recursive and client

>=2048

TCP: AAAA ?

Page 23: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Mitigations: The good, bad && the worthyWhat worked, what broke and what enabled exploitation

Page 24: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Originally Suggested Mitigations

● Google: DNSmasq, etc. to limit the response sizes accepted for both UDP and TCP to nothing larger than 2048 bytes

● Red Hat: A firewall that drops UDP DNS packets > 512 bytes○ Breaks lots of things

Page 25: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Originally Suggested Mitigations

● Red Hat: Avoid dual A and AAAA queries (avoids buffer management error) e.g. Do not use AF_UNSPEC○ Not applicable for your average user○ Breaks lots of things

● Bye bye, EDNS0

Page 26: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Threat model

Is it exploitable? How exploitable?

GAME OVER

Page 27: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Real world exercise: djbdns (dnscache)

● Holds 20 concurrent connections.● Drops the first. FIFO.● Truncate->TCP->A/AAAA Payload->Drop

■ YAHTZEE!

AAAA Payload

Page 28: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Real world exercise: djbdns (dnscache)

GAME OVER

Page 29: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

What did we learn here?

Everything hinges on severing the TCP connection to induce the retry.

From there on out, it’s game over, no matter how you cut it.

Page 30: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

OpenDNS: Based on djbdns

● Massive connection pool compared to dnscache.

● Spent a long Friday night with their team trying to exploit.

● Their implementation doesn’t severe the TCP connection when request leaves pool

Page 31: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

OpenDNS: They’re unaffected… by that vector.

● Don’t forget though, it all hinges on severing the TCP connection...

Page 32: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Real World Exercise: BIND9

ASSERTION:GAME OVER

Page 33: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

BIND9: Throws assert failures everywhere

A + AAAA ?Recursive

Subrequests?

Maybe queries?>=2084

TC=1

TCP: A + AAAA ?

A: TTL=0, AAAA: stall

CVE-201?-????

Force close connection between recursive and client

with assert.

PAYLOAD

TCP: AAAA ?

WINNER

Page 34: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

The Variables for Successful Exploitation● Know thy opponents architecture and

you will own everything.● Attacker must own NS for the malicious

domain.● In order to traverse caches, attacker

must also control resolv.conf or the home router that handles DNS(easy)

Page 35: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

The Variables for Successful Exploitation pt. 2

● Depending how the exploit is written, sometimes the A/AAAA queries show up in different order. Exploit must account for that.

● If payload successfully delivered: ○ Smashing the Stack for Fun and Profit

Page 36: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

This is not a one-shot ./hack

● Too many uncontrollable variables○ Nameservers○ Tricking the person into visiting the

malicious site.

Page 37: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Conclusion

Page 38: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

The McGyver Effect.

● Bugs only get better.● Luckily this is a hard one and went

unnoticed.● But still, bugs only get better and this bug

will be around for years to come.

Page 39: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

IoT to CPE’s: If Mirai were a little bit smarter

● If enough devices infected by a botnet that leverages this exploit (and more), we’re in trouble.

● CPE’s are the most easily targeted and used to setup attack vectors

● There’s no way of telling if this has been exploited in the wild still.

Page 40: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Questions?

Page 41: in DNS Exploring CVE-2015-7547, a Skeleton key...Similar to CVE-2015-0235 GHOST 2015-07-13 reported 2016-02-16 disclosed + fixed PoC on the same day. Why is it the Skeleton key? In

Thank you!