I do not understand something with CORS headers:
Let's suppose i have my website on this domain: http://myverynicesite.com
Let's suppose a hacker managed to inject malicious javascript code on my site.
This malicious javascript is sending data to the hacker's website: http://hackerwebsite.com
There is something i do not understand with CORS headers: The header which allow is set on webservice site. So, the hacker will just have to add this header and it will work:
<?php
header("Access-Control-Allow-Origin: http://myverynicesite.com");
?>
I do not understand why CORS does not work with an inverted flow ? I was thinking that myverynicesite.com should allow hackerwebsite.com with CORS. And i see this is hackerwebsite.com which allows myverynicesite.com.
So i do not understand the value add of CORS.
Thanks