freeCodeCamp/curriculum/challenges/italian/09-information-security/information-security-with-h.../disable-dns-prefetching-wit...

1.6 KiB

id title challengeType forumTopicId dashedName
587d8248367417b2b2512c3d Disable DNS Prefetching with helmet.dnsPrefetchControl() 2 301577 disable-dns-prefetching-with-helmet-dnsprefetchcontrol

--description--

As a reminder, this project is being built upon the following starter project on Replit, or cloned from GitHub.

To improve performance, most browsers prefetch DNS records for the links in a page. In that way the destination ip is already known when the user clicks on a link. This may lead to over-use of the DNS service (if you own a big website, visited by millions people…), privacy issues (one eavesdropper could infer that you are on a certain page), or page statistics alteration (some links may appear visited even if they are not). If you have high security needs you can disable DNS prefetching, at the cost of a performance penalty.

--instructions--

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

--hints--

helmet.dnsPrefetchControl() middleware should be mounted correctly

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/app-info').then(
    (data) => {
      assert.include(data.appStack, 'dnsPrefetchControl');
      assert.equal(data.headers['x-dns-prefetch-control'], 'off');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/