Top Banner
Software Security CompSci 725 Cryptography and Steganography (Handout 11) August 2009 Clark Thomborson University of Auckland
35

Software Security CompSci 725 Cryptography and Steganography (Handout 11)

Jan 20, 2016

Download

Documents

licia

Software Security CompSci 725 Cryptography and Steganography (Handout 11). August 2009 Clark Thomborson University of Auckland. An Attack Taxonomy for Communication Systems. Interception (attacker reads the message); Interruption (attacker prevents delivery); - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Software SecurityCompSci 725

Cryptography and Steganography

(Handout 11)

August 2009

Clark Thomborson

University of Auckland

Page 2: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

An Attack Taxonomy for Communication Systems

1. Interception (attacker reads the message);

2. Interruption (attacker prevents delivery);

3. Modification (attacker changes the message);

4. Fabrication (attacker injects a message);

5. Impersonation (attacker pretends to be a legitimate sender or receiver);

6. Repudiation (attacker is a legitimate sender or receiver, who falsely asserts that they did not send or receive a message).

CompSci 725sc07-10.2

Page 3: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Analysing a Security Requirement• “Suppose a sender [Alice] wants to send a message to

a receiver [Bob]. Moreover, [Alice] wants to send the message securely: [Alice] wants to make sure an eavesdropper [Trudy] cannot read the message.” (Schneier, Applied Cryptography, 2nd edition, 1996)

• Exercise 1. Draw a picture of this scenario.

• Exercise 2. Discuss Alice’s security requirements, using the terminology developed in COMPSCI 725.

CompSci 725sc07-10.3

Page 4: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

• Cryptology: the art (science) of communication with secret codes. Includes – Cryptography: the making of secret codes.– Cryptanalysis : “breaking” codes, so that the

plaintext of a message is revealed.

• Exercise 3: identify a non-cryptographic threat to the information flow shown above.

Terminology of Cryptography

Encryption

DecryptionAlice

Bob

plaintext plaintextciphertext

key

key

CompSci 725sc07-10.4

Page 5: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

A Simple Encryption Scheme

• Rot(k,s) : “rotate” each character in string s by k: for( i=0; i<len(s); i++ )

s[i] = ( s[i] + k ) mod 26;return(s);

• Exercise 4: write the corresponding decryption routine.

• Exercise 5: how many keys must you try, before you can “break” a ciphertext Rot(k,s)?

• This is a (very weak) “secret-key” encryption scheme, where the secret key is k.

• When k=3, this is “Caesar’s cipher”.CompSci 725sc07-10.5

Page 6: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Symmetric and Public-Key Encryption

• If the decryption key kd can be computed from the encryption key ke, then the algorithm is called “symmetric”.

• Question: is Rot(ke,s) a symmetric cipher?

• If the decryption key kd cannot be computed (in a reasonable amount of time) from the encryption key ke, then the algorithm is called “asymmetric” or “public-key”.

CompSci 725sc07-10.6

Page 7: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

One-Time Pads• If our secret key K is as long as our plaintext message P,

when both are written as binary bitstrings, then we can easily compute the bitwise exclusive-or KP.

• This encoding is “provably secure”, if we never re-use the key.– Provably secure = The most efficient way to compute P, given

KP, is to try all possible keys K.

• It is often impractical to establish long secret keys.• Reference: Stamp, Information Security, pp. 18-19.• Warning: Security may be breached if an attacker knows

that an encrypted message has been sent!– Traffic analysis: if a burst of messages is sent from the Pentagon…– Steganography is the art of sending imperceptible messages.

CompSci 725sc07-10.7

Page 8: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Stream Ciphers• We can encrypt an arbitrarily long bitstring

P if we know how to generate an arbitrarily-long “keystring” S from our secret key K.

• The encryption is the bitwise exclusive-or SP.

• Decryption is the same function as encryption, because S ( S P ) = P.

• RC4 is a stream cipher used in SSL.

• Reference: Stamp, pp. 36-37.CompSci 725sc07-10.8

Page 9: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Block Ciphers• We can encrypt an arbitrarily long bitstring P by

breaking it up into blocks P0, P1, P2, …, of some convenient size (e.g. 256 bits), then encrypting each block separately.

• You must vary the encryption at least slightly for each block, otherwise the attacker can easily discover i, j : Pi = Pj.

• A common method for varying the block encryptions is “cipher block chaining” (CBC).– Each plaintext block is XOR-ed with the ciphertext

from the previous block, before being encrypted.• Reference: Stamp, pp. 50-51.• Common block ciphers: DES, 3DES, AES.

CompSci 725sc07-10.9

Page 10: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Message Integrity• So far, we have considered only interception attacks.• The Message Authentication Code (MAC) is the last ciphertext

block from a CBC-mode block cipher.– Changing any message bit will change the MAC.– Unless you know the secret key, you can’t compute a MAC from the

plaintext.• Sending a plaintext message, plus its MAC, will ensure message

integrity to anyone who knows the (shared) secret key.• This defends against modification and fabrication!• Note: changing a bit in an encrypted message will make it

unreadable, but there’s no general-purpose algorithm to determine “readability”.

• Keyed hashes (HMACs) are another approach.– SHA-1 and MD5 are used in SSL.

• Reference: Stamp, pp. 54-55 and 93-94.

CompSci 725sc07-10.10

Page 11: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Public Key CryptographyEncryption E: Plaintext × EncryptionKey CyphertextDecryption D: Cyphertext × DecryptionKey Plaintext

• The receiver can decrypt if they know the decryption key kd : P: D( E( P, ke ), kd ) = P.

• In public-key cryptography, we use key-pairs (s, p), where our secret key s cannot be computed efficiently (as far as anyone knows) from our public key p and our encrypted messages.– The algorithms (E, D) are standardized.– We let everyone know our public key p.– We don’t let anyone else know our corresponding secret key s.– Anybody can send us encrypted messages using E(*, p).– Simpler notation: {P}Clark is plaintext P that has been

encrypted by a secret key named “Clark”.• Reference: Stamp, pp. 75-79.

CompSci 725sc07-10.11

Page 12: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Authentication in PK Cryptography• We can use our secret key s to encrypt a message which everyone can decrypt

using our public key p. – E(P, s) is a “signed message”. Simpler notation: [P]Clark

– Only people who know the secret key named “Clark” can create this signature.

– Anyone who knows the public key for “Clark” can validate this signature.– This defends against impersonation and repudiation attacks!

• We may have many public/private key pairs:– For our email,– For our bank account (our partner knows this private key too),– For our workgroup (shared with other members), …

• A “public key infrastructure” (PKI) will help us discover other people’s public keys (p1, p2, …), if we know the names of these keys and where they were registered.– A registry database is called a “certificate authority” (CA).– Warning: someone might register a key under your name!

CompSci 725sc07-10.12

Page 13: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

A Simple Cryptographic Protocol

Alice Bob

RA

{SK}B, {P}SK

[B, “Bob”]CA

1. Alice sends a service request RA to Bob.

2. Bob replies with his digital certificate.• Bob’s certificate contains Bob’s public key B and Bob’s name.• This certificate was signed by a Certificate Authority, using a

public key CA which Alice already knows.

3. Alice creates a symmetric key SK. This is a “session key”. • Alice sends SK to Bob, encrypted with public key B.• Alice and Bob will use SK to encrypt their plaintext messages.

CompSci 725sc07-10.13

Page 14: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Protocol Analysis

[T, “Trudy”]CA

Alice Bob

RA

Trudy: acting as Alice to Bob,and as Bob to Alice

{SK}T, {P}SK

RA

[B, “Bob”]CA

{SK}B, {P}SK

• How can Alice detect that Trudy is “in the middle”?• What does your web-browser do, when it receives a

digital certificate that says “Trudy” instead of “Bob”?

• Trudy’s certificate might be [T, “Bob”]CA’

• If you follow a URL to “https://www.bankofamerica.org”, your browser might form an SSL connection with a Nigerian website which spoofs the website of a legitimate bank!

• Have you ever inspected an SSL certificate? CompSci 725sc07-10.14

Page 15: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Attacks on Cryptographic Protocols• A ciphertext may be broken by…

– Discovering the “restricted” algorithm (if the algorithm doesn’t require a key).

– Discovering the key by non-cryptographic means (bribery, theft, ‘just asking’).

– Discovering the key by “brute-force search” (through all possible keys).

– Discovering the key by cryptanalysis based on other information, such as known pairs of (plaintext, ciphertext).

• The weakest point in the system may not be its cryptography!– See Ferguson & Schneier, Practical Cryptography, 2003.– For example: you should consider what identification was

required, when a CA accepted a key, before you accept any public key from that CA as a “proof of identity”.

CompSci 725sc07-10.15

Page 16: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Limitations and Usage of PKI• If a Certificate Authority is offline, or if you can’t be bothered

to wait for a response, you will use the public keys stored in your local computer.– Warning: a public key may be revoked at any time, e.g. if someone

reports their key was stolen.

• Key Continuity Management is an alternative to PKI.– The first time someone presents a key, you decide whether or not to

accept it.– When someone presents a key that you have previously accepted, it’s

probably ok.– If someone presents a changed key, you should think carefully before

accepting!– This idea was introduced in SSH, in 1996. It was named, and

identified as a general design principle, by Peter Gutmann (http://www.cs.auckland.ac.nz/~pgut001/).

– Reference: Simson Garfinkel, in http://www.simson.net/thesis/pki3.pdfCompSci 725sc07-10.16

Page 17: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Identification and Authentication• You can authenticate your identity to a local

machine by– what you have (e.g. a smart card),– what you know (e.g. a password),– what you “are” (e.g. your thumbprint or handwriting)

• After you have authenticated yourself locally, then you can use cryptographic protocols to…– … authenticate your outgoing messages (if others know

your public key);– … verify the integrity of your incoming messages (if you

know your correspondents’ public keys);– … send confidential messages to other people (if you

know their public keys).– Warning: you (and others) must trust the operations of

your local machine! We’ll return to this subject…CompSci 725sc07-10.17

Page 18: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Watermarking, Tamper-Proofing and Obfuscation – Tools for

Software Protection

Christian Collberg & Clark Thomborson

IEEE Transactions on Software Engineering 28:8, 735-746, August 2002

CompSci 725sc07-10.18

Page 19: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Watermarking and Fingerprinting

• Messages may be images, audio, video, text, executables, …

• Visible or invisible (steganographic) embeddings

• Robust (difficult to remove) or fragile (guaranteed to be removed) if cover is distorted.

• Watermarking (only one extra message per cover) or fingerprinting (different versions of the cover carry different messages).

Watermark: an additional message, embedded into a cover message.

CompSci 725sc07-10.19

Page 20: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Our Desiderata for (Robust, Invisible) SW Watermarks

• Watermarks should be stealthy -- difficult for an adversary to locate.

• Watermarks should be resilient to attack -- resisting attempts at removal even if they are located.

• Watermarks should have a high data-rate -- so that we can store a meaningful message without significantly increasing the size of the object.

CompSci 725sc07-10.20

Page 21: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Attacks on Watermarks• Subtractive attacks: remove the watermark (WM)

without damaging the cover.• Additive attacks: add a new WM without revealing

“which WM was added first”.• Distortive attacks: modify the WM without

damaging the cover.• Collusive attacks: examine two fingerprinted

objects, or a watermarked object and its unwatermarked cover; find the differences; construct a new object without a recognisable mark.

CompSci 725sc07-10.21

Page 22: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Defenses for Robust Software Watermarks

• Obfuscation: we can modify the software, so that a reverse engineer will have great difficulty figuring out how to reproduce the cover without also reproducing the WM.

• Tamperproofing: we can add integrity-checking code that (almost always) renders it unusable if the object is modified.

CompSci 725sc07-10.22

Page 23: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Classification of Software Watermarks

• Static code watermarks are stored in the section of the executable that contains instructions.

• Static data watermarks are stored in other sections of the executable.

Dynamic data watermarks are stored in a program’s execution state. Such watermarks are resilient to distortive (obfuscation) attacks.

CompSci 725sc07-10.23

Page 24: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Dynamic Watermarks

• Easter Eggs are revealed to any end-user who types a special input sequence.

• Execution Trace Watermarks are carried (steganographically) in the instruction execution sequence of a program, when it is given a special input.

Data Structure Watermarks are built (steganographically) by a program, when it is given a special input sequence (possibly null).

CompSci 725sc07-10.24

Page 25: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Easter Eggs

• The watermark is visible -- if you know where to look!

• Not resilient, once the secret is out.

• See www.eeggs.com

CompSci 725sc07-10.25

Page 26: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Goals for Dynamic Datastructure Watermarks

• Stealth. Our WM should “look like” other structures created by the cover (search trees, hash tables, etc.)

• Resiliency. Our WM should have some properties that can be checked, stealthily and quickly at runtime, by tamperproofing code (triangulated graphs, biconnectivity, …)

• Data Rate. We would like to encode 100-bit WMs, or 1000-bit fingerprints, in a few KB of data structure. Our fingerprints may be 1000-bit integers that are products of two primes.

CompSci 725sc07-10.26

Page 27: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Permutation Graphs (Harary)• The WM is 1-3-5-6-2-4.

• High data rate: lg(n!) lg(n/e) bits per node.

• High stealth, low resiliency (?)

• Tamperproofing may involve storing the same permutation in another data structure.

• But… what if an adversary changes the node labels?

13

5

6

2

4

Node labels may be obtained from node positions on another list.

CompSci 725sc07-10.27

Page 28: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Oriented Trees

• Represent as “parent-pointer trees”

• There are)/O(/ 2/52/31 nnc nn

oriented trees on n nodes, with c = 0.44 and = 2.956,so the asymptotic data rate is lg() 1.6 bits/node.

A few of the 48 trees for n = 7Could you “hide” this data structure in the code for a compiler? For a word processor?

1: 2: 22:

48:

CompSci 725sc07-10.28

Page 29: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Planted Plane Cubic Trees

• One root node (in-degree 1).• Trivalent internal nodes, with

rotation on edges.• We add edges to make all

nodes trivalent, preserving planarity and distinguishing the root.

• Simple enumeration (Catalan numbers).

• Data rate is ~2 bits per leaf node.

• Excellent tamperproofing.

n = 1

n = 4

n = 2 n = 3

CompSci 725sc07-10.29

Page 30: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Open Problems in Watermarking

• We can easily build a “recogniser” program to find the WM and therefore demonstrate ownership… but can we release this recogniser to the public without compromising our watermarks?

• Can we design a “partial recogniser” that preserves resiliency, even though it reveals the location of some part of our WM?

CompSci 725sc07-10.30

Page 31: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

State of the Art in SW Watermarking• Davidson and Myhrvold (1996) encode a static

watermark by rearranging the basic blocks of a code.– Venkatesan et al. (2001) add arcs to the control-flow graph.

• The first dynamic data structure watermarks were published by us (POPL’99), with further development:– http://www.cs.arizona.edu/sandmark/ (2000- )– Palsberg et al. (ACSAC’00)– Charles He (MSc 2002)– Collberg et al (WG’03)– Thomborson et al (AISW’04)

• Jasvir Nagra, a PhD student under my supervision, is implementing execution-trace watermarks (IHW’04)

CompSci 725sc07-10.31

Page 32: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Software Obfuscation• Many authors, websites and even a few

commercial products offer “automatic obfuscation” as a defense against reverse engineering.

• Existing products generally operate at the lexical level of software, for example by removing or scrambling the names of identifiers.

• We were the first (in 1997) to use “opaque predicates” to obfuscate the control structure of software.

CompSci 725sc07-10.32

Page 33: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Opaque Predicates

{A; B } A

B

pTT F

“always true”

A

B

P?T F

“indeterminate”

B’

A

B

PTT F

“tamperproof”

Bbug

(“always false” is not shown) CompSci 725sc07-10.33

Page 34: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Opaque Predicates on GraphsDynamic analysis is required!

f g

f g

g.Merge(f)

f.Insert();g.Move();g.Delete() if (f = = g) then …CompSci 725sc07-10.34

Page 35: Software Security CompSci 725 Cryptography and Steganography  (Handout 11)

Conclusion• New art in software obfuscation can make it

more difficult for pirates to defeat standard tamperproofing mechanisms, or to engage in other forms of reverse engineering.

• New art in software watermarking can embed “ownership marks” in software, that will be very difficult for anyone to remove.

• More R&D is required before robust obfuscating and watermarking tools are easy to use and readily available to software developers.

CompSci 725sc07-10.35