In our application the user is allowed to download a file by pressing a context menu button. At the moment we achieve this functionality by creating and appending an iframe
to the dom with a src
attribute that points to the file's location on the server.
We recently added CSRF
protection to the application and as you can guess issues arose with the file download issue. This is easily solvable by providing the csrf token as a query param but ultimately defeats the purpose of the protection method and exposes the token to listeners.
Is there a way to trigger a file download (i.e. after pressing the "Download File" button trigger the native Save as...
dialog) using a request with configurable Http Headers
?
Note that even though the data itself will not be exposed to the attacker's site we also want to avoid having multiple such heavy requests be sent to the server by a malicious page, thus needing the CSRF protection.
Finally please keep in mind that we must remain compatible with up to Internet Explorer 10 which might restrict our options (for example download
attribute in anchor elements does not work there).