SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Securing Single Page Applications
with
Token Based Authentication
Stefan Achtsnit
WeAreDevelopers Conference
April 2016
Outline
• Single Page Application Security
• Token Based Authentication
Client Tokens
JSON Web Token format
• Web Application Security 101
Cross-site scripting
Cross-site request forgery -> Double submit cookie
• Implementation Challenges
Who should be in charge of the authentication token – JS
client or Browser?
How to revoke issued tokens?
Single Page Application Security
• no sensitive information like keys on clients
• prevent malicious code from running in your
application (Cross-site scripting – see upcoming slide)
• secure user credentials (Man-in-the-middle attacks)
• strive for consistent authorization, i.e. UI rendering
based on same rules as used for API (Client Tokens)
Client Tokens
• self-contained set of claims that assert an identity and
a scope of access that can be shared (no silo)
{
"subject": "jdoe",
"name": "John Doe",
"admin": true,
"expiration": 12-04-2016 23:55 UTC
}
• signed and optionally encrypted
• flexible, e.g. extend with "issuer“ claim for verification,
add application specific ACLs
• stateless (token revocation - see upcoming slide)
JSON Web Token (JWT) format
• de facto standard token format
• sign with strong key and always verify token
• encrypt for sensitive information (JSON Web Encryption)
• security considerations as for session identifiers
Cross-site scripting (XSS)
• attacker pushes malicious JS code into application
• canonical example: script tag in user comment
• various categories like stored, reflected or DOM-based
attacks
• OWASP - XSS Prevention Cheat Sheet
• always validate user input and escape everything
• be careful with dynamically loaded JSON, CSS, HTML
templates,…
• Content Security Policy (CSP)
• 3rd party JS libraries are still problematic, everything
accessible by JS like tokens stored in web storage may
be exposed -> possible alternative: use cookie storage
with HttpOnly flag for tokens
Cross-site request forgery (CSRF)
• browser automatically sends cookies set on a given domain with every
request made to that domain (regardless of where those requests
originated)
• OWASP - CSRF Prevention Cheat Sheet
• no side effects with HTTP GET
• use Double submit cookie with HTTP POST for SPAs
Double submit cookie
• create random value during authentication process
• add this value as additional claim to the provided client token
e.g. {
"subject": “jdoe",
"name": "John Doe",
"admin": true,
"expiration": 12-04-2016 23:55 UTC,
"xsrfToken": 63be08af-0264-47af-b2b9-6d56e8f6428a
}
• put this value in further authentication cookie (with HttpOnly cookie
flag set to false), so that JS client can read value and forward it with
corresponding HTTP header in subsequent requests
• server side API code can compare client token claim with submitted
HTTP header value during token verification (stateless!)
• protection based on same-origin policy for cookies - only JS code
running on the origin domain can read this second cookie!
Request Flow Example
JS client Browser
Transmission Authorization: Bearer <JWT>
manual coding effort, only when
necessary, works with any domain
(Cross-Origin Resource Sharing)
Cookie: token=<JWT>
automatically sent, overhead when
not necessary, not possible across
domains i.e. with external APIs
Storage various options, e.g.
• web storage (accessible only
from storing subdomain, 5MB
limit)
• cookie storage (accessible from
multiple subdomains, 4KB limit)
cookie storage
MITM SSL must be managed by code Secure cookie flag forces SSL
XSS manual coding effort implicit with HttpOnly cookie flag to
prevent JS access
CSRF not applicable manual coding effort (e.g. Double
submit cookie)
Who is in charge of the token?
How to revoke tokens?
Renewal approach Blacklisting approach
Characteristic stateless stateful
Mechanism two kinds of tokens used: Access
Tokens as usual with a short
expiration and Refresh Token
with a longer expiration for the
renewal of Access Tokens when
they expire (OAuth2!)
Identifier ("jti" claim) added to Access
Token and checked against blacklist
during token verification
Consequence client flow implementation not
trivial, additional server logic
only within authentication API
transparent for client, blacklist must
be available to all server APIs
Recommendation
• follow a token based approach with JWT
• avoid cross-domain architecture if possible
• CSRF protection is easy to get right, XSS protection is easy to get wrong
store token in cookie with HttpOnly (XSS) and Secure flag (MITM)
use Double submit cookie (CSRF)
• start with a simple token revocation mechanism
• do your homework and don’t reinvent the world
Open Web Application Security Project (OWASP)
https://www.owasp.org/index.php/Top_10_2013
https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_She
et
https://www.owasp.org/index.php/Cross-
Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet
JSON Web Token
https://jwt.io
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

Rest Security with JAX-RS
Rest Security with JAX-RSRest Security with JAX-RS
Rest Security with JAX-RS
Frank Kim
 
Mohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuthMohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuth
fossmy
 
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
Hermann Burgmeier
 

Was ist angesagt? (20)

Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
Rest Security with JAX-RS
Rest Security with JAX-RSRest Security with JAX-RS
Rest Security with JAX-RS
 
JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2
 
Mohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuthMohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuth
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
 
Best Practices in Building an API Security Ecosystem
Best Practices in Building an API Security EcosystemBest Practices in Building an API Security Ecosystem
Best Practices in Building an API Security Ecosystem
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)
 
ConFoo 2015 - Securing RESTful resources with OAuth2
ConFoo 2015 - Securing RESTful resources with OAuth2ConFoo 2015 - Securing RESTful resources with OAuth2
ConFoo 2015 - Securing RESTful resources with OAuth2
 
API Security & Federation Patterns - Francois Lascelles, Chief Architect, Lay...
API Security & Federation Patterns - Francois Lascelles, Chief Architect, Lay...API Security & Federation Patterns - Francois Lascelles, Chief Architect, Lay...
API Security & Federation Patterns - Francois Lascelles, Chief Architect, Lay...
 
Securing REST APIs
Securing REST APIsSecuring REST APIs
Securing REST APIs
 
Super simple application security with Apache Shiro
Super simple application security with Apache ShiroSuper simple application security with Apache Shiro
Super simple application security with Apache Shiro
 
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
 
2016 pycontw web api authentication
2016 pycontw web api authentication 2016 pycontw web api authentication
2016 pycontw web api authentication
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
Demystifying OAuth 2.0
Demystifying OAuth 2.0Demystifying OAuth 2.0
Demystifying OAuth 2.0
 
Building an API Security Ecosystem
Building an API Security EcosystemBuilding an API Security Ecosystem
Building an API Security Ecosystem
 
OAuth - Open API Authentication
OAuth - Open API AuthenticationOAuth - Open API Authentication
OAuth - Open API Authentication
 
Making Sense of API Access Control
Making Sense of API Access ControlMaking Sense of API Access Control
Making Sense of API Access Control
 
Oauth 2.0 security
Oauth 2.0 securityOauth 2.0 security
Oauth 2.0 security
 
Token Based Authentication Systems with AngularJS & NodeJS
Token Based Authentication Systems with AngularJS & NodeJSToken Based Authentication Systems with AngularJS & NodeJS
Token Based Authentication Systems with AngularJS & NodeJS
 

Ă„hnlich wie Securing Single Page Applications with Token Based Authentication

WSO2Con US 2013 - Advanced API Management Tactics
WSO2Con US 2013 - Advanced API Management TacticsWSO2Con US 2013 - Advanced API Management Tactics
WSO2Con US 2013 - Advanced API Management Tactics
WSO2
 
How the SSL/TLS protocol works (very briefly) How to use HTTPS
How the SSL/TLS protocol works  (very briefly) How to use HTTPSHow the SSL/TLS protocol works  (very briefly) How to use HTTPS
How the SSL/TLS protocol works (very briefly) How to use HTTPS
whj76337
 

Ă„hnlich wie Securing Single Page Applications with Token Based Authentication (20)

Securing Web Applications with Token Authentication
Securing Web Applications with Token AuthenticationSecuring Web Applications with Token Authentication
Securing Web Applications with Token Authentication
 
Building Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTsBuilding Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTs
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
WSO2Con US 2013 - Advanced API Management Tactics
WSO2Con US 2013 - Advanced API Management TacticsWSO2Con US 2013 - Advanced API Management Tactics
WSO2Con US 2013 - Advanced API Management Tactics
 
Token Authentication for Java Applications
Token Authentication for Java ApplicationsToken Authentication for Java Applications
Token Authentication for Java Applications
 
15-auth-session-mgmt.ppt
15-auth-session-mgmt.ppt15-auth-session-mgmt.ppt
15-auth-session-mgmt.ppt
 
DataPower Restful API Security
DataPower Restful API SecurityDataPower Restful API Security
DataPower Restful API Security
 
How the SSL/TLS protocol works (very briefly) How to use HTTPS
How the SSL/TLS protocol works  (very briefly) How to use HTTPSHow the SSL/TLS protocol works  (very briefly) How to use HTTPS
How the SSL/TLS protocol works (very briefly) How to use HTTPS
 
Spring4 security
Spring4 securitySpring4 security
Spring4 security
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-Orru
 
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
 
CNIT 129S: Ch 7: Attacking Session Management
CNIT 129S: Ch 7: Attacking Session Management CNIT 129S: Ch 7: Attacking Session Management
CNIT 129S: Ch 7: Attacking Session Management
 
526_topic08.ppt
526_topic08.ppt526_topic08.ppt
526_topic08.ppt
 
Chapter 13 web security
Chapter 13 web securityChapter 13 web security
Chapter 13 web security
 
Complete Guide to Setup Secure Scheme for Restful APIs
Complete Guide to Setup Secure Scheme for Restful APIsComplete Guide to Setup Secure Scheme for Restful APIs
Complete Guide to Setup Secure Scheme for Restful APIs
 
Top 10 Web Hacks 2012
Top 10 Web Hacks 2012Top 10 Web Hacks 2012
Top 10 Web Hacks 2012
 
API Security : Patterns and Practices
API Security : Patterns and PracticesAPI Security : Patterns and Practices
API Security : Patterns and Practices
 
Token Handler Pattern
Token Handler PatternToken Handler Pattern
Token Handler Pattern
 

KĂĽrzlich hochgeladen

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

KĂĽrzlich hochgeladen (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Securing Single Page Applications with Token Based Authentication

  • 1. Securing Single Page Applications with Token Based Authentication Stefan Achtsnit WeAreDevelopers Conference April 2016
  • 2. Outline • Single Page Application Security • Token Based Authentication Client Tokens JSON Web Token format • Web Application Security 101 Cross-site scripting Cross-site request forgery -> Double submit cookie • Implementation Challenges Who should be in charge of the authentication token – JS client or Browser? How to revoke issued tokens?
  • 3. Single Page Application Security • no sensitive information like keys on clients • prevent malicious code from running in your application (Cross-site scripting – see upcoming slide) • secure user credentials (Man-in-the-middle attacks) • strive for consistent authorization, i.e. UI rendering based on same rules as used for API (Client Tokens)
  • 4. Client Tokens • self-contained set of claims that assert an identity and a scope of access that can be shared (no silo) { "subject": "jdoe", "name": "John Doe", "admin": true, "expiration": 12-04-2016 23:55 UTC } • signed and optionally encrypted • flexible, e.g. extend with "issuer“ claim for verification, add application specific ACLs • stateless (token revocation - see upcoming slide)
  • 5. JSON Web Token (JWT) format • de facto standard token format • sign with strong key and always verify token • encrypt for sensitive information (JSON Web Encryption) • security considerations as for session identifiers
  • 6. Cross-site scripting (XSS) • attacker pushes malicious JS code into application • canonical example: script tag in user comment • various categories like stored, reflected or DOM-based attacks • OWASP - XSS Prevention Cheat Sheet • always validate user input and escape everything • be careful with dynamically loaded JSON, CSS, HTML templates,… • Content Security Policy (CSP) • 3rd party JS libraries are still problematic, everything accessible by JS like tokens stored in web storage may be exposed -> possible alternative: use cookie storage with HttpOnly flag for tokens
  • 7. Cross-site request forgery (CSRF) • browser automatically sends cookies set on a given domain with every request made to that domain (regardless of where those requests originated) • OWASP - CSRF Prevention Cheat Sheet • no side effects with HTTP GET • use Double submit cookie with HTTP POST for SPAs
  • 8. Double submit cookie • create random value during authentication process • add this value as additional claim to the provided client token e.g. { "subject": “jdoe", "name": "John Doe", "admin": true, "expiration": 12-04-2016 23:55 UTC, "xsrfToken": 63be08af-0264-47af-b2b9-6d56e8f6428a } • put this value in further authentication cookie (with HttpOnly cookie flag set to false), so that JS client can read value and forward it with corresponding HTTP header in subsequent requests • server side API code can compare client token claim with submitted HTTP header value during token verification (stateless!) • protection based on same-origin policy for cookies - only JS code running on the origin domain can read this second cookie!
  • 10. JS client Browser Transmission Authorization: Bearer <JWT> manual coding effort, only when necessary, works with any domain (Cross-Origin Resource Sharing) Cookie: token=<JWT> automatically sent, overhead when not necessary, not possible across domains i.e. with external APIs Storage various options, e.g. • web storage (accessible only from storing subdomain, 5MB limit) • cookie storage (accessible from multiple subdomains, 4KB limit) cookie storage MITM SSL must be managed by code Secure cookie flag forces SSL XSS manual coding effort implicit with HttpOnly cookie flag to prevent JS access CSRF not applicable manual coding effort (e.g. Double submit cookie) Who is in charge of the token?
  • 11. How to revoke tokens? Renewal approach Blacklisting approach Characteristic stateless stateful Mechanism two kinds of tokens used: Access Tokens as usual with a short expiration and Refresh Token with a longer expiration for the renewal of Access Tokens when they expire (OAuth2!) Identifier ("jti" claim) added to Access Token and checked against blacklist during token verification Consequence client flow implementation not trivial, additional server logic only within authentication API transparent for client, blacklist must be available to all server APIs
  • 12. Recommendation • follow a token based approach with JWT • avoid cross-domain architecture if possible • CSRF protection is easy to get right, XSS protection is easy to get wrong store token in cookie with HttpOnly (XSS) and Secure flag (MITM) use Double submit cookie (CSRF) • start with a simple token revocation mechanism • do your homework and don’t reinvent the world Open Web Application Security Project (OWASP) https://www.owasp.org/index.php/Top_10_2013 https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_She et https://www.owasp.org/index.php/Cross- Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet JSON Web Token https://jwt.io Thank you!

Hinweis der Redaktion

  1. JSON Web Token format rules the world
  2. common attack vectors in web application security
  3. Open Web Application Security Project (OWASP) pages are excellent resource with the switch from server side web applications to SPAs you’ll find yourself building access control logic several times, for your front end and your back end
  4. pass real assertions and not just a session identifier structured way to declare who a user is and what they can access - they can be used by your UI and your backend to make decisions, they can be shared, compare that to a session identifier, a session id hast no meaning per se, sessions are silo, you need to look them up somewhere to figure out the information and they only have a meaning within your system freedom to design your own access control language - just include what makes sense for your application
  5. JSON Web Token (JWT) specification is gaining traction quickly
  6. browser has no way of telling the difference between good or bad code - from the browser’s perspective, the script originated from the web application, so it is automatically treated as a trusted resource far from full story can’t ensure protection against XSS attacks you shouldn’t make authentication information - regardless if it is a session identifier or a JWT - accessible to JS
  7. Synchronizer Token (aka Anti Forgery Token), where a dynamic hidden variable is added to any input form Origin header which can’t be set by JS client