65
1 How to Break XML Encryption – Automatically Juraj Somorovsky How to Break XML Encryption – Automatically Dennis Kupser, Christian Mainka, Jörg Schwenk, Juraj Somorovsky Ruhr University Bochum @jurajsomorovsky 1

How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

  • Upload
    others

  • View
    37

  • Download
    0

Embed Size (px)

Citation preview

Page 1: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

1How to Break XML Encryption – Automatically Juraj Somorovsky

How to Break XML Encryption –Automatically

Dennis Kupser, Christian Mainka, Jörg Schwenk, Juraj Somorovsky

Ruhr University Bochum

@jurajsomorovsky

1

Page 2: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

2How to Break XML Encryption – Automatically Juraj Somorovsky

About Me and Our Institute

• Security Researcher at:

– Chair for Network and Data Security• Prof. Dr. Jörg Schwenk

• Web Services, Single Sign-On, (Applied) Crypto, SSL, crypto currencies

• Provable security, attacks and defenses

– Horst Görtz Institute for IT-Security• Further topics: embedded security, malware, crypto…

– Ruhr University Bochum

• Penetration tests, security analyses, workshops…

2

Page 3: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

3How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

3

Page 4: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

4How to Break XML Encryption – Automatically Juraj Somorovsky

What is a (SOAP) Web Service?

Envelope

getPrime

Body

Envelope

Body

11

thePrime

Client Server

4

Page 5: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

5How to Break XML Encryption – Automatically Juraj Somorovsky 5

More complicated scenarios …

Broker

Bank

Insurance

XML

XML

XML

Client

Page 6: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

6How to Break XML Encryption – Automatically Juraj Somorovsky

Security?

• SSL / TLS: Transport-Level Security

• Messages are only secured during transport

Broker

Bank

Insurance

Client

6

Page 7: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

7How to Break XML Encryption – Automatically Juraj Somorovsky

Motivation – XML Security

• Message Level Security

• Messages protected directly

• XML Security

Broker

Bank

Insurance

Client

7

Page 8: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

8How to Break XML Encryption – Automatically Juraj Somorovsky

• Methods for cryptographic algorithms in XML

• XML Signature: authenticity and integrity

• XML Encryption: confidentiality

• Flexible

8

XML Security

<PaymentInfo>

<Name>John Smith</Name>

<CreditCard Limit='5,000’>

<Number>4019 ...5567</Number>

<Issuer>Example Bank</Issuer>

<Expiration>04/02</Expiration>

</CreditCard>

</PaymentInfo>

Page 9: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

10How to Break XML Encryption – Automatically Juraj Somorovsky

XML Security Areas

• Financial services:

– Electronic Banking Internet

Communication (EBICS)

• Healthcare:

– Australian eHealth Technical Specification

• Governmental services:

– ID cards in Estonia, Germany, Hungary, …

• System integration, firewalls

10

Page 10: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

12How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

12

Page 11: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

13How to Break XML Encryption – Automatically Juraj Somorovsky

Body

MonitorInstances

Id=”body”

Timestamp Id=”Timestamp”

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

URI=”#Timestamp”Reference

DigestValue

DigestValue

XML Signature

Page 12: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

14How to Break XML Encryption – Automatically Juraj Somorovsky

Header

Security

Signature

SignedInfo

Reference URI=”#body”

SignValue

Body

MonitorInstances

Id=”body”

IdInstanceId

Wrapper

Envelope McIntosh, Austel (2005)

Bhargavan, Fournet, Gordon, O’Shea (2005)

Body

MonitorInstances

Id=”body”

IdInstanceId

Body

CreateKeyPair

Id=”attack”

KeyName attackerKey

XML Signature Wrapping / Rewriting

Page 13: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

15How to Break XML Encryption – Automatically Juraj Somorovsky

XML Signature Wrapping

Why does the attack work?

15

Page 14: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

16How to Break XML Encryption – Automatically Juraj Somorovsky

Header

Security

Signature

SignedInfo

Reference URI=”#body”

KeyInfo

Body

MonitorInstances

Id=”body”

IdInstanceId

Wrapper

Envelope

Body

CreateKeyPair

Id=”attack”

KeyName attackerKey

XML Signature Wrapping

Server

Verification logic

Application logic

Page 15: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

17How to Break XML Encryption – Automatically Juraj Somorovsky

Cloud Controller

User

soap

soap

• Attacks on Amazon EC2 / Eucalyptus clouds• Juraj Somorovsky, Mario Heiderich, Meiko Jensen, Jörg Schwenk, Nils

Gruschka, Luigi Lo Iacono: All Your Clouds Are Belong to Us – Security

Analysis of Cloud Management Interfaces - CCSW 2011.

XML Signature Wrapping

17

Page 16: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

19How to Break XML Encryption – Automatically Juraj Somorovsky 19

Further Attacks: SAML

Vladislav Mladenov, Christian Mainka, Florian Feldmann, Julian Krautwald, Jörg

Schwenk: Your Software at my Service, CCSW 2014

XXESignatureWrapping

Page 17: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

20How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

20

Page 18: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

22How to Break XML Encryption – Automatically Juraj Somorovsky 22

XML Encryption

Body

Envelope

Header

Security

EncryptedKey

EncryptionMethod

CipherData

Algorithm=”…#rsa-1_5”

EncryptedData

EncryptionMethod

CipherData

Algorithm=“…#aes128-cbc”

ReferenceList

DataReference URI=“#enc”

Id=“enc”

1

2

Asymmetric encryption / decryption

Symmetric encryption / decryption

Hybrid encryption scheme

Page 19: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

23How to Break XML Encryption – Automatically Juraj Somorovsky

Attacks on XML Encryption

• Attacks on EncryptedKey– Bleichenbacher’s Attack Strikes Again:

Breaking PKCS#1 v1.5 in XML Encryption. Tibor Jager, Sebastian Schinzel, Juraj Somorovsky. ESORICS 2012

• Attacks on EncryptedData– How to Break XML Encryption.

Tibor Jager, Juraj Somorovsky. CCS 2011

23

Body

Envelope

Header

Security

EncryptedKey

EncryptedData

URI=“#enc”

Id=“enc”

Adaptive chosen-ciphertext attacks

Page 20: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

24How to Break XML Encryption – Automatically Juraj Somorovsky 24

Adaptive chosen-ciphertext attack

Client

XML Encryption ciphertext C = Enc(M)

Chosen ciphertext C1

valid/invalid

M = Dec(C)

Web ServiceChosen ciphertext C2

valid/invalid

XML Encryption ciphertext C = Enc(M)

(repeated several times)

Server-Queries 14 / plaintext byte 400k to 82M / key

Encryption symmetric asymmetric

CCS 2011 ESORICS 2012

Page 21: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

25How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

25

Page 22: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

26How to Break XML Encryption – Automatically Juraj Somorovsky 26

Attack Scenario

• What is a “valid” plaintext?

• How to use Web Service as “plaintext validity oracle”?

• How to use this oracle to decrypt C?

XML Encryption ciphertext C = Enc(M)

Chosen ciphertext C1

valid/invalid plaintext

M = Dec(C)

Web ServiceChosen ciphertext C2

valid/invalid plaintext

XML Encryption ciphertext C = Enc(M)

(repeated several times)

Client

Page 23: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

27How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

27

Page 24: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

28How to Break XML Encryption – Automatically Juraj Somorovsky

Plaintext Validity

• XML is a text-based data format

• XML parsing

• Characters (usually) encoded in ASCII

28

Page 25: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

29How to Break XML Encryption – Automatically Juraj Somorovsky 29

ASCII

0x00 NUL 0x20 0x40 @ 0x60 '

0x01 (Type A) 0x21 ! 0x41 A 0x61 a

0x02 (Type A) 0x22 " 0x42 B 0x62 b

0x03 (Type A) 0x23 # 0x43 C 0x63 c

0x04 (Type A) 0x24 $ 0x44 D 0x64 d

0x05 (Type A) 0x25 % 0x45 E 0x65 e

0x06 (Type A) 0x26 & 0x46 F 0x66 f

0x07 BEL 0x27 ' 0x47 G 0x67 g

0x08 BS 0x28 ( 0x48 H 0x68 h

0x09 HT 0x29 ) 0x49 I 0x69 i

0x0A LF 0x2A * 0x4A J 0x6A j

0x0B (Type A) 0x2B + 0x4B K 0x6B k

0x0C (Type A) 0x2C , 0x4C L 0x6C l

0x0D CR 0x2D - 0x4D M 0x6D m

0x0E (Type A) 0x2E . 0x4E N 0x6E n

0x0F (Type A) 0x2F / 0x4F O 0x6F o

0x10 (Type A) 0x30 0 0x50 P 0x70 p

0x11 (Type A) 0x31 1 0x51 Q 0x71 q

0x12 (Type A) 0x32 2 0x52 R 0x72 r

0x13 (Type A) 0x33 3 0x53 S 0x73 s

0x14 (Type A) 0x34 4 0x54 T 0x74 t

0x15 (Type A) 0x35 5 0x55 U 0x75 u

0x16 (Type A) 0x36 6 0x56 V 0x76 v

0x17 (Type A) 0x37 7 0x57 W 0x77 w

0x18 (Type A) 0x38 8 0x58 X 0x78 x

0x19 (Type A) 0x39 9 0x59 Y 0x79 y

0x1A (Type A) 0x3A : 0x5A Z 0x7A z

0x1B ESC 0x3B ; 0x5B [ 0x7B {

0x1C (Type A) 0x3C < 0x5C \ 0x7C |

0x1D (Type A) 0x3D = 0x5D ] 0x7D }

0x1E (Type A) 0x3E > 0x5E ^ 0x7E ~

0x1F (Type A) 0x3F ? 0x5F _ 0x7F DEL

Type A

Type B

Not

Parsable:

Parsable:„Valid“ Plaintext contains onlyType B characters

Page 26: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

30How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

30

Page 27: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

31How to Break XML Encryption – Automatically Juraj Somorovsky

Validity Oracle

• Using Web Services Server as plaintext validity oracle

• Invalid plaintext => Parsing error• Parsing error => Fault message (or another side

channel)

31

Web Service

XML Encryption ciphertext

1) Content Decryption2) XML Parsing3) XML Evaluation

valid/invalid plaintext

Page 28: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

32How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

32

Page 29: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

33How to Break XML Encryption – Automatically Juraj Somorovsky

Consider ASCII character M1 = (0,b1,b

2,b

3,b

4,b

5,b

6,b

7)

0x00 NUL 0x20 0x40 @ 0x60 '

0x01 (Type A) 0x21 ! 0x41 A 0x61 a

0x02 (Type A) 0x22 " 0x42 B 0x62 b

0x03 (Type A) 0x23 # 0x43 C 0x63 c

0x04 (Type A) 0x24 $ 0x44 D 0x64 d

0x05 (Type A) 0x25 % 0x45 E 0x65 e

0x06 (Type A) 0x26 & 0x46 F 0x66 f

0x07 BEL 0x27 ' 0x47 G 0x67 g

0x08 BS 0x28 ( 0x48 H 0x68 h

0x09 HT 0x29 ) 0x49 I 0x69 i

0x0A LF 0x2A * 0x4A J 0x6A j

0x0B (Type A) 0x2B + 0x4B K 0x6B k

0x0C (Type A) 0x2C , 0x4C L 0x6C l

0x0D CR 0x2D - 0x4D M 0x6D m

0x0E (Type A) 0x2E . 0x4E N 0x6E n

0x0F (Type A) 0x2F / 0x4F O 0x6F o

0x10 (Type A) 0x30 0 0x50 P 0x70 p

0x11 (Type A) 0x31 1 0x51 Q 0x71 q

0x12 (Type A) 0x32 2 0x52 R 0x72 r

0x13 (Type A) 0x33 3 0x53 S 0x73 s

0x14 (Type A) 0x34 4 0x54 T 0x74 t

0x15 (Type A) 0x35 5 0x55 U 0x75 u

0x16 (Type A) 0x36 6 0x56 V 0x76 v

0x17 (Type A) 0x37 7 0x57 W 0x77 w

0x18 (Type A) 0x38 8 0x58 X 0x78 x

0x19 (Type A) 0x39 9 0x59 Y 0x79 y

0x1A (Type A) 0x3A : 0x5A Z 0x7A z

0x1B ESC 0x3B ; 0x5B [ 0x7B {

0x1C (Type A) 0x3C < 0x5C \ 0x7C |

0x1D (Type A) 0x3D = 0x5D ] 0x7D }

0x1E (Type A) 0x3E > 0x5E ^ 0x7E ~

0x1F (Type A) 0x3F ? 0x5F _ 0x7F DEL

Type A

Type B

33

Page 30: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

34How to Break XML Encryption – Automatically Juraj Somorovsky

Decrypting by checking plaintext validity

• ASCII exhibits nice pattern of Type A/B characters

• Suppose we can flip arbitrary plaintext bits and use a plaintext validity oracle

• What could go wrong?

34

Page 31: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

35How to Break XML Encryption – Automatically Juraj Somorovsky

Decrypting by checking plaintext validity

• Example

• We have eavesdropped a ciphertextC = Enc(“Deepsec”)

• How to determine (b1,b2) of M1 = “D”?

Page 32: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

36How to Break XML Encryption – Automatically Juraj Somorovsky

Consider ASCII character M1 = (0,b1,b

2,b

3,b

4,b

5,b

6,b

7)

0x00 NUL 0x20 0x40 @ 0x60 '

0x01 (Type A) 0x21 ! 0x41 A 0x61 a

0x02 (Type A) 0x22 " 0x42 B 0x62 b

0x03 (Type A) 0x23 # 0x43 C 0x63 c

0x04 (Type A) 0x24 $ 0x44 D 0x64 d

0x05 (Type A) 0x25 % 0x45 E 0x65 e

0x06 (Type A) 0x26 & 0x46 F 0x66 f

0x07 BEL 0x27 ' 0x47 G 0x67 g

0x08 BS 0x28 ( 0x48 H 0x68 h

0x09 HT 0x29 ) 0x49 I 0x69 i

0x0A LF 0x2A * 0x4A J 0x6A j

0x0B (Type A) 0x2B + 0x4B K 0x6B k

0x0C (Type A) 0x2C , 0x4C L 0x6C l

0x0D CR 0x2D - 0x4D M 0x6D m

0x0E (Type A) 0x2E . 0x4E N 0x6E n

0x0F (Type A) 0x2F / 0x4F O 0x6F o

0x10 (Type A) 0x30 0 0x50 P 0x70 p

0x11 (Type A) 0x31 1 0x51 Q 0x71 q

0x12 (Type A) 0x32 2 0x52 R 0x72 r

0x13 (Type A) 0x33 3 0x53 S 0x73 s

0x14 (Type A) 0x34 4 0x54 T 0x74 t

0x15 (Type A) 0x35 5 0x55 U 0x75 u

0x16 (Type A) 0x36 6 0x56 V 0x76 v

0x17 (Type A) 0x37 7 0x57 W 0x77 w

0x18 (Type A) 0x38 8 0x58 X 0x78 x

0x19 (Type A) 0x39 9 0x59 Y 0x79 y

0x1A (Type A) 0x3A : 0x5A Z 0x7A z

0x1B ESC 0x3B ; 0x5B [ 0x7B {

0x1C (Type A) 0x3C < 0x5C \ 0x7C |

0x1D (Type A) 0x3D = 0x5D ] 0x7D }

0x1E (Type A) 0x3E > 0x5E ^ 0x7E ~

0x1F (Type A) 0x3F ? 0x5F _ 0x7F DEL

Type A

Type B

36 36

Page 33: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

37How to Break XML Encryption – Automatically Juraj Somorovsky

Consider ASCII character M1 = (0,b1,b

2,b

3,b

4,b

5,b

6,b

7)

0x00 NUL 0x20 0x40 @ 0x60 '

0x01 (Type A) 0x21 ! 0x41 A 0x61 a

0x02 (Type A) 0x22 " 0x42 B 0x62 b

0x03 (Type A) 0x23 # 0x43 C 0x63 c

0x04 (Type A) 0x24 $ 0x44 D 0x64 d

0x05 (Type A) 0x25 % 0x45 E 0x65 e

0x06 (Type A) 0x26 & 0x46 F 0x66 f

0x07 BEL 0x27 ' 0x47 G 0x67 g

0x08 BS 0x28 ( 0x48 H 0x68 h

0x09 HT 0x29 ) 0x49 I 0x69 i

0x0A LF 0x2A * 0x4A J 0x6A j

0x0B (Type A) 0x2B + 0x4B K 0x6B k

0x0C (Type A) 0x2C , 0x4C L 0x6C l

0x0D CR 0x2D - 0x4D M 0x6D m

0x0E (Type A) 0x2E . 0x4E N 0x6E n

0x0F (Type A) 0x2F / 0x4F O 0x6F o

0x10 (Type A) 0x30 0 0x50 P 0x70 p

0x11 (Type A) 0x31 1 0x51 Q 0x71 q

0x12 (Type A) 0x32 2 0x52 R 0x72 r

0x13 (Type A) 0x33 3 0x53 S 0x73 s

0x14 (Type A) 0x34 4 0x54 T 0x74 t

0x15 (Type A) 0x35 5 0x55 U 0x75 u

0x16 (Type A) 0x36 6 0x56 V 0x76 v

0x17 (Type A) 0x37 7 0x57 W 0x77 w

0x18 (Type A) 0x38 8 0x58 X 0x78 x

0x19 (Type A) 0x39 9 0x59 Y 0x79 y

0x1A (Type A) 0x3A : 0x5A Z 0x7A z

0x1B ESC 0x3B ; 0x5B [ 0x7B {

0x1C (Type A) 0x3C < 0x5C \ 0x7C |

0x1D (Type A) 0x3D = 0x5D ] 0x7D }

0x1E (Type A) 0x3E > 0x5E ^ 0x7E ~

0x1F (Type A) 0x3F ? 0x5F _ 0x7F DEL

Type A

Type B

37 37

Page 34: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

38How to Break XML Encryption – Automatically Juraj Somorovsky

Performance

• 14 queries / byte

38

Page 35: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

39How to Break XML Encryption – Automatically Juraj Somorovsky 39

Why Flipping Possible?

Page 36: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

40How to Break XML Encryption – Automatically Juraj Somorovsky

Cipher Block Chaining Mode

• Flip arbitrary bits in plaintext• Applied in padding oracle attacks

40

Initialization Vector (IV)

...

Ciphertext Block 1

AESKey

Ciphertext:

Plaintext:

CBC decryption

Page 37: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

41How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

41

Page 38: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

42How to Break XML Encryption – Automatically Juraj Somorovsky

Basic Idea

• Protect integrity and authenticity ofciphertexts

• Not easy…

42

Page 39: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

44How to Break XML Encryption – Automatically Juraj Somorovsky 44

XML Signature Wrapping?

Body Id=”attacked”

Envelope

Header

Security

Signature

Reference URI=”#body”

EncryptedKey

DataReference URI=“#oracle”

EncryptedData Id=“oracle”

CipherData

Body Id=”body”

EncryptedData Id=“enc”

CipherDataSignature validation

DecryptionBody Id=”body”

EncryptedData Id=“enc”

CipherData

Page 40: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

45How to Break XML Encryption – Automatically Juraj Somorovsky 45

XML Encryption Wrapping?

Body Id=”body”

Envelope

Header

Security

Signature

Reference URI=”#body”

EncryptedKey

DataReference URI=“#enc”

EncryptedData Id=“enc”

CipherData

EncryptedData Id=“oracle”

CipherData

EncryptedKey

DataReference URI=“#oracle”

Signature validation

Decryption

Business logicDecryption and

Page 41: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

46How to Break XML Encryption – Automatically Juraj Somorovsky

How to analyze Web Services Automatically?

Page 42: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

47How to Break XML Encryption – Automatically Juraj Somorovsky

1. What is a Web Service and XML Security

2. XML Signature Wrapping

3. Attacks on XML Encryption

4. Attacks on Symmetric Encryption Scheme

1. Attack Scenario

2. Plaintext Validity

3. Using Web Service for Plaintext Validation

4. Decrypting by Checking Plaintext Validity

5. Countermeasures and Problems

6. WS-Attacker

Overview

47

Page 43: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

48How to Break XML Encryption – Automatically Juraj Somorovsky

WS-Attacker

48

• Automatic penetration test tool for Web Services

• https://github.com/RUB-NDS/WS-Attacker

• Supports many attacks

– New plugin for XML Encryption

• Approach:

1. Analyze message security

2. Remove signature protection

3. Attack (symmetric / asymmetric)

Page 44: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

49How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase Avoid Phase Attack Phase

49

Automated Attack Workflow

IdentifySecurity

Elements

Encrypted

XML

Page 45: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

50How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase (Offline)

Body

Envelope

Header

Security

EncryptedKey

EncryptedData

URI=“#a”

Id=“a”

Signature URI=“#b”

Signature URI=“#c”

Timestamp Id=“c”

Id=“b”

50

Page 46: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

51How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase Avoid Phase Attack Phase

51

Automated Attack Workflow

Knowledge Pool

IdentifySecurity

Elements

SignedTimestamp?

Encrypted

XML

Page 47: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

52How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase (Offline)

Body

Envelope

Header

Security

EncryptedKey

EncryptedData

URI=“#a”

Id=“a”

Signature URI=“#b”

Signature URI=“#c”

Timestamp Id=“c”

Id=“b”

52

Page 48: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

53How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase Avoid Phase Attack Phase

53

Automated Attack Workflow

Knowledge Pool

IdentifySecurity

Elements

SignedTimestamp?

XSW

no

yes

Encrypted

XML

Page 49: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

54How to Break XML Encryption – Automatically Juraj SomorovskyN

oA

ttribu

te

Position 1

Applying XSW - Complexity

54

Body

getServerTime

Id=”body”

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

DigestValue

KeyInfo

Body

getServerTime

Id=”body”

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

DigestValue

KeyInfo

Body

getServerTime

Id=”body”

getAdminConfig

Id=“atk”

Body

getServerTime

Id=”body”

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

DigestValue

KeyInfo

Body

getServerTime

Id=”body”

getAdminConfig

Id=“atk”Body

getServerTime

Id=”body”

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

DigestValue

KeyInfo

Body

getServerTime

Id=”body”

getAdminConfig

Id=“atk”Body

getServerTime

Id=”body”

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

DigestValue

KeyInfo

Body

getServerTime

Id=”body”

getAdminConfig

Id=“body”Body

getServerTime

SignatureValue

Envelope

Header

Security

Signature

SignedInfo

Reference URI=”#body”

DigestValue

KeyInfo

Body

getServerTime

Id=”body”

getAdminConfig

Page 50: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

55How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase Avoid Phase Detection Phase

55

Automated Attack Workflow

Knowledge Pool

IdentifySecurity

Elements

SignedTimestamp?

XSW

SignedEncryptedElement

XSW

XEW

no no

yes yes

fail

fail

IdentifyOracle

yes

no

Encrypted

XML

Page 51: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

56How to Break XML Encryption – Automatically Juraj Somorovsky

Web Service

Identify Oracle

• Map Server Responses to „valid“ or „invalid“

• Implementation dependent!

56

XML Encryption ciphertext C

= Enc(M)Chosen ciphertext

<ok/>

Chosen ciphertext

<failure/>

Page 52: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

57How to Break XML Encryption – Automatically Juraj Somorovsky

Detection Phase Avoid Phase Attack Phase

57

Automated Attack Workflow

Knowledge Pool

IdentifySecurity

Elements

SignedTimestamp?

XSW

SignedEncryptedElement

XSW

XEW

IdentifyOracle

Apply Attackno no

yes yes

fail

fail

Decrypted

XML

yes

no

yes

fail

Encrypted

XML

Page 53: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

58How to Break XML Encryption – Automatically Juraj Somorovsky

Results

System Asymmetric Attack Symmetric Attack Countermeasures applicable?

Apache Axis2 1.6.2

Apache CXF 2.7.10 yes

Axway Gateway 7.3.1 yes

IBM Datapower XI50 yes

Microsoft WCF yes

58

Page 54: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

59How to Break XML Encryption – Automatically Juraj Somorovsky

Load WSDL

59

Page 55: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

60How to Break XML Encryption – Automatically Juraj Somorovsky

Send Test Request

60

Page 56: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

61How to Break XML Encryption – Automatically Juraj Somorovsky

Choose Attacks

61

Page 57: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

62How to Break XML Encryption – Automatically Juraj Somorovsky

Configure XML Encryption

Page 58: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

63How to Break XML Encryption – Automatically Juraj Somorovsky

Start Attack

63

Page 59: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

64How to Break XML Encryption – Automatically Juraj Somorovsky 64

Case Apache CXF

Body

Envelope

Header

Security

EncryptedKey

EncryptionMethod

CipherData

#rsa-1_5

EncryptedData

EncryptionMethod

CipherData

#aes128-cbc

1

2

Asymmetric decryption

Symmetric decryption

CVE-2015-0226

CVE-2015-0227

k

Page 60: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

65How to Break XML Encryption – Automatically Juraj Somorovsky 65

Case Apache CXF: Symmetric

Body

Envelope

Header

Security

EncryptedKey

EncryptionMethod

CipherData

#rsa-1_5

EncryptedData

EncryptionMethod

CipherData

#aes128-cbc2 Symmetric decryption

CVE-2015-0226

CVE-2015-0227

Signature enforced with: requireSignedEncryptedDataElements = "true" Signature Wrapping

Page 61: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

66How to Break XML Encryption – Automatically Juraj Somorovsky 66

Case Apache CXF: Asymmetric

Body

Envelope

Header

Security

EncryptedKey

EncryptionMethod

CipherData

#rsa-1_5

EncryptedData

EncryptionMethod

CipherData

#aes128-cbc

1

2

Asymmetric decryption

Symmetric decryption

CVE-2015-0226

CVE-2015-0227

k

Side Channel

Page 62: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

67How to Break XML Encryption – Automatically Juraj Somorovsky 67

Case Apache CXF: Asymmetric

Body

Envelope

Header

Security

EncryptedKey

EncryptionMethod

CipherData

#rsa-1_5

EncryptedData

EncryptionMethod

CipherData

#aes128-cbc

1 Asymmetric decryption

CVE-2015-0226

CVE-2015-0227

k random

(128 bits)

128 bytes

Invalid countermeasure

Page 63: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

68How to Break XML Encryption – Automatically Juraj Somorovsky

Playing with WS-Attacker

• https://github.com/RUB-NDS/WS-Attacker

• Use Apache Axis2 and Apache Rampart

• Examples:

– http://web-in-security.blogspot.de/

68

Page 64: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

69How to Break XML Encryption – Automatically Juraj Somorovsky

Countermeasures

• AES-CBC, RSA-PKCS#1 v1.5 insecure!

• XML Encryption updated (Version 1.1)

• AES-GCM added

• Use of secure algorithms: RSA-OAEP, AES-GCM

• If secure algorithms not available, only decryptsigned XML ciphertexts

• Example: IBM Datapower

Page 65: How to Break XML Encryption Automatically€¦ · How to Break XML Encryption –Automatically Juraj Somorovsky 33 Consider ASCII character M 1 = (0,b 1,b 2,b 3,b 4,b 5,b 6,b 7) 0x00

71How to Break XML Encryption – Automatically Juraj Somorovsky

Conclusion

• XML – especially XML Security – is complex

• WS-Attacker for evaluation:

– https://github.com/RUB-NDS/WS-Attacker

• Our approach applicable to other scenarios

– SAML, JSON, Web Crypto…

• Prefer authenticated encryption (AES-GCM instead of AES-CBC)

71