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

PPTX
Rest API Security
PDF
OWASP API Security Top 10 - API World
PPT
Application Security
PPSX
Docker Kubernetes Istio
PDF
API Security Best Practices & Guidelines
PPTX
API Security Fundamentals
ODP
OAuth2 - Introduction
PPT
Source Code Analysis with SAST
Rest API Security
OWASP API Security Top 10 - API World
Application Security
Docker Kubernetes Istio
API Security Best Practices & Guidelines
API Security Fundamentals
OAuth2 - Introduction
Source Code Analysis with SAST

What's hot (20)

PPTX
REST API Design & Development
PDF
Microservices with Java, Spring Boot and Spring Cloud
PDF
OWASP Top 10 API Security Risks
PPTX
Software Composition Analysis Deep Dive
PDF
Keycloak Single Sign-On
PPSX
Microservices, DevOps & SRE
PPTX
Secure your app with keycloak
PPTX
OpenId Connect Protocol
PPSX
Event Sourcing & CQRS, Kafka, Rabbit MQ
PPTX
Building secure applications with keycloak
PDF
How to migrate an application in IBM APIc, and preserve its client credential
PDF
DevSecOps: What Why and How : Blackhat 2019
PPTX
API Security : Patterns and Practices
KEY
Web API Basics
PPTX
What's New in API Connect & DataPower Gateway in 1H 2018
PDF
Apigee Demo: API Platform Overview
PPTX
API Security Lifecycle
PDF
Designing APIs with OpenAPI Spec
PDF
Terraform -- Infrastructure as Code
PDF
Microservices Design Patterns | Edureka
REST API Design & Development
Microservices with Java, Spring Boot and Spring Cloud
OWASP Top 10 API Security Risks
Software Composition Analysis Deep Dive
Keycloak Single Sign-On
Microservices, DevOps & SRE
Secure your app with keycloak
OpenId Connect Protocol
Event Sourcing & CQRS, Kafka, Rabbit MQ
Building secure applications with keycloak
How to migrate an application in IBM APIc, and preserve its client credential
DevSecOps: What Why and How : Blackhat 2019
API Security : Patterns and Practices
Web API Basics
What's New in API Connect & DataPower Gateway in 1H 2018
Apigee Demo: API Platform Overview
API Security Lifecycle
Designing APIs with OpenAPI Spec
Terraform -- Infrastructure as Code
Microservices Design Patterns | Edureka
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
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
PDF
Who Needs That FAPI Thing, Anyway? - Michal Trojanowski, Curity
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
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
Who Needs That FAPI Thing, Anyway? - Michal Trojanowski, Curity
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
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
PPTX
Deep dive into Java security architecture
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
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
Deep dive into Java security architecture

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
master seminar digital applications in india
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
human mycosis Human fungal infections are called human mycosis..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 Đ...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Cell Types and Its function , kingdom of life
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
master seminar digital applications in india
TR - Agricultural Crops Production NC III.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
01-Introduction-to-Information-Management.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
human mycosis Human fungal infections are called human mycosis..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 Đ...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Cell Structure & Organelles in detailed.
Anesthesia in Laparoscopic Surgery in India
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Cell Types and Its function , kingdom of life
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O5-L3 Freight Transport Ops (International) V1.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table

API Security Best Practices & Guidelines

  • 1. API Security Best Practices & Guidelines Prabath Siriwardena, WSO2 Twitter: @prabath | Email: prabath@wso2.com
  • 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