SlideShare una empresa de Scribd logo
1 de 43
Descargar para leer sin conexión
You want your apps to be safe?
Hack yourselves!
Isabelle Mauny - 42Crunch
Madrid | November 30 - December 1, 2018
ISABELLE@42CRUNCH.COM
OWASP : FROM 2010 THROUGH 2017
2
TOP 10 2010
A1: Injection
A2: Cross-Site Scripting (XSS)
A3: Broken Authentication and Session Management
A4: Insecure Direct Object References
A5: Cross-Site Request Forgery (CSRF)
A6: Security Misconfiguration
A7: Insecure Cryptographic Storage
A8: Failure to Restrict URL Access
A9: Insufficient Transport Layer Protection
A10: Unvalidated Redirects and Forwards
Top 10 2017
A1: Injection*
A2: Broken Authentication*
A3: Sensitive Data Exposure*
A4: XML External Entities (XXE)*
A5: Broken Access Control*
A6: Security Misconfiguration*
A7: Cross-Site Scripting (XSS)*
A8: Insecure Deserialization*
A9: Using Components with Known Vulnerabilities*
A10: Insufficient Logging&Monitoring*
* APPLIES TO APIs!
LET’S LOOK AT A
BROKEN APP
3
4
NOT ONLY IN
DEMOS…
5
BROKEN AUTHENTICATION (A2)
6
I am not advertising this API,
how could anyone know about it ?!
https://motherboard.vice.com/en_us/article/598xaa/remini-app-exposed-childrens-data-open-api
7
Information Leakage (A3)
Broken Access Control (A5)
Check: https://www1.cs.fau.de/filepool/
projects/n26/n26-roots.pdf
Watch video at: https://media.ccc.de/v/
33c3-7969-shut_up_and_take_my_money
N26 CONTINUED…
8
9
Failed to properly validate that you
can’t input any other number than
yours!
TITLE TEXT
Remote Command Execution (A1)
SQL Injection (A1)
JSON injection (A1)
Information Leakage (A3)
Broken Access Control (A5)
Check: https://blog.talosintelligence.com/2018/07/
samsung-smartthings-vulns.html
10
11https://www.talosintelligence.com/reports/TALOS-2018-0539/
UNPROTECTED API ! (A6)
Remote Command Execution
SQL Injection
Buffer Overflow
JSON injection
Information Leakage
Check: https://blog.talosintelligence.com/2018/07/samsung-
smartthings-vulns.html
12https://ninja.style/post/bcard/
AND OF COURSE …. EQUIFAX FOR A9
13
WHY IS THIS
HAPPENING?
14
WE ARE
HUMANS!
15
16
TITLE TEXTDIGITAL TRANSFORMATION MADNESS….
17
APPLICATION

DEVELOPMENT
APPLICATION

SECURITY
CONTROLLER LAYER IS GONE!
18Internal Applications Legacy Systems Databases
Integration
Layer
Technical and
Functional
(micro)Services
SaaS Applications
Things
App-level
APIs
TITLE TEXTHOW SECURITY PEOPLE FEEL ABOUT APIS
19
YOU GOT
THE
POWER!
20
LETS COVER THE
BASICS…
21
22
KNOW YOUR
APIS
23
1
See: https://www.owasp.org/index.php/Application_Threat_Modeling
OPEN BANKING SAMPLE CATEGORISATION
24
API Category Data Sensitivity
Operations
Sensitivity
Authentication
Requirements
Integrity
Requirement
ATMs OpenData Low Low None None
Accounts Read High Medium Medium Required
Payments Write High High High Required
VALIDATE AND
SANITIZE INPUT
25
URL validation
Verb validation
✓ Reject if not valid
Query params validation
✓ Min / Max / Pattern-based matching
Content-Type validation
✓ Don’t accept as-is!
Accept Header validation
✓ Don’t copy into Content-Type
Data inbound
✓ Format
✓ Message Size and complexity
Data outbound
✓ Data Leakage
✓ Exception Leakage
✓ Use rules against data dictionary
2
OPENAPI SPECIFICATION to the RESCUE !
USE OAUTH
PROPERLY
26
OAuth Grant Types
✓ Authorization Code
✓ Others are usually not the safe option.
Do not use OAuth as proof of authentication, use
OpenID Connect instead.
Leverage PKCE
3
OPENAPI SPECIFICATION to the RESCUE !
OAUTH THREAT LANDSCAPE
Sensitive information
✓ Access tokens: the key to open the API door
✓ Refresh tokens: the key to obtain many valid access tokens
✓ Authorization code : to obtain an access token
✓ State : protection against CSRF attacks
Common attacks vectors
✓ Token leakage g TLS 1.2 + strong ciphers, short-lived, token binding, protected storage
✓ Code Interception attacks g Use PKCE (Proof Key for Code Exchange)
✓ Token replay g Token Binding (over TLS) or Mutual TLS for OAuth
✓ Redirect URI Forgery g standard CRSF attacks countermeasures (OWASP)
REQUIRES PROTECTION MEASURES ON CLIENT AND SERVER SIDE
27
VALIDATE JSON
WEB TOKENS
28
Don’t trust the incoming tokens!
Client could have been compromised…
Validate algorithm (the one you chose!)
✓ HS256
✓ RS256 (recommended)
Reject None!
Validate signature
✓ Prefer digital signatures over HMAC
✓ If not, be careful of key exchange
Validate standard claims and your own claims
See details Learn the best practices for keeping your JWTs secure.
4
OPENAPI SPECIFICATION (AGAIN) to the RESCUE !
EXTERNAL/ PUBLIC VS INTERNAL TOKENS
29
Token Server
Validate/
Issue token
FINE-GRAIN
AUTHORIZATION
30
Who is calling ?
✓ Is it your own app ?
✓ Is it a trusted user ?
What can they do ?
OAuth Scopes are often not enough !
✓ Need Attributes-based Access Control (ABAC)
solution (XACML!)
5
FINDING
VULNERABILITIES
31
START EARLY: SHIFT LEFT !
32
DeploymentTestingDevelopmentDesign
33
Development
Security
Operations
Business
COVER THE
BASICS
34
Use Trusted Libraries
Don’t re-invent the wheel!
Automated Analysis
Static code analysis
3rd party libraries validation (CVEs), e.g.
NPS / Snyk for Node.js
GitHub dependencies graph
Manual Analysis
Code reviews
1
35
https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5
36
HACK
YOURSELVES!
37
API Scanning/Fuzzing
✓ Veracode, Coverity
✓ 42Crunch (coming soon!)
Transport analysis
✓ SSL Labs
✓ Hardenize
Further Analysis
✓ Bug Bounty
✓ Pen Testing
2
38
PROTECT YOUR
APIS
3
Protect all APIs ( public, private, SaaS)
AUTOMATICALLY deploy security measures
such as API Security Gateways/Firewalls
✓ Enforce Rate Limiting
• Brute force attacks (see N26!)
• DOS attacks
✓ Data Validation / JWT Validation / Auth / Azn
✓ Serves as Virtual Patching (as a WAF does for applications)
✓ Deploy at the edge and/or close to APIs (microservices
architecture)
Use Development ticketing system for
tracking issues
Analyse runtime behaviour and raise
issues automatically
39
MONITOR AND
ANALYZE
4
JOIN THE MAILING LIST !
APISECURITY.IO
REGISTER AND LEARN FROM MORE STORIES!
RESOURCES
41
RESOURCES
OWASP Top 10
✓ https://www.owasp.org/index.php/Category:OWASP_Top_Ten_2017_Project
OWASP DevSlop Project
✓ https://www.owasp.org/index.php/OWASP_DevSlop_Project
Chaos Engineering
✓ http://principlesofchaos.org
✓ https://github.com/dastergon/awesome-chaos-engineering
OWASP ZAP
✓ https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project
Source Code Analysis
✓ https://www.owasp.org/index.php/Source_Code_Analysis_Tools
Code Security reviews
✓ https://www.owasp.org/index.php/Code_Review_Introduction
Systems Scans
✓ https://www.owasp.org/index.php/Category:Vulnerability_Scanning_Tools
Security Methodology
✓ https://developer.rackspace.com/blog/fanatical-security-delivered-by-quality-engineering-security-team/ 42
RESOURCES
SSL Setup Scan
✓ https://hardenize.com
✓ https://securityheaders.io
✓ https://www.ssllabs.com/ssltest/
Threat Modelling
✓ https://www.owasp.org/index.php/Application_Threat_Modeling
Attacks Type Information
✓ XSS: https://excess-xss.com
✓ Buffer Overflow: https://www.youtube.com/watch?v=1S0aBV-Waeo
✓ SQL injection: https://www.youtube.com/watch?v=ciNHn38EyRc
✓ Cookie stealing /XSS: https://www.youtube.com/watch?v=T1QEs3mdJoc
Pixi / DevSlop
✓ https://github.com/DevSlop/Pixi
✓ https://devslop.co
JWT as session data
✓ https://dzone.com/articles/stop-using-jwts-as-session-tokens
Node JS Security recommendations
✓ https://medium.com/@nodepractices/were-under-attack-23-node-js-security-best-practices-e33c146cb87d
43

Más contenido relacionado

Más de Codemotion

Más de Codemotion (20)

Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
 
Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019
Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019
Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019
 
Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019
Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019
Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019
 
Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019
Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019
Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019
 
Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019
Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019
Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019
 
Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019
Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019
Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019
 
Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019
Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019
Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019
 
Andreea Marin - Our journey into Cassandra performance optimisation -
Andreea Marin - Our journey into Cassandra performance optimisation -Andreea Marin - Our journey into Cassandra performance optimisation -
Andreea Marin - Our journey into Cassandra performance optimisation -
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Isabelle Mauny | You want your apps to be safe? Hack yourselves! | Codemotion Madrid 2018

  • 1. You want your apps to be safe? Hack yourselves! Isabelle Mauny - 42Crunch Madrid | November 30 - December 1, 2018 ISABELLE@42CRUNCH.COM
  • 2. OWASP : FROM 2010 THROUGH 2017 2 TOP 10 2010 A1: Injection A2: Cross-Site Scripting (XSS) A3: Broken Authentication and Session Management A4: Insecure Direct Object References A5: Cross-Site Request Forgery (CSRF) A6: Security Misconfiguration A7: Insecure Cryptographic Storage A8: Failure to Restrict URL Access A9: Insufficient Transport Layer Protection A10: Unvalidated Redirects and Forwards Top 10 2017 A1: Injection* A2: Broken Authentication* A3: Sensitive Data Exposure* A4: XML External Entities (XXE)* A5: Broken Access Control* A6: Security Misconfiguration* A7: Cross-Site Scripting (XSS)* A8: Insecure Deserialization* A9: Using Components with Known Vulnerabilities* A10: Insufficient Logging&Monitoring* * APPLIES TO APIs!
  • 3. LET’S LOOK AT A BROKEN APP 3
  • 4. 4
  • 6. BROKEN AUTHENTICATION (A2) 6 I am not advertising this API, how could anyone know about it ?! https://motherboard.vice.com/en_us/article/598xaa/remini-app-exposed-childrens-data-open-api
  • 7. 7 Information Leakage (A3) Broken Access Control (A5) Check: https://www1.cs.fau.de/filepool/ projects/n26/n26-roots.pdf Watch video at: https://media.ccc.de/v/ 33c3-7969-shut_up_and_take_my_money
  • 9. 9 Failed to properly validate that you can’t input any other number than yours!
  • 10. TITLE TEXT Remote Command Execution (A1) SQL Injection (A1) JSON injection (A1) Information Leakage (A3) Broken Access Control (A5) Check: https://blog.talosintelligence.com/2018/07/ samsung-smartthings-vulns.html 10
  • 12. UNPROTECTED API ! (A6) Remote Command Execution SQL Injection Buffer Overflow JSON injection Information Leakage Check: https://blog.talosintelligence.com/2018/07/samsung- smartthings-vulns.html 12https://ninja.style/post/bcard/
  • 13. AND OF COURSE …. EQUIFAX FOR A9 13
  • 16. 16
  • 17. TITLE TEXTDIGITAL TRANSFORMATION MADNESS…. 17 APPLICATION
 DEVELOPMENT APPLICATION
 SECURITY
  • 18. CONTROLLER LAYER IS GONE! 18Internal Applications Legacy Systems Databases Integration Layer Technical and Functional (micro)Services SaaS Applications Things App-level APIs
  • 19. TITLE TEXTHOW SECURITY PEOPLE FEEL ABOUT APIS 19
  • 22. 22
  • 24. OPEN BANKING SAMPLE CATEGORISATION 24 API Category Data Sensitivity Operations Sensitivity Authentication Requirements Integrity Requirement ATMs OpenData Low Low None None Accounts Read High Medium Medium Required Payments Write High High High Required
  • 25. VALIDATE AND SANITIZE INPUT 25 URL validation Verb validation ✓ Reject if not valid Query params validation ✓ Min / Max / Pattern-based matching Content-Type validation ✓ Don’t accept as-is! Accept Header validation ✓ Don’t copy into Content-Type Data inbound ✓ Format ✓ Message Size and complexity Data outbound ✓ Data Leakage ✓ Exception Leakage ✓ Use rules against data dictionary 2 OPENAPI SPECIFICATION to the RESCUE !
  • 26. USE OAUTH PROPERLY 26 OAuth Grant Types ✓ Authorization Code ✓ Others are usually not the safe option. Do not use OAuth as proof of authentication, use OpenID Connect instead. Leverage PKCE 3 OPENAPI SPECIFICATION to the RESCUE !
  • 27. OAUTH THREAT LANDSCAPE Sensitive information ✓ Access tokens: the key to open the API door ✓ Refresh tokens: the key to obtain many valid access tokens ✓ Authorization code : to obtain an access token ✓ State : protection against CSRF attacks Common attacks vectors ✓ Token leakage g TLS 1.2 + strong ciphers, short-lived, token binding, protected storage ✓ Code Interception attacks g Use PKCE (Proof Key for Code Exchange) ✓ Token replay g Token Binding (over TLS) or Mutual TLS for OAuth ✓ Redirect URI Forgery g standard CRSF attacks countermeasures (OWASP) REQUIRES PROTECTION MEASURES ON CLIENT AND SERVER SIDE 27
  • 28. VALIDATE JSON WEB TOKENS 28 Don’t trust the incoming tokens! Client could have been compromised… Validate algorithm (the one you chose!) ✓ HS256 ✓ RS256 (recommended) Reject None! Validate signature ✓ Prefer digital signatures over HMAC ✓ If not, be careful of key exchange Validate standard claims and your own claims See details Learn the best practices for keeping your JWTs secure. 4 OPENAPI SPECIFICATION (AGAIN) to the RESCUE !
  • 29. EXTERNAL/ PUBLIC VS INTERNAL TOKENS 29 Token Server Validate/ Issue token
  • 30. FINE-GRAIN AUTHORIZATION 30 Who is calling ? ✓ Is it your own app ? ✓ Is it a trusted user ? What can they do ? OAuth Scopes are often not enough ! ✓ Need Attributes-based Access Control (ABAC) solution (XACML!) 5
  • 32. START EARLY: SHIFT LEFT ! 32 DeploymentTestingDevelopmentDesign
  • 34. COVER THE BASICS 34 Use Trusted Libraries Don’t re-invent the wheel! Automated Analysis Static code analysis 3rd party libraries validation (CVEs), e.g. NPS / Snyk for Node.js GitHub dependencies graph Manual Analysis Code reviews 1
  • 36. 36
  • 37. HACK YOURSELVES! 37 API Scanning/Fuzzing ✓ Veracode, Coverity ✓ 42Crunch (coming soon!) Transport analysis ✓ SSL Labs ✓ Hardenize Further Analysis ✓ Bug Bounty ✓ Pen Testing 2
  • 38. 38 PROTECT YOUR APIS 3 Protect all APIs ( public, private, SaaS) AUTOMATICALLY deploy security measures such as API Security Gateways/Firewalls ✓ Enforce Rate Limiting • Brute force attacks (see N26!) • DOS attacks ✓ Data Validation / JWT Validation / Auth / Azn ✓ Serves as Virtual Patching (as a WAF does for applications) ✓ Deploy at the edge and/or close to APIs (microservices architecture)
  • 39. Use Development ticketing system for tracking issues Analyse runtime behaviour and raise issues automatically 39 MONITOR AND ANALYZE 4
  • 40. JOIN THE MAILING LIST ! APISECURITY.IO REGISTER AND LEARN FROM MORE STORIES!
  • 42. RESOURCES OWASP Top 10 ✓ https://www.owasp.org/index.php/Category:OWASP_Top_Ten_2017_Project OWASP DevSlop Project ✓ https://www.owasp.org/index.php/OWASP_DevSlop_Project Chaos Engineering ✓ http://principlesofchaos.org ✓ https://github.com/dastergon/awesome-chaos-engineering OWASP ZAP ✓ https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project Source Code Analysis ✓ https://www.owasp.org/index.php/Source_Code_Analysis_Tools Code Security reviews ✓ https://www.owasp.org/index.php/Code_Review_Introduction Systems Scans ✓ https://www.owasp.org/index.php/Category:Vulnerability_Scanning_Tools Security Methodology ✓ https://developer.rackspace.com/blog/fanatical-security-delivered-by-quality-engineering-security-team/ 42
  • 43. RESOURCES SSL Setup Scan ✓ https://hardenize.com ✓ https://securityheaders.io ✓ https://www.ssllabs.com/ssltest/ Threat Modelling ✓ https://www.owasp.org/index.php/Application_Threat_Modeling Attacks Type Information ✓ XSS: https://excess-xss.com ✓ Buffer Overflow: https://www.youtube.com/watch?v=1S0aBV-Waeo ✓ SQL injection: https://www.youtube.com/watch?v=ciNHn38EyRc ✓ Cookie stealing /XSS: https://www.youtube.com/watch?v=T1QEs3mdJoc Pixi / DevSlop ✓ https://github.com/DevSlop/Pixi ✓ https://devslop.co JWT as session data ✓ https://dzone.com/articles/stop-using-jwts-as-session-tokens Node JS Security recommendations ✓ https://medium.com/@nodepractices/were-under-attack-23-node-js-security-best-practices-e33c146cb87d 43