83
Compression Oracle Attacks on VPN Networks - Nafeez

Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Compression Oracle Attacks on VPN Networks

- Nafeez

Page 2: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Nafeez

AppSec research, static analysis tools, writing code

Maker @ assetwatch.io - Simple & Transparent Attack Surface Discovery

@sketpic_fx

Page 3: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

OverviewCompression Side Channel and Encryption

History of attacks

VPNs and how they use compression

Voracle attack

How to find if your "VPN" is vulnerable

Way forward

Page 4: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Data CompressionLZ77

Replace redundant patterns

102 CharactersEverything looked dark and bleak, everything looked gloomy,

and everything was under a blanket of mist

89 CharactersEverything looked dark and bleak, (-34,18)gloomy,

and (-54,11)was under a blanket of mist

Page 5: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Data CompressionHuffman Coding

Replace frequent bytes with shorter codes

https://en.wikipedia.org/wiki/Huffman_coding

Page 6: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Data Compression

DEFLATE - LZ77 + Huffman Coding

ZLIB, GZIP are well known DEFLATE libraries

Page 7: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Compression Side Channel

First known research in 2002

Page 8: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

The Side Channel

Length of encrypted payloads

Page 9: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Plain Text Data

Compress

Encrypt

Encrypted Data + Data Length

Page 10: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Plain Text Data

Compress

Encrypt

Add Attacker Controlled Bytes

Encrypted Data + Data Length

Page 11: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Plain Text Data

Compress

Encrypt

Add Attacker Controlled Bytes

Observe Encrypted Traffic

Encrypted Data + Data Length

Page 12: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Compression Oracle Attack

Chosen Plain Text Attack

Brute force the secret byte by byte

Force a compression using the chosen byte and the existing bytes in the secret

Page 13: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=1

Encrypted Length = 30

secret=637193-some-app-data;secret=1

Page 14: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=1

Encrypted Length = 30

secret=637193-some-app-data;secret=1

Application Data

Attacker injected bytes

Whole data before compression /

encryption

Page 15: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=1

Encrypted Length = 30

secret=637193-some-app-data;secret=1Compressible Compressible

Page 16: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=2

Encrypted Length = 30

secret=637193-some-app-data;secret=2

Page 17: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=3

Encrypted Length = 30

secret=637193-some-app-data;secret=3

Page 18: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=4

Encrypted Length = 30

secret=637193-some-app-data;secret=4

Page 19: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=5

Encrypted Length = 30

secret=637193-some-app-data;secret=5

Page 20: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

secret=637193-some-app-data;

Compress

Encrypt

Data Length

secret=6

Encrypted Length = 29

secret=637193-some-app-data;secret=6

More Compression, Smaller Length

Compression increased by 1 byte

Page 21: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

How can we convert this into a real world attack on

browsers?

Page 22: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Plain Text Data

Compress

Encrypt

Add Attacker Controlled Bytes

Observe Encrypted Traffic

Encrypted Data + Data Length

Page 23: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Add Attacker Controlled Bytes

Observe Encrypted Traffic

Browser Sends Cross-Domain requests with

Cookies attached

Attacker can send simple HTTP POST

requests cross-domain with his own data

MITM. People do this all the time

Page 24: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

EkoParty 2012

Back in 2012Juliano Rizzo, Thai Duong

Page 25: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

CRIME, 2012

www.ekoparty.org/archive/2012/CRIME_ekoparty2012.pdf

Page 26: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

TIME Attack 2013

Tal Be'ery, Amichai Shulman

Timing side channel purely via browsers, using TCP window sizes.

Extending CRIME to HTTP Responses

Page 27: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

BREACH Attack 2013

BreachAttack.com

Angelo Prado, Neal Harris, Yoel Gluck

Page 28: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

So far

CRIME style attacks have been mostly targeted on HTTPS

Researchers have possibly explored all possible side channels to efficiently leak sensitive data

There are more - HEIST, Practical Developments to BREACH

Page 29: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

So, whats new today?

Page 30: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

VPN Tunnels

Page 31: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

TLS VPNs are pretty common these days

Page 32: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs
Page 33: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

What do most of these SaaS VPNs have in

common?

Page 34: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

OpenVPN

Page 35: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

High level overview

Authentication & Key Negotiation (Control Channel)

Data Channel Compression

Data Channel Encryption

Page 36: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Compress everything

UDP

TCP

Bi-Directional

Page 37: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

OpenVPN Compression Algorithms

LZO

LZ4

-LZ77 Family-

Page 38: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

We have a compress then encrypt on all of data channel

Page 39: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

VORACLE Attack

Page 40: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Under a VPN, HTTP WebApps are still

insecure !

Page 41: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Things are safe, if the underlying app layer already uses an encryption channel.

Page 42: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Things might go bad, if the VPN tunnel is helping you encrypt already non-

encrypted data

Page 43: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Lets see how this attack works on an HTTP website using an encrypted VPN

Page 44: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

VPN Server and Client has Compression enabled by default

Requirements

Attacker can observe VPN traffic

VPN User visits attacker.com

Page 45: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Page 46: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

Page 47: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Page 48: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Page 49: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Page 50: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Attacker

Page 51: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Attackerattacker.com

Page 52: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Attackerattacker.com

Passive MITM

Page 53: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Attackerattacker.com

Passive MITM

Injected Ads,Malicous Blogs,

etc.

Page 54: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Attackerattacker.com

Passive MITM

Injected Ads,Malicous Blogs,

etc.

Can Observe VPN Data packet Lengths

Page 55: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Setup

VPN User

Browser

HTTP WebApp

Trusted VPN with Compression

Attackerattacker.com

Passive MITM

Injected Ads,Malicous Blogs,

etc.

Can Observe VPN Data packet Lengths

Can Send Cross Domain requests to the HTTP WebApp

Page 56: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attacker can now conduct Compression Oracle attacks on HTTP requests and responses

Page 57: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

https://github.com/OpenVPN/openvpn3

Browser

VPN Client

VPN Server OpenVPN Server

WebApp http://insecure.skepticfx.com

Mozilla Firefox

Steal sessionId cookie from a cross-domain websiteAttack Goal

Demo

Page 58: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Voracle

https://github.com/skepticfx/voracle

Page 59: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Attack Challenges

No Server Name Indication(SNI) or TLS certificates.

VPN traffic is too chatty. Everything goes through it

Hard to determine attacker's own traffic

Page 60: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Browser needs to send HTTP requests in single TCP Data Packet

Also

Page 61: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Google Chrome splits HTTP packets into Header and Body

So we can't get the compression window in the same request

Page 62: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Mozilla Firefox sends them all in a single TCP data packet

Now we get the compression window in the same request

Page 63: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Detecting Voracle in your VPN

Page 64: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

If your VPN provider is using OpenVPN - take a look at your client configuration.

Page 65: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

OpenVPN Client Configuration (*.OVPN)

Page 66: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Or you can test this dynamically by triggering compression and observing the

length

Page 67: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

DIY Voracle Detection

Fire up Wireshark

Connect to your VPN under test

Send a few Curl requests with compression

Observe VPN Payload Length

Page 68: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

curl -s -o /dev/null -X POST http://website.com -d "--some-data-- Secret=37346282; --blah-- Secret=1 Secret=1"

Length = x

Curl and Observe Length

Page 69: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

curl -s -o /dev/null -X POST http://website.com -d "--some-data-- Secret=37346282; --blah-- Secret=2 Secret=2"

Length = x

Curl and Observe Length

Page 70: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

curl -s -o /dev/null -X POST http://website.com -d "--some-data-- Secret=37346282; --blah-- Secret=3 Secret=3"

Length = x-1

Curl and Observe Length

More Compression, Smaller Length

Page 71: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Fix?

Page 72: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Fixing Compression is an interesting problem

Page 73: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Remember when SPDY was vulnerable to

CRIME?

Page 74: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

HPACK in HTTP/2 selectively disables header compression for sensitive

fields

Page 75: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

https://http2.github.io/http2-spec/compression.html

Page 76: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

cf-nocompress

https://blog.cloudflare.com/a-solution-to-compression-oracles-on-the-web/

Page 77: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

For VPNs, Disable compression entirely for all plain text transactions

Page 78: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Turning compression off by default is

opinionated

Page 79: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

OpenVPN chose to warn the implementors more explicitly to turn off data Compression.

https://github.com/OpenVPN/openvpn/commit/a59fd147

Page 80: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

turned off compression entirely

Page 81: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Its time, everything moves to HTTPS

Page 82: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Takeaway

EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs.

VPN Providers - Explicitly state what your VPN protects against. If you are claiming your VPN tunnel protects against plain text web apps, ensure you do not compress them.

Page 83: Compression Oracle Attacks on VPN Networks · Takeaway EndUsers & Website owners - If you are using VPN to access plain text websites over the internet, its time to move them to HTTPs

Thank you!

@skeptic_fx

[email protected]