Http Header — X-download-options __top__
: Enable the headers module and add this to your .htaccess or site config: Header set X-Download-Options "noopen"
: Use the Helmet middleware, which includes this header by default: app.use(helmet.ieNoOpen()); ASP.NET Core : Use specialized middleware like NWebsec . 4. Browser Support and Legacy Status
The X-Download-Options header addresses this by removing the "Open" button from the download dialog, leaving only "Save" and "Cancel". This ensures the content runs in a local, restricted context rather than the site's domain context. 2. Header Syntax and Values There is only one valid directive for this header: X-Download-Options: noopen Use code with caution. Description http header x-download-options
When a user downloads a file (like an .html file), some browsers provide an "Open" option. If selected, the browser renders the file immediately, often within the security context of the hosting domain. A malicious file could then execute scripts to access that domain's: and session data. Local Storage . Security Context , bypassing the Same-Origin Policy (SOP) .
The X-Download-Options HTTP response header is a security mechanism designed to prevent Internet Explorer 8 (and later) from automatically opening downloaded files in the browser's context. By forcing users to save files locally before opening them, it mitigates Cross-Site Scripting (XSS) risks associated with untrusted HTML uploads. 1. Purpose and Mechanism : Enable the headers module and add this to your
The X-Download-Options header was specifically created for and above.
: These browsers typically handle downloads more securely by default, often opening them in a sandboxed or local context that lacks access to site-specific data. 5. Security Context & Best Practices This ensures the content runs in a local,
You can implement this header at the server or application level:

