SlideShare a Scribd company logo
@adam_englander
Don’t Lose Sleep
Secure Your REST
Adam Englander, iovation
@adam_englander
A Little Background About Me
And APIs
@adam_englander
This is what I looked
like when I started
working on APIs
It was so long ago that SOAP was the
new hotness.
@adam_englander
Over The Years
• 2001 — Global Authentication Service API
• 2008 — Loan Application Ping Tree
• 2010 — Loan Management System API
• 2012 — Advertising Network API
• 2013 — Real Time Loan Risk Assessment API
• 2015 — Decentralized Multi-Factor Authorization API
@adam_englander
Some Were More Secure Than
Others
@adam_englander
Auth and Crypto Was Messy
• Auth as part of the message added complexity
• Auth outside of the message lost context
• Every implementation was specialized
• Crypto was non-standard and static
• Non-experts had to write a lot of code
@adam_englander
2015 Changed All Of That
IETF RFC 7523: JSON Web Token (JWT) Profile
for OAuth 2.0 Client Authentication and Authorization Grants
@adam_englander
Javascript Object Signing and
Encryption (JOSE) Went Mainstream
@adam_englander
Why Was It A Big Deal?
• Authentication, authorization, encryption, and
data integrity validation are not tied to the
protocol
• OAuth, OpenID, and FIDO adopting the
standard gave it credibility, stability, and
longevity as an IETF working group
@adam_englander
Case Study: iovation LaunchKey
Transformation of an Authorization API
@adam_englander
LaunchKey is a Multi-Factor
Authentication and Authorization
Service
@adam_englander
LaunchKey API Version 1.x
The Before Time. The Long Long Ago…
@adam_englander
Data
• RESTish Web API
• Query parameters for GET including encrypted
data and signature
• Mostly form encoded requests for POST/PUT/
DELETE
• JSON responses
@adam_englander
Credentials
• Silo credentials for entity types
• Random integers for identifiers
• Passwords sent in encrypted package
• Password rotation with old password expiring
one hour after new password generated.
@adam_englander
Cryptography
• RSA OAEP encryption for most requests
• AES 256 CBC for large packages
• RSA SHA-256 signatures for portions
@adam_englander
Security
• Replay prevention for requester ID and
timestamp
• Signature verification for password and
timestamp
• Encrypted password and timestamp
• Rate limited by requester ID and subject
@adam_englander
The Good — Security
• The API was never compromised even though
there has been a bug bounty for four years
• It passed multiple static and dynamic analyses
from top security analysis firms
• No-one has ever been able to fabricate an
authorization ever
@adam_englander
The Bad — Usability
• Has its own way of doing things
• API is not uniform in data and encryption
• Security trumped RESTful
• Too many credentials to manage
• No proper credential rotation
@adam_englander
LaunchKey API v2.x
An almost awesome attempt at making a better API via open standards
@adam_englander
Enter JSON Web Token (JWT)
@adam_englander
What We Gained
• Began using an open standard for data security
• We added a private claim for as SHA-256 hash
of the request body
• A more secure API request format
@adam_englander
What Was Missing
• Still using custom and inconsistent encryption
• Did not increase the RESTful quality
• Did not sign the entire request
• Did not reduce the quantity of credentials
• Did not improve the response
@adam_englander
LaunchKey API v3.0
A full blown JOSE secured REST API
@adam_englander
What Changed?
• JWT with custom claims used to validate entire
request and critical portions of the response
• JWE to encrypt request and response
• JWA for future proofing cryptography
• JWK for credential rotation
• Removed password entirely
@adam_englander
The Good — Decoupling
• Authentication, authorization, validation, encryption
and decryption was moved to middleware
• Controllers handled only HTTP/JSON which greatly
reduced code complexity
• Better unit testing across the board
• Reduced development times for new functionality
@adam_englander
The Good — OSS Libraries
• We can test our API without requiring our own
client SDK
• Client SDKs are less complex
• OSS contributions are actually possible
• Documentation complexity was reduced
@adam_englander
The Good — Uniformity Across APIs
• All APIs will be migrated to JOSE
• Different key implementations are possible
• Shared knowledge across vastly different teams
• Federated authentication is attainable
@adam_englander
The Good — Hierarchical Auth
• JWT inclusion of issuer, subject, and audience
allows for a parent to provide credentials for
action on a sibling with proper context.
• JWK allows for easy identification of credentials
used
@adam_englander
The Bad
• Some languages have minimal support for
algorithms and strengths
• Some languages have no support for JWE. We
had to write our own minimal Objective-C
implementation
• Some good documentation but a good working
knowledge requires reading RFCs
@adam_englander
How Did We Do It?
@adam_englander
JOSE, JOSE, JOSE
@adam_englander
What is JOSE?
• JavaScript Object Signing and Encryption encompasses:
• JSON Web Token (JWT)
• JSON Web Signature (JWS)
• JSON Web Encryption (JWE)
• JSON Web Algorithm (JWA)
• JSON Web Key (KWK)
@adam_englander
JSON Web Token (JWT)
• JWT is actually a JSON Web Signature (JWS)
package with standardized payload in the form
of Claims.
• Provides for credentials, nonce, timestamp, and
duration
• Private claims can be added for extensibility
@adam_englander
JSON Web Signature (JWS)
JWS is comprised of three segments:
1. Header provides key information, signature
algorithm, and optionally content metadata
2. Payload is the data to be signed
3. Signature of the header and payload
@adam_englander
JSON Web Encryption (JWE)
JSON Web Encryption contains five segments:
1. Header provides key management mode, key
information, key encryption algorithm, content
encryption algorithm, and optionally content metadata
2. Content Encryption Key (CEK) may contain generated
symmetric keys used for encryption and HMAC that
are encrypted using asymmetric key encryption
@adam_englander
JSON Web Encryption (JWE)
3. Initialization Vector for encrypting the payload
4. Encrypted payload
5. Authentication tag is an HMAC of the header,
IV, and encrypted payload
@adam_englander
JSON Web Algorithm
• Standardized format for expressing encryption
and signature algorithms.
• Used by JWE/JWS with “enc” and “alg” keys in
the header.
@adam_englander
JSON Web Key
• Standardized format for expressing keys used
for JWE and JWS.
• Provides for key identification.
• Used by JWE/JWS with number of keys in the
header which are determined by the key type.
@adam_englander
How We Use JOSE
JOSE Solved Every Problem We Had
@adam_englander
Request Example Representation
POST /service/v3/auths HTTP/1.1
Content-Type: application/jose
Content-Length: 112
Authorization: IOV-JWT eyJhb.VuYyI6IkEy.OKOaw
eyJhbGciO.Ppd6dIAkG.71lYoW6jA.t-4rRH6GsoXt0.1DGC4k
@adam_englander
JWT Header Example
{

"kid": "09:f7:e0:2f:12:90:be:21:1d:a7:07:a2:66:f1:53:b3",

"alg": "RS256",

"typ": "JWT",

"cty": "JWT"

}
@adam_englander
Key Rotation
• Key ID id provided in request and response
• Current and specific public keys are available via
endpoint
• https://api.launchkey.com/public/v3/public-key/
09:f7:e0:2f:12:90:be:21:1d:a7:07:a2:66:f1:53:b3
• https://api.launchkey.com/public/v3/public-key
@adam_englander
Key Rotation
{

"kid": "09:f7:e0:2f:12:90:be:21:1d:a7:07:a2:66:f1:53:b3",

"alg": "RS256",

"typ": "JWT",

"cty": "JWT"

}
/v3/public-key/09:f7:e0:2f:12:90:be:21:1d:a7:07:a2:66:f1:53:b3
@adam_englander
Request Authorization
• Single use JSON Web Token (JWT) in Authorization
header as Authorization scheme IOV-JWT
• RSA key signature
• Hierarchical ACL: Org -> Dir -> Service
• Token ID as nonce
• Private claims: request
@adam_englander
Private Request Claims
• Method
• Path
• Body hash
• Body hash algorithm
• Query parameters
@adam_englander
JWT Request Claims Example
{

"iss": "dir:fd57bffe-7391-47c4-94d0-a0ad4b6bc979",

"sub": "svc:d2083969-b5aa-4753-909d-472ce2517fd1",

"aud": "lka",

"iat": 1234567890,

"nbf": 1234567890,

"exp": 1234567895,

"jti": "bec95e07-cee2-4c77-b080-56a8b24b2e54",

"request": {

"meth": "POST",

"path": "/service/v3/auths",

"func": "S256",

"hash": "66a045b452102c59d840ec097d59d9467e13a3f34f6494e539ffd32c1bb35f18"

}

}
@adam_englander
Hierarchical Credentials
…

"iss": "dir:fd57bffe-7391-47c4-94d0-a0ad4b6bc979",

"sub": "svc:d2083969-b5aa-4753-909d-472ce2517fd1",

"aud": "lka",
…

@adam_englander
Timestamp and Duration
…

"iat": 1487244120,

"nbf": 1487244120,

"exp": 1487244125,

…
JWT hash stored until expiration to prevent replay
attacks.
@adam_englander
Nonce
…
"jti": "bec95e07-cee2-4c77-b080-56a8b24b2e54",

…
@adam_englander
Request Validation
POST /service/v3/auths HTTP/1.1
…
"request": {

"meth": "POST",

"path": "/service/v3/auths",

"func": "S256",

"hash": "66a045b452102c59d840e…"

}

…
@adam_englander
Response Authorization
• Single use JSON Web Token (JWT) in custom
header X-IOV-JWT
• RSA key signature
• Hierarchical credentials
• Token ID nonce is echoed
• Private claims: response
@adam_englander
Private Response Claims
• Status Code
• Cache-Control Header
• Location Header
• Body hash
• Body hash algorithm
@adam_englander
Response Example Representation
HTTP/1.1 201 Created
Content-Type: application/jose
Content-Length: 112
Cache-Control: no-cache
Location: /directory/v3/users/518f5d3e-7cdf-4ef1-…
X-IOV-JWT: eyJhb.VuYyI6IkEy.OKOaw
eyJhbGciO.Ppd6dIAkG.71lYoW6jA.t-4rRH6GsoXt0.1DGC4k
@adam_englander
JWT Response Claims Example
{

"iss": "lka",

"sub": "svc:d2083969-b5aa-4753-909d-472ce2517fd1",

"aud": "dir:fd57bffe-7391-47c4-94d0-a0ad4b6bc979",

"iat": 1234567891,

"nbf": 1234567891,

"exp": 1234567896,

"jti": "bec95e07-cee2-4c77-b080-56a8b24b2e54",

"response": {

"status": 201,

"cache": "no-cache",

"location": "/directory/v3/users/518f5d3e-7cdf-4ef1-…",

"func": "S256",

"hash": "66a045b452102c59d840ec097d59d9467e13a3f34f6494e539ffd32c1bb35f18"

}

}
@adam_englander
Hierarchical Credentials
…

"iss": "lka",

"sub": "svc:d2083969-b5aa-4753-909d-472ce2517fd1",

"aud": "dir:fd57bffe-7391-47c4-94d0-a0ad4b6bc979",
…

@adam_englander
Timestamp and Duration
…

"iat": 1487244121,

"nbf": 1487244121,

"exp": 1487244126,

…
@adam_englander
Nonce
…
"jti": "bec95e07-cee2-4c77-b080-56a8b24b2e54",

…
Nonce is echoed in JTI to allow for detection of
Man In The Middle attacks
@adam_englander
Response Validation
HTTP/1.1 201 Created
Cache-Control: no-cache
Location: /directory/v3/users/518f5d3e-7c…
…
"response": {

"status": 201,

"cache": "no-cache",

"location": "/directory/v3/users/518f5d3e-7c…",

"func": "S256",

"hash": “66a045b452102c59d840ec097d59d9467e13…”

}
…
@adam_englander
Encrypted Data with JWE
• JWK provides for key rotation
• Combination of RSA and AES encryption is always
used
• Algorithms and modes are always the same
• Key size is variable in allowed range
• Response uses same AES key size as request
@adam_englander
JWE Header Example
{

"kid": "09:f7:e0:2f:12:90:be:21:1d:a7:07:a2:66:f1:53:b3",

"alg": “RSA-OAEP-256",

"enc": "A256CBC-HS512",

"cty": “application/json"

}
@adam_englander
Conclusion
• JOSE has made our secure API more secure
• JOSE has made our API easier to use
• JOSE has made our code less complex
• JOSE has homogenized auth and crypto across
multiple platforms regardless of language
@adam_englander
Libraries
• spomky-labs/jose - Full JOSE
• lcobucci/jwt - JWT only - Author presenting
tomorrow
@adam_englander
Please Rate This Talk
https://legacy.joind.in/20330
@adam_englander
If You Want To Follow Up
• @adam_englander
• adam.englander@iovation.com
• https://www.iovation.com/blog/author/aenglander

More Related Content

PDF
Don't Loose Sleep - Secure Your Rest - php[tek] 2017
PDF
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
PPTX
Practical API Security - PyCon 2018
PDF
DevDays LT 2017 - Secure by Design
PDF
Protecting Your APIs Against Attack & Hijack
PPTX
Secure socket layer
 
PPTX
Token Binding Identiverse 2018
PDF
CIS 2015 OpenID Connect and Mobile Applications - David Chase
Don't Loose Sleep - Secure Your Rest - php[tek] 2017
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
Practical API Security - PyCon 2018
DevDays LT 2017 - Secure by Design
Protecting Your APIs Against Attack & Hijack
Secure socket layer
 
Token Binding Identiverse 2018
CIS 2015 OpenID Connect and Mobile Applications - David Chase

What's hot (16)

PPTX
Couchbase usage at Symantec
PPTX
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
PDF
VA Code Completion
PPTX
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
PPTX
Locking the Doors -7 Pernicious Pitfalls to avoid with Java
PDF
Add Some DDD to Your ASP.NET MVC, OK?
PPT
PKI101 polk
PDF
2018 JavaLand Deconstructing and Evolving REST Security
PDF
What is tackled in the Java EE Security API (Java EE 8)
PDF
Implementing Authorization
PPTX
Polaris presentation ioc - code conference
PDF
Rest api design by george reese
PPTX
RESTful modules in zf2
PDF
Are You Properly Using JWTs?
PPTX
Java ee 8 + security overview
PPTX
Secure API Services in Node with Basic Auth and OAuth2
Couchbase usage at Symantec
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
VA Code Completion
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
Locking the Doors -7 Pernicious Pitfalls to avoid with Java
Add Some DDD to Your ASP.NET MVC, OK?
PKI101 polk
2018 JavaLand Deconstructing and Evolving REST Security
What is tackled in the Java EE Security API (Java EE 8)
Implementing Authorization
Polaris presentation ioc - code conference
Rest api design by george reese
RESTful modules in zf2
Are You Properly Using JWTs?
Java ee 8 + security overview
Secure API Services in Node with Basic Auth and OAuth2
Ad

Viewers also liked (20)

PDF
JWT - To authentication and beyond!
PDF
Integrating React.js with PHP projects
PDF
SunshinePHP 2017 - Making the most out of MySQL
ODP
My app is secure... I think
PPTX
Docker for Developers - Sunshine PHP
PDF
Hopping in clouds - phpuk 17
PDF
Driving Design through Examples
PDF
WordPress for the modern PHP developer
PDF
PHP Benelux 2017 - Caching The Right Way
PDF
Demystifying Object-Oriented Programming - PHP UK Conference 2017
PDF
Phone calls and sms from php
PDF
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
PDF
IoT Lock Down - Battling the Bot Net Builders
PDF
Code Coverage for Total Security in Application Migrations
PPTX
Debugging Effectively - SunshinePHP 2017
PDF
SunshinePHP 2017: Tales From The Crypt - A Cryptography Primer
PDF
Dip Your Toes in the Sea of Security
PPTX
A World Without PHP
PDF
Learn To Test Like A Grumpy Programmer - 3 hour workshop
PDF
Amp your site: An intro to accelerated mobile pages
JWT - To authentication and beyond!
Integrating React.js with PHP projects
SunshinePHP 2017 - Making the most out of MySQL
My app is secure... I think
Docker for Developers - Sunshine PHP
Hopping in clouds - phpuk 17
Driving Design through Examples
WordPress for the modern PHP developer
PHP Benelux 2017 - Caching The Right Way
Demystifying Object-Oriented Programming - PHP UK Conference 2017
Phone calls and sms from php
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
IoT Lock Down - Battling the Bot Net Builders
Code Coverage for Total Security in Application Migrations
Debugging Effectively - SunshinePHP 2017
SunshinePHP 2017: Tales From The Crypt - A Cryptography Primer
Dip Your Toes in the Sea of Security
A World Without PHP
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Amp your site: An intro to accelerated mobile pages
Ad

Similar to PHP UK 2017 - Don't Lose Sleep - Secure Your REST (20)

PPTX
JWTs and JOSE in a flash
PPTX
Pentesting jwt
PDF
Json web token api authorization
PDF
RoadSec 2017 - Trilha AppSec - APIs Authorization
PPTX
Microservices Security Patterns & Protocols with Spring & PCF
PDF
Introduction to JWT and How to integrate with Spring Security
PPTX
Cloud Identity Management
PPTX
Json Web Token - JWT
PDF
JDD2015: Security in the era of modern applications and services - Bolesław D...
PPTX
Introduction to the Emerging JSON-Based Identity and Security Protocols
PPT
Securing RESTful API
PDF
Modern API Security with JSON Web Tokens
PDF
JSON WEB TOKEN
PPTX
Advanced Security Extensions in Apigee Edge: JWT, JWE, JWS
PDF
Landscape
PDF
Landscape
PDF
Protecting Java Microservices: Best Practices and Strategies
PDF
5 easy steps to understanding json web tokens (jwt)
PDF
What the Heck is OAuth and OpenID Connect - DOSUG 2018
PDF
Securing Web Applications with Token Authentication
JWTs and JOSE in a flash
Pentesting jwt
Json web token api authorization
RoadSec 2017 - Trilha AppSec - APIs Authorization
Microservices Security Patterns & Protocols with Spring & PCF
Introduction to JWT and How to integrate with Spring Security
Cloud Identity Management
Json Web Token - JWT
JDD2015: Security in the era of modern applications and services - Bolesław D...
Introduction to the Emerging JSON-Based Identity and Security Protocols
Securing RESTful API
Modern API Security with JSON Web Tokens
JSON WEB TOKEN
Advanced Security Extensions in Apigee Edge: JWT, JWE, JWS
Landscape
Landscape
Protecting Java Microservices: Best Practices and Strategies
5 easy steps to understanding json web tokens (jwt)
What the Heck is OAuth and OpenID Connect - DOSUG 2018
Securing Web Applications with Token Authentication

More from Adam Englander (20)

PPTX
Making PHP Smarter - Dutch PHP 2023.pptx
PDF
Practical API Security - PyCon 2019
PDF
Threat Modeling for Dummies
PDF
ZendCon 2018 - Practical API Security
PDF
ZendCon 2018 - Cryptography in Depth
PDF
Threat Modeling for Dummies - Cascadia PHP 2018
PDF
Dutch PHP 2018 - Cryptography for Beginners
PDF
php[tek] 2108 - Cryptography Advances in PHP 7.2
PDF
php[tek] 2018 - Biometrics, fantastic failure point of the future
PDF
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
PDF
Practical API Security - Midwest PHP 2018
PDF
Cryptography for Beginners - Midwest PHP 2018
PDF
Cryptography for Beginners - Sunshine PHP 2018
PDF
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
PDF
ZendCon 2017 - Cryptography for Beginners
PDF
ZendCon 2017: The Red Team is Coming
PDF
ZendCon 2017 - Build a Bot Workshop - Async Primer
PDF
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
PDF
Coder Cruise 2017 - The Red Team Is Coming
PDF
Build a bot workshop async primer - php[tek]
Making PHP Smarter - Dutch PHP 2023.pptx
Practical API Security - PyCon 2019
Threat Modeling for Dummies
ZendCon 2018 - Practical API Security
ZendCon 2018 - Cryptography in Depth
Threat Modeling for Dummies - Cascadia PHP 2018
Dutch PHP 2018 - Cryptography for Beginners
php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2018 - Biometrics, fantastic failure point of the future
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Practical API Security - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Sunshine PHP 2018
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ZendCon 2017 - Cryptography for Beginners
ZendCon 2017: The Red Team is Coming
ZendCon 2017 - Build a Bot Workshop - Async Primer
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Coder Cruise 2017 - The Red Team Is Coming
Build a bot workshop async primer - php[tek]

Recently uploaded (20)

PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
ai tools demonstartion for schools and inter college
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
AI in Product Development-omnex systems
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
medical staffing services at VALiNTRY
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
history of c programming in notes for students .pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
DOCX
The Five Best AI Cover Tools in 2025.docx
PPTX
Introduction to Artificial Intelligence
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Online Work Permit System for Fast Permit Processing
PDF
PTS Company Brochure 2025 (1).pdf.......
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Softaken Excel to vCard Converter Software.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
ai tools demonstartion for schools and inter college
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
AI in Product Development-omnex systems
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
medical staffing services at VALiNTRY
Upgrade and Innovation Strategies for SAP ERP Customers
Materi-Enum-and-Record-Data-Type (1).pptx
history of c programming in notes for students .pptx
Operating system designcfffgfgggggggvggggggggg
The Five Best AI Cover Tools in 2025.docx
Introduction to Artificial Intelligence
ManageIQ - Sprint 268 Review - Slide Deck
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Online Work Permit System for Fast Permit Processing
PTS Company Brochure 2025 (1).pdf.......

PHP UK 2017 - Don't Lose Sleep - Secure Your REST