Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

x-xss-protection

helmetjs1.8mMIT2.0.0TypeScript support: included

Middleware to disable the X-XSS-Protection header

express, security, x-xss-protection

readme

X-XSS-Protection middleware

The X-XSS-Protection HTTP header aimed to offer a basic protection against cross-site scripting (XSS) attacks. However, you probably should disable it, which is what this middleware does.

Many browsers have chosen to remove it because of the unintended security issues it creates. Generally, you should protect against XSS with sanitization and a Content Security Policy. For more, read this GitHub issue.

This middleware sets the X-XSS-Protection header to 0. For example:

const xXssProtection = require("x-xss-protection");

// Set "X-XSS-Protection: 0"
app.use(xXssProtection());

If you truly need the legacy behavior, you can write your own simple middleware and avoid installing this module. For example:

// NOTE: This is probably insecure!
app.use((req, res, next) => {
  res.setHeader("X-XSS-Protection", "1; mode=block");
  next();
});

changelog

Changelog

2.0.0 - 2020-08-02

Changed

  • XSS filtering is now disabled by default. See #230

Removed

1.3.0 - 2019-09-01

Added

  • Added mode: null to disable mode=block

Changed

  • Minor performance improvements with Internet Explorer <9 detection

1.2.0 - 2019-06-15

Added

  • Added TypeScript type definitions. See #8
  • Created a changelog
  • Added some additional package metadata

Changed

  • Updated documentation
  • Excluded some files from npm package

Changes in versions 1.1.0 and below can be found in Helmet's changelog.