Let's analyze the following scenario:
- User authenticates with
session
cookie - I have
CORS
enabled (likeAccess-Control-Allow-Origin: *
- header) - I use
CSRF Token
to preventCSRF
attacks and I include it inHTML
document's body
Is it possible to perform CSRF attack like this?:
(Attack from domain: attack.com
)
- In
atack.dom/index.html
is written script that executesGET
mydomain.com
via e.g.window.fetch
. - This script extracts
CSRF Token
from fetchedmydomain.com/index.html
- It performs then the real
CSRF
attack as it already has validCSRF Token
so it does attach this token to<form>
and submit this prepared<form>
Is it possible? Is enabling CORS possibly making my wesbite vulnerable to CSRF attack despite the fact I'm using CSRF Token
protection?