retire.js is a free, open source build & deployment project written in JavaScript and released under Apache-2.0. It has 4,173 GitHub stars, 440 forks and 2 open issues, and was last pushed 4 days ago. On this registry it ranks #35 of 59 tracked projects in Build & Deployment, with 5 head-to-head comparisons available.

What is retire.js?

What it is

Retire.js is an open-source JavaScript security scanner for web and Node.js projects. It lives in the JavaScript software-composition-analysis ecosystem and is distributed under the Apache-2.0 license. The project detects JavaScript libraries and Node.js modules with known vulnerabilities, including libraries downloaded into source control rather than listed in a package manifest.

The problem it addresses is shipping outdated or insecure dependencies. The README notes that JavaScript libraries accelerate development but require ongoing maintenance, and that “Using Components with Known Vulnerabilities” was added to the OWASP Top 10 in 2013. Retire.js helps developers find vulnerable library versions before or during deployment.

Key capabilities

  • It scans web and Node.js applications for JavaScript libraries and Node.js modules with known vulnerabilities.
  • It generates CycloneDX software bills of materials, including CycloneDX 1.4 XML and JSON variants for CycloneDX 1.4, 1.6, and 1.7.
  • It provides cyclonedxJSON1_6_VEX and cyclonedxJSON1_7_VEX variants that also include a vulnerabilities section.
  • It runs as a command-line tool and exits with code 13 by default when vulnerabilities are found unless overridden with --exitwith 0.
  • It supports Chrome extension scanning, Burp and OWASP ZAP integrations, a headless site scanner, and deprecated Grunt and Gulp tasks.

Who uses it and how

  • Developers run the command-line scanner in an application source folder to identify vulnerable JavaScript dependencies during local development or build processes.
  • Browser users install the Chrome extension to scan visited sites and see warnings about insecure libraries in the developer console.
  • Penetration testers use the Burp extension or OWASP ZAP add-on to include Retire.js scanning in interactive web application testing.
  • Build engineers use the headless site scanner or deprecated Grunt and Gulp tasks to scan deployed sites or project files automatically.

Getting started

The typical command-line installation is to install Node.js and npm, run npm install -g retire, and execute retire inside the source folder of the application.

When to use it — and when not to

Retire.js is useful when a team needs an open-source scanner for JavaScript libraries and wants CycloneDX SBOM output in a build or security workflow. It is less suitable when a project needs one maintained integration path, because the Firefox extension, Grunt plugin, and Gulp task are deprecated, and the Chrome extension is not officially available in the Chrome web store. Users must also operate the scanner through local Node.js and npm, browser extensions, Burp, OWASP ZAP, or the headless site scanner.

project readme (upstream, from github) — read inline

Retire.js

What you require you must also retire

There is a vast ecosystem of JavaScript libraries available for both web and Node.js applications. While these libraries significantly accelerate development, they also require ongoing maintenance to ensure security vulnerabilities are addressed promptly. In 2013, “Using Components with Known Vulnerabilities” was added to the OWASP Top 10 list of critical security risks, highlighting the serious threat that outdated or insecure dependencies can pose to web applications. Retire.js was created to help developers identify JavaScript library versions with known vulnerabilities, especially those that are not in package manifests, but simply downloaded and put in source control.

Retire.js can be used in many ways:

  1. As command line scanner
  2. As a Chrome extension - Not officially available in the Chrome web store
  3. As a Burp Extension or OWASP ZAP Add-on
  4. As a Firefox extension - Deprecated Let us know if you want to maintain and undeprecate it.
  5. A headless web site scanner
  6. As a grunt plugin (deprecated)
  7. As a gulp task (deprecated)

Command line scanner

Scan a web app or node app for use of vulnerable JavaScript libraries and/or Node.JS modules. If you haven't already, you need to install node/npm first. In the source code folder of the application folder run:

$ npm install -g retire
$ retire

SBOM generation

retire.js can generate SBOMs in the CycloneDX-format:

$ retire --outputformat cyclonedx

cyclonedx produces CycloneDX 1.4 XML. For JSON, and for newer spec versions, use cyclonedxJSON (1.4), cyclonedxJSON1_6 or cyclonedxJSON1_7. The cyclonedxJSON1_6_VEX and cyclonedxJSON1_7_VEX variants also include a vulnerabilities section.

By default retire.js will exit with code 13 if it finds vulnerabilities. This can be overridden with --exitwith 0.

Chrome and firefox extensions

Scans visited sites for references to insecure libraries, and puts warnings in the developer console. An icon on the address bar displays will also indicate if vulnerable libraries were loaded.

Burp Extension and OWASP ZAP Add-on

@h3xstream has adapted Retire.js as a plugin for the penetration testing tools Burp and OWASP ZAP.

The OWASP ZAP team officially supports a Retire.js add-on which is available via the ZAP Marketplace and is included by default in the ZAP weekly releases: https://www.zaproxy.org/docs/desktop/addons/retire.js/

Headless site scanner

The retire-site-scanner https://github.com/RetireJS/retire-site-scanner can be used to scan a web site in headless mode (as opposed to using the chrome/firefox extensions)

Grunt plugin (deprecated)

A Grunt task for running Retire.js as part of your application's build routine, or some other automated workflow.

Gulp task (deprecated)

An example of a Gulp task which can be used in your gulpfile to watch and scan your project files automatically. You can modify the watch patterns and (optional) Retire.js options as you like.

const c = require("ansi-colors");

var gulp = require("gulp");
var beeper = require("beeper");
var log = require("fancy-log");
var spawn = require("child_process").spawn;

gulp.task("retire:watch", ["retire"], function (done) {
  // Watch all javascript files and package.json
  gulp.watch(["js/**/*.js", "package.json"], ["retire"]);
});

gulp.task("retire", function () {
  // Spawn Retire.js as a child process
  // You can optionally add option parameters to the second argument (array)
  var child = spawn("retire", [], { cwd: process.cwd() });

  child.stdout.setEncoding("utf8");
  child.stdout.on("data", function (data) {
    log(data);
  });

  child.stderr.setEncoding("utf8");
  child.stderr.on("data", function (data) {
    log(c.red(data));
    beeper();
  });
});

Donate

Donations will be used to fund the maintainance of the tool and vulnerability repo.

Frequently asked questions

Is retire.js free to use?

retire.js is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does retire.js do?

scanner detecting the use of JavaScript libraries with known vulnerabilities. Can also generate an SBOM of the libraries it finds.

What is retire.js written in?

retire.js is primarily written in JavaScript. Its source is publicly available at https://github.com/RetireJS/retire.js, and it has 4,173 GitHub stars.