sha-1 backdooring & exploitation

62
SHA-1 backdooring and exploitation

Upload: ange-albertini

Post on 15-Jan-2015

174 views

Category:

Technology


2 download

DESCRIPTION

If the four 32-bit constants of SHA-1 can be modified, then exploitable collisions can be constructed. No need to panic, this doesn’t affect the original SHA-1. However, vendors and customers of products with custom cryptography will be interested. for more info, check http://malicioussha1.github.io/

TRANSCRIPT

Page 1: SHA-1 backdooring & exploitation

SHA-1backdooring and exploitation

Page 2: SHA-1 backdooring & exploitation

brought to you by

Maria Eichlseder, Florian Mendel, Martin SchläfferTU Graz, .at; cryptanalysis

@angealbertini Corkami, .de; binary kung-fu

@veorq Kudelski Security, .ch; theory and propaganda :-)

Page 3: SHA-1 backdooring & exploitation

1. WTF is a hash function backdoor?2. backdooring SHA1 with cryptanalysis3. exploitation! collisions!

Page 4: SHA-1 backdooring & exploitation

TL;DR:

Page 5: SHA-1 backdooring & exploitation

who’s interested in crypto backdoors?

Page 6: SHA-1 backdooring & exploitation

& Dual_EC speculation — https://projectbullrun.org

Page 7: SHA-1 backdooring & exploitation

Clipper (1993)

Page 8: SHA-1 backdooring & exploitation

crypto researchers?

Page 9: SHA-1 backdooring & exploitation
Page 10: SHA-1 backdooring & exploitation

Young/Yung malicious cipher (2003)- compresses texts to leak key bits in ciphertexts- blackbox only (internals reveal the backdoor)- other “cryptovirology” schemes

Page 11: SHA-1 backdooring & exploitation
Page 12: SHA-1 backdooring & exploitation

2011: theoretical framework, but nothing useful

Page 13: SHA-1 backdooring & exploitation

what’s a crypto backdoor?

Page 14: SHA-1 backdooring & exploitation

not an implementation backdoor

example: RC4 C implementation (Wagner/Biondi)

#define TOBYTE(x) (x) & 255#define SWAP(x,y) do { x^=y; y^=x; x^=y; } while (0)

static unsigned char A[256];static int i=0, j=0;

unsigned char encrypt_one_byte(unsigned char c) { int k; i = TOBYTE(i+1); j = TOBYTE(j + A[i]); SWAP(A[i], A[j]); k = TOBYTE(A[i] + A[j]); return c ^ A[k];}

Page 15: SHA-1 backdooring & exploitation

a backdoor (covert) isn’t a trapdoor (overt)

RSA has a trapdoor, NSA has backdoors

VSH is a trapdoor hash based on RSA

Page 16: SHA-1 backdooring & exploitation

backdoor in a crypto hash?

Page 17: SHA-1 backdooring & exploitation

“some secret property that allows you to efficiently break the hash”

Page 18: SHA-1 backdooring & exploitation

“break” can be about collisions, preimages…how to model the stealthiness of the backdoor…

exploitation can be deterministic or randomized…

Page 19: SHA-1 backdooring & exploitation

role reversal

Eve wants to achieve some security propertyAlice and Bob (the users) are the adversaries

Page 20: SHA-1 backdooring & exploitation

definitionsmalicious hash = pair of algorithms

exploit() either “static” or “dynamic”

generate()randomnesshash function H

backdoor b

exploit()hash function H

collision/preimagebackdoor bchallenge

Page 21: SHA-1 backdooring & exploitation

taxonomystatic collision backdoor

returns constant m and m’ such that H(m)=H(m’)

dynamic collision backdoorreturns random m and m’ such that H(m)=H(m’)

static preimage backdoorreturns m such that H(m) has low entropy

dynamic preimage backdoorgiven h, returns m such that H(m)=h

Page 22: SHA-1 backdooring & exploitation

stealth definitionsundetectability vs undiscoverability

detect() may also return levels of suspicionH may be obfuscated...

detect()hash function H exploit() ?

discover()hash function H

backdoor bexploit()

Page 23: SHA-1 backdooring & exploitation

our resultsdynamic collision backdoor

valid structured files with arbitrary payloads

detectable, but undiscoverableand as hard to discover as to break SHA-1

Page 24: SHA-1 backdooring & exploitation

SHA-1

Page 25: SHA-1 backdooring & exploitation

SHA-1everywhere

RSA-OAEP, “RSAwithSHA1”, HMAC, PBKDF2, etc.⇒ in TLS, SSH, IPsec, etc.

integrity check: git, bootloaders, HIDS/FIM, etc.

Page 26: SHA-1 backdooring & exploitation

SHA-1

Page 27: SHA-1 backdooring & exploitation

but no collision published yetactual complexity unclear (>260)

Page 28: SHA-1 backdooring & exploitation

Differential cryptanalysis for collisions “perturb-and-correct”

Page 29: SHA-1 backdooring & exploitation

2 stages (offline/online)

1. find a good differential characteristic= one of high probability

2. find conforming messageswith message modification techniques

Page 30: SHA-1 backdooring & exploitation

find a characteristic: linearization

low-probability

high-probability

2-40 2-15

2-40

Page 31: SHA-1 backdooring & exploitation

find conforming messageslow-probability part: “easy”, K1 unchangeduse automated tool to find a conforming message

round 2: try all 232 K2‘s, repeat 28 times (cost 240)consider constant K2 as part of the message!

round 3: do the same to find a K3 (total cost 248)repeating the 240 search of K2 2

8 times….

round 4: find K4 in negligible time

iterate to minimize the differences in the constants...

Page 32: SHA-1 backdooring & exploitation

collision!

1-block, vs. 2-block collisions for previous attacks

Page 33: SHA-1 backdooring & exploitation

empty

Page 34: SHA-1 backdooring & exploitation

but it’s not the real SHA-1!

Page 35: SHA-1 backdooring & exploitation

“custom” standards are common in proprietary systems

(encryption appliances, set-top boxes, etc.)

motivations:customer-specific crypto (customers’ request)

“other reasons”

Page 36: SHA-1 backdooring & exploitation

how to turn garbage collisions into useful collisions?

(= 2 valid files with arbitrary content)

Page 37: SHA-1 backdooring & exploitation

basic idea

where H(M1)=H(M2)and Mx is essentially “process payload x”

M1

M2

Payload1 Payload2

Payload1 Payload2

Page 38: SHA-1 backdooring & exploitation

constraints

differences (only in) the first block

difference in the first four bytes⇒ 4-byte signatures corrupted

Page 39: SHA-1 backdooring & exploitation

PE? (Win* executables, etc.)

differences forces EntryPoint to be at > 0x40000000⇒ 1GiB (not supported by Windows)

Page 40: SHA-1 backdooring & exploitation

PE = fail

Page 41: SHA-1 backdooring & exploitation

ELF, Mach-O = fail(≥ 4-byte signature at offset 0)

Page 42: SHA-1 backdooring & exploitation

shell scripts?

Page 43: SHA-1 backdooring & exploitation

#<garbage, 63 bytes>

#<garbage with differences>

EOL

<check for block’s content>

//block 1 start

//block 2 start

//same payload

Page 44: SHA-1 backdooring & exploitation
Page 45: SHA-1 backdooring & exploitation
Page 46: SHA-1 backdooring & exploitation

RAR/7z

scanned forward

≥ 4-byte signature :-(

but signature can start at any offset :-D⇒ payload = 2 concatenated archives

Page 47: SHA-1 backdooring & exploitation

killing the 1st signature byte disables the top archive

Page 48: SHA-1 backdooring & exploitation

COM/MBR?

Page 49: SHA-1 backdooring & exploitation

COM/MBR(DOS executable/Master Boot Record)

no signature!

start with x86 (16 bits) code at offset 0

like shell scripts, skip initial garbage

JMP to distinct addr rather than comments

Page 50: SHA-1 backdooring & exploitation

JMP address1

JMP address2

address1:

<payload1>

address2:

<payload2>

//block 1 start

//block 2 start

//common payload

Page 51: SHA-1 backdooring & exploitation

JPEG?

Page 52: SHA-1 backdooring & exploitation

JPEG

2-byte signature 0xFFD8

sequence of chunks

ideamessage 1: first chunk “commented”

message 2: first chunk processed

Page 53: SHA-1 backdooring & exploitation
Page 54: SHA-1 backdooring & exploitation
Page 55: SHA-1 backdooring & exploitation

polyglots

2 distinct files, 3 valid file formats!

~virtual multicollisions

Page 56: SHA-1 backdooring & exploitation

> msha1.py mbr_shell_rar*.pdf 5a827999 82b1c71a 5141963a b389abb9mbr_shell_rar0.pdf 10382a6d3c949408d7cafaaf6d110a9e23230416mbr_shell_rar1.pdf 10382a6d3c949408d7cafaaf6d110a9e23230416

> msha1.py jpg-rar*.jpg 5a827999 9b73a440 71599fc5 0c8a53e4jpg-rar0.jpg 7a00042714d8ee6f4978193b07df705b652d0e39jpg-rar1.jpg 7a00042714d8ee6f4978193b07df705b652d0e39

more magic: just 2 files here

Page 57: SHA-1 backdooring & exploitation
Page 58: SHA-1 backdooring & exploitation

Conclusions

Page 59: SHA-1 backdooring & exploitation

Implications for SHA-1 security?

None. We did not improve attacks on the

unmodified SHA-1.

Page 60: SHA-1 backdooring & exploitation

Did NSA use this trick when designing SHA-1 in 1995?

Probably not, because1) cryptanalysis techniques are known since ~2004 2) the constants look like NUMSN (√2 √3 √5 √10) 3) remember the SHA-0 fiasco :)

Page 61: SHA-1 backdooring & exploitation

Can you do the same for SHA-256?

Not at the moment.

Good: SHA-256 uses distinct constants at each step⇒more control to conform to the characteristic

(but also more differences with the original)

Not good: The best known attack is on 31 steps (in ~265), of 64 steps in total, so it might be difficult to find a useful 64-step characteristic

Page 62: SHA-1 backdooring & exploitation

thank you! questions?

Roads? Where we're going, we don't need roads.