Skip to Content
Outdated JavaScript dependencies and security vulnerabilities

Outdated JavaScript Dependencies

What outdated JavaScript dependencies expose (XSS, prototype pollution, RCE), how to find them with npm audit, Snyk and OSV-Scanner, and how to keep them patched.

Sep 19, 2025
Updated Nov 22, 2026
9 min read

Description

An application with outdated JavaScript dependencies ships library versions that have published vulnerabilities. The bugs are documented in the NVD and the GitHub Advisory Database, and many come with public exploit code, so the work of finding the flaw has already been done.

npm, yarn and pnpm make it cheap to pull in packages, and each package pulls in its own. A typical application ends up with hundreds or thousands of transitive dependencies (dependencies of dependencies). Most of them nobody on the team chose directly, and any one of them can be the vulnerable version.

Testers and attackers look for these because the vulnerability is already public, exploit code often exists, update cycles slip, and transitive packages rarely get reviewed at all.

Supply chain angle

A vulnerable or compromised package affects every application downstream of it. One bad release of a popular library can reach thousands of projects.

Impact

Depends entirely on the library and where it runs:

Bug classTypical source
Cross-site scriptingOld front-end libraries (jQuery, template helpers) that write unsanitized HTML
Remote code executionServer-side packages that deserialize or evaluate input
Prototype pollutionDeep-merge and query-string helpers; can lead to RCE or privilege escalation depending on the gadgets available
Denial of serviceRegular expressions with catastrophic backtracking (ReDoS), unbounded parsing
Data theftMalicious package releases that read environment variables and API keys
Authentication bypassBugs in token validation libraries
Path traversalArchive extraction and file-serving packages

Common vulnerable dependencies

High-risk categories

CategoryExamplesTypical issue
Serializationserialize-javascript, node-serializeCode injection, RCE
Template engineshandlebars, mustache, pugTemplate injection
Archive and file handlingtar, unzip, yauzlPath traversal during extraction
XML/HTML parsersxml2js, cheerioParser bugs, prototype pollution
Authenticationjsonwebtoken, passportToken validation bypasses
Cryptographycrypto-js, old OpenSSL bindingsWeak defaults and implementations
Image processingsharp, jimpMemory corruption in native code
HTTP clientsrequest, axiosSSRF and redirect handling

Examples of major vulnerabilities

  • lodash before 4.17.12: prototype pollution (CVE-2019-10744)
  • jQuery before 3.5.0: XSS in HTML manipulation methods (CVE-2020-11022, CVE-2020-11023)
  • express before 4.17.3: denial of service (process hang) through a __proto__ key in its bundled qs (CVE-2022-24999)
  • moment before 2.29.2: path traversal in locale loading (CVE-2022-24785)
  • serialize-javascript before 3.1.0: code injection (CVE-2020-7660)
  • handlebars before 4.7.7: RCE through template compilation (CVE-2021-23369)

Detection

Automated vulnerability scanning

npm audit is built into npm and checks the lockfile against the advisory database:

npm audit
npm audit --audit-level high
npm audit --json  # Machine-readable output

yarn audit does the same for Yarn projects:

yarn audit
yarn audit --level high
yarn audit --json

Snyk uses its own vulnerability database and can keep watching a project after the first scan:

npx snyk test
snyk monitor  # Continuous monitoring

Package analysis tools

npm-check-updates lists packages with newer versions available:

npx npm-check-updates
npx ncu -u  # Update package.json

audit-ci fails a CI build when vulnerabilities above a threshold are found:

npx audit-ci --moderate  # Fail on moderate+ vulnerabilities

OSV-Scanner reads lockfiles from many ecosystems and checks them against OSV.dev:

osv-scanner --lockfile package-lock.json

Manual analysis

On a test where you only have the front end, read library versions out of the JavaScript bundles and file banners and look them up in the advisory databases. With source access, read package.json and the lockfile, and trace why a transitive package is present with npm ls <package> or yarn why <package>.

CI/CD integration

Run the audit in the build pipeline:

# GitHub Actions example
- name: Run security audit
  run: |
    npm audit --audit-level high
    npx audit-ci --high

Remediation

Immediate actions

Update dependencies to current stable versions:

npm update
# Or for major version updates
npx npm-check-updates -u && npm install

Apply the fixes npm knows about. --force allows major version bumps, so run the tests afterwards:

npm audit fix
npm audit fix --force  # For breaking changes

Commit the lockfile and install from it, so every build gets the same versions:

# Commit package-lock.json or yarn.lock to version control
npm ci  # Install from lock file exactly

Dependency management strategy

Apply security updates weekly, minor versions monthly and evaluate major upgrades quarterly. Dependabot or Renovate can open the pull requests, with automatic merging for patch-level security fixes and alerts for critical advisories.

Pin versions deliberately. An exact version never moves, ^ accepts minor and patch updates, ~ accepts only patch updates:

{
  "dependencies": {
    "express": "4.18.2",      // Exact version
    "lodash": "^4.17.21",     // Compatible version
    "react": "~18.2.0"        // Approximate version
  }
}

Choosing packages

Before adding a package, check whether it is still maintained, how quickly past advisories were fixed and how many projects depend on it. Fewer dependencies means fewer things to patch: drop unused packages, prefer small focused libraries over large frameworks where it makes sense, and look at bundle analysis output to see what is actually shipped.

Further mitigations

Subresource Integrity (SRI) makes the browser refuse a CDN file whose hash has changed:

<script src="https://cdn.example.com/lib.js"
        integrity="sha384-hash"
        crossorigin="anonymous"></script>

A Content Security Policy limits where scripts can load from. The example below still allows 'unsafe-inline', which gives up most of the XSS protection; drop it if the application can live without inline scripts:

Content-Security-Policy: script-src 'self' 'unsafe-inline' https://trusted-cdn.com

npm audit signatures checks registry signatures and provenance attestations for installed packages. (npm install --package-lock-only only rewrites the lockfile; it does not verify anything.)

npm install --package-lock-only  # Verify integrity
npm audit signatures  # Verify package signatures

Monitoring and alerting

Keep watching after the first scan. Snyk monitoring and GitHub Dependabot alerts both report new advisories against packages you already use:

# Snyk monitoring
snyk monitor

# GitHub security alerts
# Enable in repository settings

Block deployments that would ship high or critical vulnerabilities:

# Fail deployments on high/critical vulnerabilities
script:
  - npm audit --audit-level high || exit 1

Prevention

Development practices

Review new dependencies before they are added and keep a list of approved packages with the reason each one is there. Put dependency checks in code review and CI. For supply chain risk, watch for maintainer changes and unexpected new releases, and publish internal packages to a private registry so a public package with the same name cannot be pulled in by mistake.

Infrastructure controls

A private registry proxy (Verdaccio, Artifactory, Nexus) can cache and scan packages, require approval for new ones and block known-vulnerable versions.

In containers, keep build tooling and dev dependencies out of the runtime image. On current npm, --omit=dev replaces the older --only=production flag used below:

# Multi-stage builds to minimize attack surface
FROM node:18-alpine AS builder
COPY package*.json ./
RUN npm ci --only=production

FROM node:18-alpine AS runtime
COPY --from=builder /app/node_modules ./node_modules

Verification

Testing updated dependencies

Run the test suites after every upgrade:

npm test
npm run e2e-tests
npm run security-tests

Then check the main application flows by hand for behaviour changes, and re-run the audit to confirm nothing new came in with the upgrade:

npm audit --audit-level moderate
npx snyk test

Tracking progress

Count vulnerable dependencies over time, measure how long critical advisories take to patch, and check that every repository is actually scanned. Include dependency analysis in regular penetration tests.

Example configurations

package.json security configuration

{
  "scripts": {
    "audit": "npm audit --audit-level moderate",
    "audit-fix": "npm audit fix",
    "security-check": "npx snyk test && npm audit"
  },
  "engines": {
    "node": ">=18.0.0",
    "npm": ">=8.0.0"
  }
}

GitHub Actions security workflow

name: Security Audit
on: [push, pull_request]
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm ci
      - run: npm audit --audit-level high
      - run: npx snyk test

Dependabot configuration

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    open-pull-requests-limit: 10
    reviewers:
      - "security-team"

References

Next steps

If you find outdated dependencies during a test, map the whole dependency tree, then rank the findings by whether the vulnerable code path is reachable and exposed, not by CVSS alone. A vulnerable server-side parser that handles user input matters far more than a dev-only build tool. Related:

On this page