malign machine learning models - zeronights · 2019-12-12 · custom serialization •protobuf...

29
MALIGN MACHINE LEARNING MODELS

Upload: others

Post on 05-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

MALIGN MACHINE LEARNING MODELS

Page 2: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

github.com/sdnewhop/AISec

●●●●●

That’s me!

Page 3: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Problem overview

3

Page 4: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Frameworks

4

Page 5: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

More parameters -> Longer train

5

Page 6: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Pre-trained model workflow

6

Page 7: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Distribution

7

•~ 2k repos on github•~ 100 repos on gitlab•~ 500 models on https://modelzoo.co/

Page 8: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Part I

8

Page 9: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Documentation

9

Page 10: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Reality

10

Page 11: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Step 1. Find an existing model

11

Page 12: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Step 2. Infect it!

12

Page 13: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Step 3. Upload it

13

Page 14: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

• Just one command to run from anywhere!

• torch.hub.load(“ChickenDuo/top10-awesome-google-models”, “date_of_death_prediction”)

14

Page 15: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Part II

15

Page 16: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Serialization

16

Page 17: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Cross-platform -> Another approach

17

Page 18: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Custom serialization

•Protobuf format (.pb)•~1300 operations (math, conditionals, statistics, etc.)•Only TWO of them were found dangerous•WriteFile (any text, any file)•ReadFile (any file)

18

Page 19: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Graph serialization

19

Page 20: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Code

20

Page 21: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Wrapper

21

Page 22: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Wrapper

22

Page 23: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Configs

23

Page 24: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Part III

24

Page 25: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

25

Serialization

Page 26: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Serialization with topology

26

- Only Keras layers (Functional model)

- … has a Lambda layer, which serialize custom python function with marshal (https://github.com/keras-team/keras/blob/master/keras/layers/core.py#L566)

- No warning on launching third-party models!

© keras.io

Page 27: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

Example

27

Page 28: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

28

Page 29: MALIGN MACHINE LEARNING MODELS - ZeroNights · 2019-12-12 · Custom serialization •Protobuf format (.pb) •~1300 operations (math, conditionals, statistics, etc.) •Only TWO

@chicken_2007

THANKS FOR ATTENTION