SlideShare a Scribd company logo
Les Hazlewood @lhazlewood
Apache Shiro PMC Chair
CTO, Stormpath
stormpath.com
Secure your REST API
(the right way)
.com
• User Management and Authentication
API
• Security for your applications
• User security workflows
• Security best practices
• Developer tools, SDKs, libraries
HTTP Authentication...
... is all about the headers
Learn more at Stormpath.com
1. Request
GET /accounts/x2b4jX3l31uiL HTTP/1.1
Host: api.acme.com
Learn more at Stormpath.com
2. Challenge Response
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm=“name”
Learn more at Stormpath.com
3. Resubmit Request
GET /accounts/x2b4jX3l31uiL HTTP/1.1
Host: api.acme.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Learn more at Stormpath.com
Authorization Header Format
GET /accounts/x2b4jX3l31uiL HTTP/1.1
Host: api.acme.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Scheme Name Scheme-specific Value
sp
Learn more at Stormpath.com
4. Successful Response
HTTP/1.1 200 OK
Content-Type: application/json
...
{
“email”: “jsmith@gmail.com”,
“givenName”: “Joe”,
“surname”: Smith”,
...
}
Learn more at Stormpath.com
Example: Oauth 1.0a
GET /accounts/1234 HTTP/1.1
Host: api.acme.com
Authorization: OAuth realm="Photos",
oauth_consumer_key="dpf43f3p2l4k3l03",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="137131200",
oauth_nonce="wIjqoS",
oauth_callback="https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fprinter.example.com%2Fready",
oauth_signature="74KNZJeDHnMBp0EMJ9ZHt%2FXKycU%3D"
Learn more at Stormpath.com
Example: Oauth 2
GET /accounts/x2b4jX3l31uiL HTTP/1.1
Host: api.acme.com
Authorization: Bearer mF_9.B5f-4.1JqM
Learn more at Stormpath.com
Example: Oauth 2 MAC
GET /accounts/x2b4jX3l31uiL HTTP/1.1
Host: api.acme.com
Authorization: MAC id="h480djs93hd8",
nonce="264095:dj83hs9s”,
mac="SLDJd4mg43cjQfElUs3Qub4L6xE="
Learn more at Stormpath.com
Ok, now that’s out of the way
• Please avoid Basic Authc if you can.
• Favor HMAC-SHA256 digest algorithms over
bearer token algorithms
• Use Oauth 1.0a or Oauth 2 (preferably MAC)
• Only use a custom scheme if you really,
really know what you’re doing.
Learn more at Stormpath.com
Status Codes
Learn more at Stormpath.com
401 vs 403
• 401 “Unauthorized” really means
Unauthenticated
“You need valid credentials for me to respond to
this request”
• 403 “Forbidden” really means Unauthorized
“I understood your credentials, but so sorry, you’re
not allowed!”
Learn more at Stormpath.com
HTTP Authorization
Learn more at Stormpath.com
HTTP Authorization
• After authc, perform authz
• Filter requests before invoking MVC layer
• Blanket security policies
• Per-URI customization
Learn more at Stormpath.com
HTTP Authorization: OAuth
• OAuth is an authorization protocol, NOT
an authentication or SSO protocol.
• “Can I see User X’s email address please?”
NOT:
• “I want to authenticate User X w/ this
username and password”
• People still try to use OAuth for
authentication (OpenId Connect)
Learn more at Stormpath.com
HTTP Authorization: OAuth
• When OAuth 2 is a good fit:
• If your REST clients do NOT own the data
they are attempting to read
• When Oauth 2 isn’t as good of a fit:
• If your REST client owns the data it is
reading
• Could still be fine if you’re willing to incur
some additional overhead
Learn more at Stormpath.com
HTTP Authorization: JWT
• JWT = JSON Web Token
• Very new spec, but clean & simple
• JWTs can be digitally signed and/or
encrypted, and are URL friendly.
• Can be used as Bearer Tokens and for SSO
Learn more at Stormpath.com
Best Practices
Learn more at Stormpath.com
API Keys
Learn more at Stormpath.com
API Keys, Not Passwords
• Entropy
• Independence
• Speed
• Reduced Exposure
• Traceability
• Rotation
Learn more at Stormpath.com
API Keys cont’d
• Authenticate every request
• Encrypt API Key secret values at rest.
• Avoid Sessions (not RESTful)
• Authc every request + no sessions = no
XSRF attacks
Learn more at Stormpath.com
Identifiers
Learn more at Stormpath.com
Identifiers
/accounts/x2b4jX3l31uiL
Good
Not So Good
/accounts/1234
Why?
Learn more at Stormpath.com
Identifiers
• Should be opaque
• Secure Random or Random/Time UUID
• URL-friendly ‘Base62’ encoding
• Avoid sequential numbers:
• distribute ID generation load
• mitigate fusking attacks
Learn more at Stormpath.com
Query Injection
Learn more at Stormpath.com
Query Injection
Vulnerable URL:
foo.com/accounts?acctId=‘ or ‘1’=‘1
String query =
“select * from accounts where acct_id = ‘” +
request.getParameter(“acctId”) + “’”;
Solution
• Use Parameterized Query API (Prepared
Statements).
• If not available, escape special chars
Learn more at Stormpath.com
Redirects and Forwards
Learn more at Stormpath.com
Redirects and Forwards
• Avoid redirects and forwards if possible
• If used, validate the value and ensure
authorized for the current user.
foo.com/redirect.jsp?url=evil.com
foo.com/whatever.jsp?fwd=admin.jsp
Learn more at Stormpath.com
TLS
Learn more at Stormpath.com
TLS
• Use TLS for everything
• Once electing to TLS:
– Never revert
– Never switch back and forth
• Cookies: set the ‘secure’ and ‘httpOnly’
flags for secure cookies
• Backend/infrastructure connections use
TLS too
Learn more at Stormpath.com
TLS Cont’d
• Configure your SSL provider to only support
strong (FIPS 140-2 compliant) algorithms
• Use Cipher Suites w/ Perfect Forward
Secrecy!
–e.g.
ECDHE_RSA_WITH_AES_256_GCM_SHA256
• Keep your TLS certificates valid
• But beware, TLS isn’t foolproof
– App-level encryption + TLS for most secure
results
Learn more at Stormpath.com
Configuration
Learn more at Stormpath.com
Configuration
• CI: Security Testing
• Security Patches
• Regularly scan/audit
• Same config in Dev, Prod, QA*
– (Docker is great for this!)
• Externalize passwords/credentials
* Except credentials of course
Learn more at Stormpath.com
Storage
Learn more at Stormpath.com
Storage
• Sensitive data encrypted at rest
• Encrypt offsite backups
• Strong algorithms/standards
• Strong encryption keys and key mgt
• Strong password hashing
• External key storage
• Encrypted file system (e.g. eCryptfs)
Learn more at Stormpath.com
Thank You!
• les@stormpath.com
• Twitter: @lhazlewood
• https://stormpath.com
Learn more at Stormpath.com
.com
• Free for developers
• Eliminate months of development
• Automatic security best practices
Sign Up Now: Stormpath.com
Learn more at Stormpath.com

More Related Content

What's hot (20)

PPTX
Spring Security 5
Jesus Perez Franco
 
PPTX
ELK Stack
Phuc Nguyen
 
PPTX
SIEM 101: Get a Clue About IT Security Analysis
AlienVault
 
PPT
Introduction To OWASP
Marco Morana
 
PPTX
Secure your app with keycloak
Guy Marom
 
ODP
Projects In Laravel : Learn Laravel Building 10 Projects
Sam Dias
 
PDF
SSRF vs. Business-critical applications. XXE tunneling in SAP
ERPScan
 
PPTX
Owasp zap
penetration Tester
 
PDF
REST API and CRUD
Prem Sanil
 
PPTX
jQuery from the very beginning
Anis Ahmad
 
PDF
Introduction to SAML 2.0
Mika Koivisto
 
ODP
Malware Dectection Using Machine learning
Shubham Dubey
 
PDF
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine
 
PPTX
Progressive Web Apps(PWA)
Muhamad Fahriza Novriansyah
 
PPTX
Visualizing Kafka Security
DataWorks Summit
 
PPTX
Rest API Security
Stormpath
 
PDF
API Security Best Practices & Guidelines
Prabath Siriwardena
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PPT
Tomcat
Venkat Pinagadi
 
PDF
OWASP API Security Top 10 - API World
42Crunch
 
Spring Security 5
Jesus Perez Franco
 
ELK Stack
Phuc Nguyen
 
SIEM 101: Get a Clue About IT Security Analysis
AlienVault
 
Introduction To OWASP
Marco Morana
 
Secure your app with keycloak
Guy Marom
 
Projects In Laravel : Learn Laravel Building 10 Projects
Sam Dias
 
SSRF vs. Business-critical applications. XXE tunneling in SAP
ERPScan
 
REST API and CRUD
Prem Sanil
 
jQuery from the very beginning
Anis Ahmad
 
Introduction to SAML 2.0
Mika Koivisto
 
Malware Dectection Using Machine learning
Shubham Dubey
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine
 
Progressive Web Apps(PWA)
Muhamad Fahriza Novriansyah
 
Visualizing Kafka Security
DataWorks Summit
 
Rest API Security
Stormpath
 
API Security Best Practices & Guidelines
Prabath Siriwardena
 
Intro to Node.js (v1)
Chris Cowan
 
OWASP API Security Top 10 - API World
42Crunch
 

Similar to Secure Your REST API (The Right Way) (20)

PPTX
REST API Security: OAuth 2.0, JWTs, and More!
Stormpath
 
PPTX
Token Authentication for Java Applications
Stormpath
 
PPT
Scalable Reliable Secure REST
guestb2ed5f
 
PPTX
Api security
teodorcotruta
 
PDF
Ch 3: Web Application Technologies
Sam Bowne
 
PDF
Securing REST APIs
Claire Hunsaker
 
PDF
OAuth and OEmbed
leahculver
 
PDF
Facebook & Twitter API
Fabrice Delhoste
 
PDF
Building Awesome APIs with Lumen
Kit Brennan
 
PPT
UserCentric Identity based Service Invocation
guestd5dde6
 
PPT
HTTP
spacecharge
 
PDF
Using Communication and Messaging API in the HTML5 World
Gil Fink
 
PPTX
JWT Authentication with AngularJS
robertjd
 
PPTX
HTTP Services & REST API Security
Taiseer Joudeh
 
PDF
What the Heck is OAuth and OIDC - UberConf 2018
Matt Raible
 
PPTX
Demystifying REST
Kirsten Hunter
 
PPT
Pentesting web applications
Satish b
 
PPTX
Protecting your APIs with Doorkeeper and OAuth 2.0
Mads Toustrup-Lønne
 
PPTX
Леонід Кузьмін “Сам собі паблішер. Від сайту ігрової студії до універсального...
Lviv Startup Club
 
PDF
Some OAuth love
Nicolas Blanco
 
REST API Security: OAuth 2.0, JWTs, and More!
Stormpath
 
Token Authentication for Java Applications
Stormpath
 
Scalable Reliable Secure REST
guestb2ed5f
 
Api security
teodorcotruta
 
Ch 3: Web Application Technologies
Sam Bowne
 
Securing REST APIs
Claire Hunsaker
 
OAuth and OEmbed
leahculver
 
Facebook & Twitter API
Fabrice Delhoste
 
Building Awesome APIs with Lumen
Kit Brennan
 
UserCentric Identity based Service Invocation
guestd5dde6
 
Using Communication and Messaging API in the HTML5 World
Gil Fink
 
JWT Authentication with AngularJS
robertjd
 
HTTP Services & REST API Security
Taiseer Joudeh
 
What the Heck is OAuth and OIDC - UberConf 2018
Matt Raible
 
Demystifying REST
Kirsten Hunter
 
Pentesting web applications
Satish b
 
Protecting your APIs with Doorkeeper and OAuth 2.0
Mads Toustrup-Lønne
 
Леонід Кузьмін “Сам собі паблішер. Від сайту ігрової студії до універсального...
Lviv Startup Club
 
Some OAuth love
Nicolas Blanco
 
Ad

More from Stormpath (20)

PDF
The Ultimate Guide to Mobile API Security
Stormpath
 
PDF
Getting Started With Angular
Stormpath
 
PDF
Building Beautiful REST APIs with ASP.NET Core
Stormpath
 
PDF
Build a REST API for your Mobile Apps using Node.js
Stormpath
 
PDF
JWTs in Java for CSRF and Microservices
Stormpath
 
PPTX
Beautiful REST+JSON APIs with Ion
Stormpath
 
PPTX
Storing User Files with Express, Stormpath, and Amazon S3
Stormpath
 
PPTX
Custom Data Search with Stormpath
Stormpath
 
PDF
Building Beautiful REST APIs in ASP.NET Core
Stormpath
 
PPTX
Browser Security 101
Stormpath
 
PPTX
JWTs for CSRF and Microservices
Stormpath
 
PPTX
Instant Security & Scalable User Management with Spring Boot
Stormpath
 
PPTX
Token Authentication in ASP.NET Core
Stormpath
 
PDF
Mobile Authentication for iOS Applications - Stormpath 101
Stormpath
 
PPTX
Spring Boot Authentication...and More!
Stormpath
 
PPTX
Multi-Tenancy with Spring Boot
Stormpath
 
PPTX
Secure API Services in Node with Basic Auth and OAuth2
Stormpath
 
PPTX
Stormpath 101: Spring Boot + Spring Security
Stormpath
 
PDF
Securing Web Applications with Token Authentication
Stormpath
 
PPTX
How to Use Stormpath in angular js
Stormpath
 
The Ultimate Guide to Mobile API Security
Stormpath
 
Getting Started With Angular
Stormpath
 
Building Beautiful REST APIs with ASP.NET Core
Stormpath
 
Build a REST API for your Mobile Apps using Node.js
Stormpath
 
JWTs in Java for CSRF and Microservices
Stormpath
 
Beautiful REST+JSON APIs with Ion
Stormpath
 
Storing User Files with Express, Stormpath, and Amazon S3
Stormpath
 
Custom Data Search with Stormpath
Stormpath
 
Building Beautiful REST APIs in ASP.NET Core
Stormpath
 
Browser Security 101
Stormpath
 
JWTs for CSRF and Microservices
Stormpath
 
Instant Security & Scalable User Management with Spring Boot
Stormpath
 
Token Authentication in ASP.NET Core
Stormpath
 
Mobile Authentication for iOS Applications - Stormpath 101
Stormpath
 
Spring Boot Authentication...and More!
Stormpath
 
Multi-Tenancy with Spring Boot
Stormpath
 
Secure API Services in Node with Basic Auth and OAuth2
Stormpath
 
Stormpath 101: Spring Boot + Spring Security
Stormpath
 
Securing Web Applications with Token Authentication
Stormpath
 
How to Use Stormpath in angular js
Stormpath
 
Ad

Recently uploaded (20)

PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 

Secure Your REST API (The Right Way)

  • 1. Les Hazlewood @lhazlewood Apache Shiro PMC Chair CTO, Stormpath stormpath.com Secure your REST API (the right way)
  • 2. .com • User Management and Authentication API • Security for your applications • User security workflows • Security best practices • Developer tools, SDKs, libraries
  • 4. ... is all about the headers Learn more at Stormpath.com
  • 5. 1. Request GET /accounts/x2b4jX3l31uiL HTTP/1.1 Host: api.acme.com Learn more at Stormpath.com
  • 6. 2. Challenge Response HTTP/1.1 401 Unauthorized WWW-Authenticate: Basic realm=“name” Learn more at Stormpath.com
  • 7. 3. Resubmit Request GET /accounts/x2b4jX3l31uiL HTTP/1.1 Host: api.acme.com Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Learn more at Stormpath.com
  • 8. Authorization Header Format GET /accounts/x2b4jX3l31uiL HTTP/1.1 Host: api.acme.com Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Scheme Name Scheme-specific Value sp Learn more at Stormpath.com
  • 9. 4. Successful Response HTTP/1.1 200 OK Content-Type: application/json ... { “email”: “[email protected]”, “givenName”: “Joe”, “surname”: Smith”, ... } Learn more at Stormpath.com
  • 10. Example: Oauth 1.0a GET /accounts/1234 HTTP/1.1 Host: api.acme.com Authorization: OAuth realm="Photos", oauth_consumer_key="dpf43f3p2l4k3l03", oauth_signature_method="HMAC-SHA1", oauth_timestamp="137131200", oauth_nonce="wIjqoS", oauth_callback="https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fprinter.example.com%2Fready", oauth_signature="74KNZJeDHnMBp0EMJ9ZHt%2FXKycU%3D" Learn more at Stormpath.com
  • 11. Example: Oauth 2 GET /accounts/x2b4jX3l31uiL HTTP/1.1 Host: api.acme.com Authorization: Bearer mF_9.B5f-4.1JqM Learn more at Stormpath.com
  • 12. Example: Oauth 2 MAC GET /accounts/x2b4jX3l31uiL HTTP/1.1 Host: api.acme.com Authorization: MAC id="h480djs93hd8", nonce="264095:dj83hs9s”, mac="SLDJd4mg43cjQfElUs3Qub4L6xE=" Learn more at Stormpath.com
  • 13. Ok, now that’s out of the way • Please avoid Basic Authc if you can. • Favor HMAC-SHA256 digest algorithms over bearer token algorithms • Use Oauth 1.0a or Oauth 2 (preferably MAC) • Only use a custom scheme if you really, really know what you’re doing. Learn more at Stormpath.com
  • 14. Status Codes Learn more at Stormpath.com
  • 15. 401 vs 403 • 401 “Unauthorized” really means Unauthenticated “You need valid credentials for me to respond to this request” • 403 “Forbidden” really means Unauthorized “I understood your credentials, but so sorry, you’re not allowed!” Learn more at Stormpath.com
  • 16. HTTP Authorization Learn more at Stormpath.com
  • 17. HTTP Authorization • After authc, perform authz • Filter requests before invoking MVC layer • Blanket security policies • Per-URI customization Learn more at Stormpath.com
  • 18. HTTP Authorization: OAuth • OAuth is an authorization protocol, NOT an authentication or SSO protocol. • “Can I see User X’s email address please?” NOT: • “I want to authenticate User X w/ this username and password” • People still try to use OAuth for authentication (OpenId Connect) Learn more at Stormpath.com
  • 19. HTTP Authorization: OAuth • When OAuth 2 is a good fit: • If your REST clients do NOT own the data they are attempting to read • When Oauth 2 isn’t as good of a fit: • If your REST client owns the data it is reading • Could still be fine if you’re willing to incur some additional overhead Learn more at Stormpath.com
  • 20. HTTP Authorization: JWT • JWT = JSON Web Token • Very new spec, but clean & simple • JWTs can be digitally signed and/or encrypted, and are URL friendly. • Can be used as Bearer Tokens and for SSO Learn more at Stormpath.com
  • 21. Best Practices Learn more at Stormpath.com
  • 22. API Keys Learn more at Stormpath.com
  • 23. API Keys, Not Passwords • Entropy • Independence • Speed • Reduced Exposure • Traceability • Rotation Learn more at Stormpath.com
  • 24. API Keys cont’d • Authenticate every request • Encrypt API Key secret values at rest. • Avoid Sessions (not RESTful) • Authc every request + no sessions = no XSRF attacks Learn more at Stormpath.com
  • 25. Identifiers Learn more at Stormpath.com
  • 27. Identifiers • Should be opaque • Secure Random or Random/Time UUID • URL-friendly ‘Base62’ encoding • Avoid sequential numbers: • distribute ID generation load • mitigate fusking attacks Learn more at Stormpath.com
  • 28. Query Injection Learn more at Stormpath.com
  • 29. Query Injection Vulnerable URL: foo.com/accounts?acctId=‘ or ‘1’=‘1 String query = “select * from accounts where acct_id = ‘” + request.getParameter(“acctId”) + “’”; Solution • Use Parameterized Query API (Prepared Statements). • If not available, escape special chars Learn more at Stormpath.com
  • 30. Redirects and Forwards Learn more at Stormpath.com
  • 31. Redirects and Forwards • Avoid redirects and forwards if possible • If used, validate the value and ensure authorized for the current user. foo.com/redirect.jsp?url=evil.com foo.com/whatever.jsp?fwd=admin.jsp Learn more at Stormpath.com
  • 32. TLS Learn more at Stormpath.com
  • 33. TLS • Use TLS for everything • Once electing to TLS: – Never revert – Never switch back and forth • Cookies: set the ‘secure’ and ‘httpOnly’ flags for secure cookies • Backend/infrastructure connections use TLS too Learn more at Stormpath.com
  • 34. TLS Cont’d • Configure your SSL provider to only support strong (FIPS 140-2 compliant) algorithms • Use Cipher Suites w/ Perfect Forward Secrecy! –e.g. ECDHE_RSA_WITH_AES_256_GCM_SHA256 • Keep your TLS certificates valid • But beware, TLS isn’t foolproof – App-level encryption + TLS for most secure results Learn more at Stormpath.com
  • 36. Configuration • CI: Security Testing • Security Patches • Regularly scan/audit • Same config in Dev, Prod, QA* – (Docker is great for this!) • Externalize passwords/credentials * Except credentials of course Learn more at Stormpath.com
  • 37. Storage Learn more at Stormpath.com
  • 38. Storage • Sensitive data encrypted at rest • Encrypt offsite backups • Strong algorithms/standards • Strong encryption keys and key mgt • Strong password hashing • External key storage • Encrypted file system (e.g. eCryptfs) Learn more at Stormpath.com
  • 39. Thank You! • [email protected] Twitter: @lhazlewood • https://stormpath.com Learn more at Stormpath.com
  • 40. .com • Free for developers • Eliminate months of development • Automatic security best practices Sign Up Now: Stormpath.com Learn more at Stormpath.com