SlideShare a Scribd company logo
API Security Best Practices
&
Guidelines
Prabath Siriwardena, WSO2
Twitter: @prabath | Email: prabath@wso2.com
● The Director of Security Architecture, WSO2
● Authored the book Advanced API Security - and three more
● The definition of the API has evolved over the time.
● It’s not just about the Application Programming Interface.
● Hosted, web-centric and public facing.
● Public facing does not always mean it’s outside your enterprise.
● Expose business functions to the rest of the world.
● Managed APIs
○ Secured
○ Monitored
○ Throttled
● Who’s going to access your API and from where?
○ Employees, within the domain or outside the domain or both.
○ Partners
○ Suppliers
○ Customers
○ General Public
● Is it a human or another system?
○ A user logs into a web app and the web app accesses an API on
behalf of the end user.
○ Web app does not worry about the who the end user is when
talking to an API
● Who is having control over the system, which talks to the APIs
○ Mobile app talks to an API - the end user has the total control
○ Web app talks to an API the end user has no control
○ SPA talks to an API the end user has no control
○ Trusted clients / public clients
● Direct Authentication
○ Trust the user directly - user could validate the trust by presenting
a token known to the user and the service provider (API) both.
○ User credentials are under the control of the service provider.
○ Authenticate to Github API with username/password.
● Brokered Authentication
○ Do not trust each and individual users - but some entity who can
assert a legitimate user to access the API.
○ User credentials are not under the control of the service provider.
○ The identity of the asserting entity can be validated by signature
verification.
○ Login with Facebook
● Direct Authentication
○ Username/password based authentication (basic auth)
○ OAuth 2.0
■ Authorization server and the resource server under the same
domain.
■ OAuth for authentication?
○ TLS mutual authentication
■ Trusts each certificate
○ JSON Web Token (JWT)
■ Self-issued JWT
○ Kerberos/NTLM
○ Custom API keys
● Brokered Authentication
○ OAuth 2.0
■ SAML 2.0 grant type
■ JWT grant type
■ ….
○ TLS mutual authentication
■ Trusts the issuer
○ JSON Web Token (JWT)
■ Trusts the issuer
API Security Best Practices & Guidelines
API Security Best Practices & Guidelines
API Security Best Practices & Guidelines
API Security Best Practices & Guidelines
API Security Best Practices & Guidelines
API Security Best Practices & Guidelines
SAML Grant Type
JWT Grant Type
Self-Contained Access Tokens
Self-Issued Access Tokens
Token Exchange
API Security Best Practices & Guidelines
XACML
● Use TLS in all the flows (bearer tokens)
● Store access tokens/refresh tokens/client credentials in a secure
storage (at the client side)
● Store hashed access tokens/refresh tokens/client credentials in a
secure storage (at the server side)
● Make sure access tokens/refresh tokens have the proper length to
tolerate brute-force attacks.
○ The token value should be >=128 bits long and constructed from
a cryptographically strong random or pseudo-random number
sequence
● Use strong client credentials
○ Use short-lived assertions as the client_secret
● Use OAuth state parameter to tolerate CSRF attacks.
● Use scoped access tokens.
● Use PKCE to tolerate authorization code interception attacks
(native mobile apps)
● Enable throttling by user by application
● Use TLS token binding to tolerate token exports
● Restrict clients by grant types
● Avoid using the same client_id/client_secret for each instance of a
mobile app - rather use the Dynamic Client Registration API to
generate a key pair per instance.
● Short-lived access tokens
● Long-lived refresh tokens
● The token expiration time would depend on the following
parameters.
○ risk associated with token leakage
○ duration of the underlying access grant
○ time required for an attacker to guess or produce a valid token
● One time access tokens (based on the use case)
● Client should validate the token audience
API Security Best Practices & Guidelines

More Related Content

PDF
API Security Best Practices & Guidelines
PDF
Api security-testing
PPTX
Spring security
PDF
PPTX
Rest API Security - A quick understanding of Rest API Security
PDF
Peeling the Onion: Making Sense of the Layers of API Security
PDF
OWASP API Security Top 10 - API World
PPTX
API Security Fundamentals
API Security Best Practices & Guidelines
Api security-testing
Spring security
Rest API Security - A quick understanding of Rest API Security
Peeling the Onion: Making Sense of the Layers of API Security
OWASP API Security Top 10 - API World
API Security Fundamentals

What's hot (20)

PPTX
API Security Lifecycle
PPTX
OWASP Top 10 2021 What's New
PPTX
An Introduction to OAuth2
PDF
Pentesting Rest API's by :- Gaurang Bhatnagar
PPTX
Rest API Security
PDF
Introduction to Kong API Gateway
PPTX
Getting Started with API Security Testing
ODP
OAuth2 - Introduction
PPTX
An introduction to OAuth 2
PDF
What is REST API? REST API Concepts and Examples | Edureka
PPT
Understanding REST
PPTX
Pentesting ReST API
PDF
APISecurity_OWASP_MitigationGuide
PDF
OWASP API Security Top 10 Examples
PPTX
What is an API Gateway?
PPTX
REST API
PPTX
REST API Design & Development
PDF
OAuth 2.0
PDF
API for Beginners
PPT
Postman.ppt
API Security Lifecycle
OWASP Top 10 2021 What's New
An Introduction to OAuth2
Pentesting Rest API's by :- Gaurang Bhatnagar
Rest API Security
Introduction to Kong API Gateway
Getting Started with API Security Testing
OAuth2 - Introduction
An introduction to OAuth 2
What is REST API? REST API Concepts and Examples | Edureka
Understanding REST
Pentesting ReST API
APISecurity_OWASP_MitigationGuide
OWASP API Security Top 10 Examples
What is an API Gateway?
REST API
REST API Design & Development
OAuth 2.0
API for Beginners
Postman.ppt
Ad

Similar to API Security Best Practices & Guidelines (20)

PDF
OAuth 2.0 for Web and Native (Mobile) App Developers
PDF
API Security In Cloud Native Era
PDF
Securing Single-Page Applications with OAuth 2.0
PDF
Security for oauth 2.0 - @topavankumarj
PDF
SSO using CAS + two-factor authentication (PyGrunn 2014 talk)
PPTX
How to Build a Fortress with the Security of a Tent - Jacob Ideskog, Curity
PPTX
Oauth 2.0 Introduction and Flows with MuleSoft
PDF
[Cloud Identity Summit 2017] Oauth 2.0 Threat Landscapes
PDF
OAuth 2.0 Threat Landscapes
PDF
Talk Microservices to Me: The Role of IAM in Microservice Architecture
PDF
Spring Security
PPTX
Y U No OAuth, Using Common Patterns to Secure Your Web Applications
PPTX
OpenId Connect Protocol
PDF
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
PPTX
Oauth 2.0 security
PDF
Secured REST Microservices with Spring Cloud
PDF
Implementing Microservices Security Patterns & Protocols with Spring
PDF
WSO2Con EU 2015: API Management Strategies and Best Practices
PDF
Introduction to the Globus Platform for Developers
PPTX
How to build Simple yet powerful API.pptx
OAuth 2.0 for Web and Native (Mobile) App Developers
API Security In Cloud Native Era
Securing Single-Page Applications with OAuth 2.0
Security for oauth 2.0 - @topavankumarj
SSO using CAS + two-factor authentication (PyGrunn 2014 talk)
How to Build a Fortress with the Security of a Tent - Jacob Ideskog, Curity
Oauth 2.0 Introduction and Flows with MuleSoft
[Cloud Identity Summit 2017] Oauth 2.0 Threat Landscapes
OAuth 2.0 Threat Landscapes
Talk Microservices to Me: The Role of IAM in Microservice Architecture
Spring Security
Y U No OAuth, Using Common Patterns to Secure Your Web Applications
OpenId Connect Protocol
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Oauth 2.0 security
Secured REST Microservices with Spring Cloud
Implementing Microservices Security Patterns & Protocols with Spring
WSO2Con EU 2015: API Management Strategies and Best Practices
Introduction to the Globus Platform for Developers
How to build Simple yet powerful API.pptx
Ad

More from Prabath Siriwardena (20)

PDF
Microservices Security Landscape
PDF
Cloud Native Identity with SPIFFE
PDF
Identity is Eating the World!
PPTX
Microservices Security Landscape
PPTX
OAuth 2.0 Threat Landscape
PDF
GDPR for Identity Architects
PDF
Blockchain-based Solutions for Identity & Access Management
PDF
Identity Management for Web Application Developers
PDF
Open Standards in Identity Management
PPTX
API Security : Patterns and Practices
PPTX
Best Practices in Building an API Security Ecosystem
PPTX
Connected Identity : The Role of the Identity Bus
PPTX
Connected Identity : Benefits, Risks & Challenges
PPTX
The Evolution of Internet Identity
PPTX
Next-Gen Apps with IoT and Cloud
PPTX
Securing Insecure
PPTX
Evolution of Internet Identity
PPTX
Securing the Insecure
PPTX
WSO2Con USA 2014 - Identity Server Tutorial
PDF
Advanced API Security
Microservices Security Landscape
Cloud Native Identity with SPIFFE
Identity is Eating the World!
Microservices Security Landscape
OAuth 2.0 Threat Landscape
GDPR for Identity Architects
Blockchain-based Solutions for Identity & Access Management
Identity Management for Web Application Developers
Open Standards in Identity Management
API Security : Patterns and Practices
Best Practices in Building an API Security Ecosystem
Connected Identity : The Role of the Identity Bus
Connected Identity : Benefits, Risks & Challenges
The Evolution of Internet Identity
Next-Gen Apps with IoT and Cloud
Securing Insecure
Evolution of Internet Identity
Securing the Insecure
WSO2Con USA 2014 - Identity Server Tutorial
Advanced API Security

Recently uploaded (20)

PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Insiders guide to clinical Medicine.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pharma ospi slides which help in ospi learning
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Cardiovascular Pharmacology for pharmacy students.pptx
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
O7-L3 Supply Chain Operations - ICLT Program
Open Quiz Monsoon Mind Game Final Set.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O5-L3 Freight Transport Ops (International) V1.pdf
Week 4 Term 3 Study Techniques revisited.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Insiders guide to clinical Medicine.pdf
01-Introduction-to-Information-Management.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf

API Security Best Practices & Guidelines

  • 1. API Security Best Practices & Guidelines Prabath Siriwardena, WSO2 Twitter: @prabath | Email: [email protected]
  • 2. ● The Director of Security Architecture, WSO2 ● Authored the book Advanced API Security - and three more
  • 3. ● The definition of the API has evolved over the time. ● It’s not just about the Application Programming Interface. ● Hosted, web-centric and public facing. ● Public facing does not always mean it’s outside your enterprise. ● Expose business functions to the rest of the world. ● Managed APIs ○ Secured ○ Monitored ○ Throttled
  • 4. ● Who’s going to access your API and from where? ○ Employees, within the domain or outside the domain or both. ○ Partners ○ Suppliers ○ Customers ○ General Public
  • 5. ● Is it a human or another system? ○ A user logs into a web app and the web app accesses an API on behalf of the end user. ○ Web app does not worry about the who the end user is when talking to an API
  • 6. ● Who is having control over the system, which talks to the APIs ○ Mobile app talks to an API - the end user has the total control ○ Web app talks to an API the end user has no control ○ SPA talks to an API the end user has no control ○ Trusted clients / public clients
  • 7. ● Direct Authentication ○ Trust the user directly - user could validate the trust by presenting a token known to the user and the service provider (API) both. ○ User credentials are under the control of the service provider. ○ Authenticate to Github API with username/password. ● Brokered Authentication ○ Do not trust each and individual users - but some entity who can assert a legitimate user to access the API. ○ User credentials are not under the control of the service provider. ○ The identity of the asserting entity can be validated by signature verification. ○ Login with Facebook
  • 8. ● Direct Authentication ○ Username/password based authentication (basic auth) ○ OAuth 2.0 ■ Authorization server and the resource server under the same domain. ■ OAuth for authentication? ○ TLS mutual authentication ■ Trusts each certificate ○ JSON Web Token (JWT) ■ Self-issued JWT ○ Kerberos/NTLM ○ Custom API keys
  • 9. ● Brokered Authentication ○ OAuth 2.0 ■ SAML 2.0 grant type ■ JWT grant type ■ …. ○ TLS mutual authentication ■ Trusts the issuer ○ JSON Web Token (JWT) ■ Trusts the issuer
  • 22. XACML
  • 23. ● Use TLS in all the flows (bearer tokens) ● Store access tokens/refresh tokens/client credentials in a secure storage (at the client side) ● Store hashed access tokens/refresh tokens/client credentials in a secure storage (at the server side) ● Make sure access tokens/refresh tokens have the proper length to tolerate brute-force attacks. ○ The token value should be >=128 bits long and constructed from a cryptographically strong random or pseudo-random number sequence ● Use strong client credentials ○ Use short-lived assertions as the client_secret ● Use OAuth state parameter to tolerate CSRF attacks. ● Use scoped access tokens. ● Use PKCE to tolerate authorization code interception attacks (native mobile apps)
  • 24. ● Enable throttling by user by application ● Use TLS token binding to tolerate token exports ● Restrict clients by grant types ● Avoid using the same client_id/client_secret for each instance of a mobile app - rather use the Dynamic Client Registration API to generate a key pair per instance. ● Short-lived access tokens ● Long-lived refresh tokens ● The token expiration time would depend on the following parameters. ○ risk associated with token leakage ○ duration of the underlying access grant ○ time required for an attacker to guess or produce a valid token ● One time access tokens (based on the use case) ● Client should validate the token audience