JWT with Bearer Token protect from CSRF and XSS whilst using AJAX

Viewed 275

I have a webapp that has a javascript page that makes ajax calls up to the webservices. The authorization scheme used for the site is JWT with bearer tokens being used in the authorization header.

However, I now realize that I am vulnerable to XSS, because the token is being stored in a cookie, and the javascript needs access to this in order to set the bearer token in it's requests. Because of this, httponly is set to false, thus meaning my token can be stolen.

So, what I would like to know is whether there is a way to protect against both CSRF and XSS whilst using ajax requests and JWTs?

0 Answers
Related