side-channel attack surfaces a hacker’s guide to …...security and privacy group google, @elie a...

68
Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel aack suaces using deep-learning with the help of many Googlers and external collaborators Google, @jmichel_p

Upload: others

Post on 30-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Google, @elie

A Hacker’s guide to reducing side-channel attack surfaces using deep-learning

with the help of many Googlers and external collaborators

Google, @jmichel_p

Page 2: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Talk is based on some of the results of a joint research project with many collaborators on hardening hardware cryptography

Page 3: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Work in progressExperimental results and code ahead

Page 4: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Side channel attacks are one of the most efficient ways to attack secure hardware

Page 5: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

A side-channel attack was used to recover the Trezor bitcoin wallet private key

https://jochen-hoenicke.de/crypto/trezor-power-analysis/

Page 6: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Side-channels attacks are notoriously hard to debug and fix

Page 7: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Can we create a debugger that accurately pinpoints the code vulnerable to side-channel attacks?

?

Page 8: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Combine deep-learning and dynamic analysis to pinpoint origin of leakage

Page 9: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

AI? Really?

Page 10: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Side Channel Attacks Leak Detector

Page 11: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Today’s goal: use SCALD to debug tinyAES running on STM32F4

Page 12: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Agenda

What are side channels?

AI based side-channel attacks

AI explainability

Finding implementation leakage origin with SCALD

Page 13: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Code and slideshttps://elie.net/scald

Page 14: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

DisclaimerThis talk purposely focuses on showcasing a high level overview of how to debug a cryptographic implementation end-to-end using SCALD. For technical details, see the paper

Page 15: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Part 1

What are side-channel attacks?

Page 16: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

A side-channel attack is an indirect measurement of a computation result via an auxiliary mechanism

Page 17: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Real-world side-channel applications

Recover encryption keys

Perform blind SQL injections

Steal passwords and pins

Extract crypto wallets

Page 18: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Timing

Electromagnetic emission

Heat

Current

Plaintext

Secret Key

Page 19: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

1 2 3 4 65 107 8 9

AES round are visible in lightly protected AES implementation power traces

Page 20: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

AES key!

SCA in a nutshell

Encryption Template attackSignal acquisition

Page 21: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

NewAE Chipwhisperer Pro + Picoscope 6000 for fast sampling rate is what we use for our researchThis is not an ad :) it is a recommendation based on what we use

Page 22: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Section 2

AI based side-channel attacks

Page 23: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Side Channel Attacks Automated with Machine Learning

Page 24: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

How do SCAAML attacks work in practice?

Page 25: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Check out last year talk for in-depth explanation https://elie.net/scaaml

Page 26: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Threat modelwhitebox attackContrary to our previous work that focused on black box attacks, the traces used in this talk are truncated and collected synchronously to improve debugging quality. This is consistent with the white-box attack model used during chip development. Additionally, the model architecture is also optimized for debugging, not pure performance.

Page 27: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

AES key!

SCAAML process overview

Encryption Combine DNN predictions

Signal acquisition(ChipWhisperer)

Predictionsusing DNN

Page 28: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

sub_bytes_in

sub_bytes_out

key

SBOX

TinyAES has multiples attack points that can be targeted by SCAAML.

Today we focus on sub_bytes_in

key PT

Page 29: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Probabilistic attack:

...

...

Page 30: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Probabilistic attack:

Val 0: 0.10

Val 1: 0.02

Val 2: 0.01

Val 254: 0.02

Val 42: 0.3

Val 255: 0.05

...

...

Val 0: 0.08

Val 1: 0.04

Val 2: 0.05

Val 254: 0.03

Val 42: 0.12

Val 255: 0.10

...

...

+ … +

*sum uses log10 + ε

Val 0: 4.4

Val 1: 5.3

Val 2: 3.2

Val 254: 2.9

Val 42: 21.4

Val 255: 4.2

...

...

Page 31: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Model architectureHypertuned residual separated 1D convolution network

Custom residual block used

Page 32: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Tensorboards - 1 model per byte

Page 33: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Our side-channel optimized model architecture yield 16 high accuracy model in 5 epoch as expect on this easy use-case

Page 34: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

How to find where TinyAES is leaking using our model?

?

Page 35: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Section 3

Deep-learning explainability

Page 36: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

...

A classic vision model prediction

Boxer

Tiger cat

Page 37: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Why did the model predict a tiger cat and a boxer?

?

Page 38: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Why did the model predict a tiger cat and dog?

?

Explainability to the rescue:

Boxer

Explainer

Page 39: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Why did the model predict a tiger cat and dog?

?

Explainability to the rescue:

Tiger cat

Page 40: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Identifying errors and biases

Unmasking Clever Hans Predictors and Assessing What Machines Really Learn

Page 41: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

How do I use explainability and combine it with dynamic analysis to debug leakages?

?

Page 42: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Section 4

Finding leakage origin with SCALD

Page 43: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Target emulator

SCALD: Game planAnnotated code SCALD: Game plan

Explainer

Model

Traces + predictions Leakage map

Target emulator(cpu + firmware)

Annotated code

Page 44: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Many explainability techniques exists

Sanity Checks for Saliency Maps - Adebayo et al.

Page 45: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Which explainability techniques work best?

?

Page 46: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Aggregate,filter, and normalize

Reduce to key spikes

Leak maps

Page 47: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Byte 0 leak mapvisualization for various techniques

SNR

Grad Cam++

Activations maps

Page 48: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Benchmarking key explainability techniques

Test tracesmodel

Leak map

mask top n points

Accuracy decrease

Page 49: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Benchmark results: lower is better

Byte

0

SNR

Byte

7

57%

44%

Byte

0Activation

maps

Byte

7

58%

95%

Byte

0

Grad Cam++

Byte

7

58%

95%

Baseline

100%

Preliminary results - 4 points masked

Page 50: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Explainability techniques don’t work better than SNR and have very noisy leak maps

Page 51: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Develop a technique tailored to leakage explanation

Page 52: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Custom code? Really?

Page 53: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

SCALD explainer combines partitioned and convolutive occlusion for speed and precise leakage pinpointing

SCALD leakage map

Byte 0

Byte 7

Page 54: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Benchmark results: lower is better

Byte

0

SNR

Byte

7

57%

44%

Byte

0Activation

maps

Byte

7

58%

95%

Byte

0

Grad Cam++

Byte

7

58%

95%

Baseline

100%

Preliminary results - 4 points masked

SCALD

17%

42%

Page 55: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

SCALD

byte 0 leak maps comparaison: the SCALD map is visibly cleaner

SNR

Gradcam

Page 56: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

SCALD custom explainability technique decreases accuracy the most and generate low noise leak map

Page 57: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

How do you go from the leakage map to code?

?

Page 58: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

state automaton

FW CPU

From traces to CPU instructions

Leakage map Mapped ASM

Page 59: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Code mapper

From CPU instructions to code

Mapped ASM

Debug symbolFirmware

Code leakage mapping

Page 60: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Theory looks great but how hard is it in practice?

?

Page 61: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Requirements

An explanation technique that have single point precisionWe need to isolate the exact few points of the traces that cause most of the leakage as some instruction only take one cycle or two (4 or 8 traces points)

An emulator that have single cycle precisionWe need to map each instruction to its exact cycle to be able to map them to the trace. A single error and the entire analysis is wrong as all instruction will be shifted.

A bit of computationYou need a 1M data point dataset, 16 models, 16 explanations, 1 full target execution and 1 mapping. With all our optimization this is requires a few days of computation that are parallelizable.

Page 62: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

This level of explainability and emulation precision seems out-of reach

Page 63: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Model targeting sub_bytes_in are expected to mostly exploit leakage in the AddRoundKey() function

STM32F4 - TinyAES

Page 64: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Scald analysis result output

TinyAES aes.c line 213 is exactly the sub_byte_in operation! SCALD perfectly identify the main source of leakage.

Page 65: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

SCALD is able to automatically isolate the exact code vulnerable to a given SCAAML side-channel attack

Page 66: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

SCALD annotated code empowers developers to quickly figure out what to patch and focus on developing stronger crypto

Page 67: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

SCAAML attacks allows to perform SOTA SCA attacks automatically

AI for side-channel is still a nascent field with a lot of exciting opportunities

SCALD use AI to find automatically leakage origin - reducing development cost

Takeaways

Page 68: side-channel attack surfaces A Hacker’s guide to …...Security and Privacy Group Google, @elie A Hacker’s guide to reducing side-channel attack surfaces using deep-learning with

Security and Privacy Group

Keep up with our research on deep-learning for side-channel attacks: https://elie.net/scaaml