Lädt...

🔧 Fixing High and Critical Vulnerabilities in npm Using npm audit


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Introduction

  • As a developer, keeping your project dependencies up to date is crucial for maintaining security and performance. The npm audit command helps identify security vulnerabilities in your project dependencies, categorizing them as low, moderate, high, or critical. In this blog, we will go through how to fix high and critical vulnerabilities and how to handle outdated packages that no longer receive security updates.

Running npm audit

  • check for vulnerabilities in your project, run the following command:
npm audit
  • This will generate a report listing all vulnerabilities along with their severity levels. If you find high or critical vulnerabilities, you need to take immediate action.

Understanding npm audit Output

The audit report consists of different sections, such as:

  • Advisory ID – Unique ID assigned to a vulnerability.
  • Module Name – The package containing the vulnerability.
  • Vulnerable Versions – Affected versions of the package.
  • Patched Versions – The versions where the vulnerability is fixed.
  • Dependency Path – Shows how the package is included in your project.

Understanding these details helps you make informed decisions when fixing vulnerabilities.

Fixing Vulnerabilities Automatically

  • In many cases, you can fix vulnerabilities automatically using the following command:
npm audit fix --force

Warning: Using --force can lead to major version upgrades that may break your application. Ensure you test your project thoroughly after applying this command.

Manually Upgrading Packages

If vulnerabilities persist, you may need to manually update specific packages. To check which versions are available, use:

npm outdated

Then, upgrade a package to its latest version using:

npm install package-name@latest

For example:

npm install lodash@latest

If a package has a major version update, read the changelog and test before upgrading.

Overwriting Deprecated or Unsupported Packages

Sometimes, a package may no longer receive security updates, but other dependencies still rely on it. In such cases, you can use overrides in your package.json file.

Add the following section to package.json:

"overrides": {
  "vulnerable-package": "patched-version"
}

For example:

"overrides": {
  "node-forge": "1.3.1"
}

Then, reinstall dependencies:

npm install

Using npx npm-check-updates for Bulk Upgrades

To upgrade all dependencies to their latest versions, you can use the npx npm-check-updates package. Install it globally with:

npm install -g npm-check-updates

Then, check outdated dependencies:

npx npm-check-updates

To update all packages in package.json:

npx npm-check-updates -u

After updating, reinstall dependencies:

npm install

Checking Security After Fixing

Once you've applied fixes, rerun npm audit to verify that all vulnerabilities have been resolved:

npm audit

If no critical or high vulnerabilities remain, your project is now more secure.

Best Practices for Keeping Dependencies Secure

  1. Regularly update dependencies – Schedule periodic updates to keep your project secure.
  2. Use semantic versioning (^ or ~) carefully – Ensure you allow minor and patch updates while preventing breaking changes.
  3. Monitor security advisories – Subscribe to npm security advisories or use GitHub’s Dependabot to automate security updates.
  4. Use alternative packages – If a package is no longer maintained, consider switching to a well-maintained alternative.
  5. Run security audits in CI/CD – Integrate npm audit into your continuous integration workflow to catch vulnerabilities early.

Conclusion

Security vulnerabilities in npm packages can put your project at risk. By using npm audit, upgrading dependencies, and applying overrides where necessary, you can ensure your application remains secure. Make it a habit to check for vulnerabilities regularly and update dependencies responsibly.

...

🔧 Fixing High and Critical Vulnerabilities in npm Using npm audit


📈 60.28 Punkte
🔧 Programmierung

🔧 Fixing High and Critical Vulnerabilities in npm Using npm audit


📈 60.28 Punkte
🔧 Programmierung

📰 Immuta Unified Audit Model streamlines the filtering and analysis of audit data


📈 22.52 Punkte
📰 IT Security Nachrichten

🕵️ Microsoft April 2025 Patch Tuesday: Fixing 121 Vulnerabilities, Including a Critical Zero-Day


📈 21.81 Punkte
🕵️ Hacking

📰 SAP releases security updates fixing five critical vulnerabilities


📈 21.81 Punkte
📰 IT Security Nachrichten

📰 Samsung rolls out Android updates fixing critical vulnerabilities


📈 21.81 Punkte
📰 IT Security Nachrichten

🔧 Audit Vigilance: Lighting the Way for Audit Analysis - Unleashing the Bat Computer


📈 21.38 Punkte
🔧 Programmierung

🕵️ Audit the Security Posture of DevOps with HackerOne Code Security Audit


📈 21.38 Punkte
🕵️ Hacking

🕵️ CVE-2022-32074 | osTicket Plugins SVG audit/class.audit.php cross site scripting


📈 21.38 Punkte
🕵️ Sicherheitslücken

🕵️ Oracle Retail Sales Audit 14.0 Sales Audit Maintenance denial of service


📈 21.38 Punkte
🕵️ Sicherheitslücken

🕵️ Low CVE-2017-18560: Content audit project Content audit


📈 21.38 Punkte
🕵️ Sicherheitslücken

🕵️ libmail-audit-perl 2.1-5 Logging mail::audit privilege escalation


📈 21.38 Punkte
🕵️ Sicherheitslücken

📰 Cloud Security Audit - A Command Line Security Audit Tool For Amazon Web Services


📈 21.38 Punkte
📰 IT Security Nachrichten

🕵️ CVE-2022-31890 | osTicket Plugins audit/class.audit.php getOrder order sql injection


📈 21.38 Punkte
🕵️ Sicherheitslücken

🕵️ Audit the Security Posture of DevOps with HackerOne Code Security Audit


📈 21.38 Punkte
🕵️ Hacking

📰 Critical Git Vulnerabilities Discovered in Source Code Security Audit


📈 20.73 Punkte
📰 IT Security Nachrichten

📰 VeraCrypt Patches Critical Vulnerabilities Uncovered in Audit


📈 20.73 Punkte
📰 IT Security Nachrichten

📰 VeraCrypt Patches Critical Vulnerabilities Uncovered in Audit


📈 20.73 Punkte
📰 IT Security Nachrichten

🔧 My First Real Taste of Git Power: Fixing a Bug After an npm Upgrade


📈 20.48 Punkte
🔧 Programmierung

🔧 Resolving npm EACCES Errors: Fixing Permissions to Install Global Packages


📈 20.48 Punkte
🔧 Programmierung

🔧 How You Should Treat NPM Audit Results


📈 19.4 Punkte
🔧 Programmierung

🔧 Icarus and the npm Updates: How Version Control Rescued My npm Upgrade Nightmare


📈 18.56 Punkte
🔧 Programmierung

🍏 Fixing mds_stores and idleassetsd High CPU or Bandwidth Usage


📈 18.41 Punkte
🍏 iOS / Mac OS

🔧 Aluminum Nitride Ceramic Resistors: High Performance for High Frequency and High Power Applications


📈 17.64 Punkte
🔧 Programmierung

🐧 GnuPG 2.2.23 released, fixing a critical security flaw


📈 17.48 Punkte
🐧 Linux Tipps

📰 Drupal releases patch fixing “highly critical” flaw


📈 17.48 Punkte
📰 IT Security Nachrichten

matomo