Back to Freecodecamp

Prevent IE from Opening Untrusted HTML with helmet.ieNoOpen()

curriculum/challenges/english/blocks/information-security-with-helmetjs/587d8248367417b2b2512c3b.md

latest1.0 KB
Original Source

--description--

As a reminder, this project is being built upon the following starter project cloned from <a href="https://github.com/freeCodeCamp/boilerplate-infosec/" target="_blank" rel="noopener noreferrer nofollow">GitHub</a>.

Some web applications will serve untrusted HTML for download. Some versions of Internet Explorer by default open those HTML files in the context of your site. This means that an untrusted HTML page could start doing bad things in the context of your pages. This middleware sets the X-Download-Options header to noopen. This will prevent IE users from executing downloads in the trusted site's context.

--instructions--

Use the helmet.ieNoOpen() method on your server.

--hints--

helmet.ieNoOpen() middleware should be mounted correctly

js
const response = await fetch(code + '/_api/app-info');
if (!response.ok) {
  throw Error(await response.text());
}
const data = await response.json();
assert.include(data.appStack, 'ienoopen');
assert.equal(data.headers['x-download-options'], 'noopen');