51
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP Foundation http://www.owasp.org Sécurité des Web Services (SOAP vs REST) Sylvain MARET Principal Consultant / MARET Consulting / @smaret OpenID Switzerland & OWASP Switzerland 05/06.11.2012, Version 1.1 @smaret

Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Embed Size (px)

Citation preview

Page 1: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License.

The OWASP Foundation http://www.owasp.org

Sécurité des Web Services (SOAP vs REST)

Sylvain MARET

Principal Consultant / MARET Consulting / @smaret

OpenID Switzerland & OWASP Switzerland

05/06.11.2012, Version 1.1 @smaret

Page 2: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

2

Page 3: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Bio

• 18 years of experience in ICT Security

• Principal Consultant at MARET Consulting

• Expert & Lecturer at University of Applied Sciences (Yverdon)

• Swiss French Area delegate at OpenID Switzerland

• Co-founder Application Security Forum #ASFWS

• OWASP Member

• Author of the blog: la Citadelle Electronique

• http://ch.linkedin.com/in/smaret or @smaret

• http://www.slideshare.net/smaret

• Chosen field – AppSec / Digital Identity Security / Cyber Defense

3

Page 4: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

4

Page 5: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Web Service ?

5

XML, JSON, etc. Consumer Provider

Page 6: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Un peu d’histoire

• 1990 : DCE/RPC – Distributed Computing Environment

• 1992 : CORBA – Common Object Request Broker Architecture

• 1990-1993 : Microsoft’s DCOM -- Distributed Component Object Model

• 1995: RMI – Monde Java

• Pour arriver à une standardisation (toujours en cours) des protocoles, outils, langages et interfaces

– SOAP

– REST

– Etc.

6

Web Service

Page 7: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Typical Web Services environment

7 Source: Mastering Web Services Security / www.wiley.com

Page 8: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

8

Page 9: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

SOAP: Démystification des technologies

• Langages

– XML

– WSDL : Descripteur du service

– UDDI: Annuaire des services

– Xpath

• Protocoles

– Transport: HTTP, HTTPS, SMTP, FTP, SMS, TFTP, SSH, etc. (TCP or UDP)

– Message: Enveloppe SOAP

• Sécurité

– WS-Security (Signature & Chiffrement)

• Autres éléments

– AuthN: SAML, X509, Username & Password, Kerberos, HTTP Digest, etc.

9

Page 10: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Enveloppe SOAP

10

- SOAP : Simple Object Access Protocol - Permet l’envoi de messages XML

Source= wikipédia

Page 11: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

11

SOAP request

SOAP response

Page 12: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

UDDI

• Universal Description Discovery and Integration, connu aussi sous l'acronyme UDDI, est un annuaire de services fondé sur XML et plus particulièrement destiné aux services Web.

12

Page 13: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

WSDL

• WSDL est une grammaire XML permettant de décrire un Service Web.

• Le WSDL sert à décrire : – le format de messages requis pour communiquer avec ce

service

– les méthodes que le client peut invoquer

– la localisation du service

– le protocole de communication (SOAP RPC ou SOAP orienté message)

13

http://fr.wikipedia.org/wiki/Web_Services_Description_Language

Page 15: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

WSDL: exemple

15

Page 16: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

SOAP: Démystification des protocoles

16

UDDI

WSDL

SOAP / XML

HTTP, HTTPS, FTP, SFTP, SMS, SMTP (TCP or UDP)

IP

Découverte

Description

Message

Protocole

Transport

Page 17: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

17

Page 18: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

REST: Démystification des technologies

• Langages

– XML

– JSON

– XHTML, HTML, PDF... as data formats

• Protocoles

– HTTP(s) Utilisation d’une URL

– Méthode de communication (GET, POST, PUT, DELETE)

• Sécurité

– Sécurité du transport (SSL/TLS)

– Sécurité des messages: HMAC / Doseta / JWS, etc. (Like XML Signature)

• Autres éléments

– Oauth, API Keys, etc.

18

Page 19: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Représentation REST (exemple JSON)

19

Page 20: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Méthodes REST

20

Page 21: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

REST: Démystification des protocoles

21

XML, JSON, etc.

HTTP, HTTPS

TCP/IP

Message

Protocole

Transport

WADL, Swagger *** Description

*** Avant-gardiste!

??? Découverte

Page 22: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Example

22

Page 23: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Example Twitter (OAuth)

23

Page 24: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

24

Page 25: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

SOAP vs REST

25

Page 26: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

26

Page 27: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

27 http://fr.wikipedia.org/wiki/Diagramme_de_flux_de_donn%C3%A9es

Page 28: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

28

Page 29: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Modèle STRIDE

29

https://www.owasp.org/index.php/Application_Threat_Modeling

Page 30: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Menaces - DFD Acme SA

• Threat 1 – Interception des messages (Information disclosure)

– Modification des messages (Tampering)

– Usurpation d’identité (Spoofing)

• Threat 2 – Attaque de l’application

• BoF

• Injection

• DoS & DDoS

• Etc

30

Page 31: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

31

Page 32: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

ACME SA: Réduction des risques ?

• Chiffrement du transport

• AuthN

• SSL Mutual AuthN / X509

• WAF / XML Gateway

• Intégrité et confidentialité des messages

• Secure Coding

32

Page 33: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Chiffrement du transport

33

SOAP / XML REST

HTTPS SSL/TLS tunnel SSH IPSEC Etc.

HTTPS

Page 34: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

AuthN

34

SOAP / XML REST

HTTP Basic, Digest, HTTP Header Mutual SSL IP trust WS Security user name password WS SAML Authentication token XML Signature Kerberos Etc.

HTTP Basic, Digest, HTTP Header Mutual SSL IP trust Oauth API Keys JSON Web Token (JWT)

Page 35: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

SSL Mutual AuthN / X509 / PKI

35

SOAP / XML REST

SSL/TLS Mutual AuthN** SSL/TLS Mutual AuthN**

** Man in the middle not possible… (As I Know)

Page 36: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

WAF / XML Gateway (Protection périmétrique)

36

SOAP / XML REST

Reverse Proxy Contrôle requêtes HTTP Rupture SSL/TLS Black List White List Validation WSDL Signature & Verification Encryption & Decryption SAML

Reverse Proxy Contrôle requêtes HTTP Rupture SSL/TLS Black List White List

Page 38: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Example XML Signature (SOAP)

38

Page 39: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Example JSON “Signature”

39

Page 40: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Code security

40

SOAP / XML REST

- Data input validation - Data output encoding - Pseudorandom data generation, high entropy - Strong / reliable data encryption algorithms - Data leakage prevention - Robust error & exception handling - Anti-automation and expiration measures

- Data input validation - Data output encoding - Pseudorandom data generation, high entropy - Strong / reliable data encryption algorithms - Data leakage prevention - Robust error & exception handling - Anti-automation and expiration measures

OWASP Application Security Verification Standard (ASVS): https://www.owasp.org/index.php/ASVS WASC web application weaknesses: http://projects.webappsec.org/w/page/13246978/Threat%20Classification

Page 41: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Agenda

• Qu’est-ce qu’un Web Service ?

• SOAP

• REST

• Threat Modeling / ACME SA

• Réduction des risques

• Conclusion

• Questions

41

Page 42: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Conclusion

• SOAP: – Implémenter les standards WS-* liés à la sécurité?

– Mettre en place un filtrage applicatif (WAF, XML GW)

– Complexe à mettre en œuvre (PKI, Secure coding, Cryptography, etc.)

– Architecture à forte contrainte de sécurité

• REST – Mettre en place un filtrage applicatif (WAF, XML GW)

– Implémentation rapide et facile tendance

– Architecture de type Cloud, Intranet, Social Login, etc.

– Emergence des standards (JSON Web Algorithms)

• On attend avec impatience les standards sécu pour REST ???

– Pragmatique: protection périmétrique, chiffrement et Secure Coding ???

42

Page 43: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Approche périmétrique vs WS-Security ?

43

Page 44: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Questions?

44

Page 45: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Merci / Thank you!

Contact:

[email protected]

@smaret

http://www.maret-consulting.ch

Slides: http://slideshare.net/ASF-WS/

45

Page 46: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License.

The OWASP Foundation http://www.owasp.org

46

Backup Slides

By Sylvain Maret

Page 47: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

47

Page 48: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

SoapBox

48

Page 49: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Capture HTTP

49

Page 50: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Signer le message

50

Page 51: Securite des Web Services (SOAP vs REST) / OWASP Geneva dec. 2012

Signer le message

51