Defeating the worm: stop malicious packages in your CI/CD pipeline with SonarQube

Bill Nottingham photo

Bill Nottingham

Product manager

7 min read

  • Code security
  • Code quality

Table of contents

Start your free trial

Verify all code. Find and fix issues faster with SonarQube.

Get started

“Malware”, short for “malicious software” has been around for decades, starting with the first computer viruses of the 1990s. Early malware was mostly experimentation and pranks. As time passed, malicious software became used for more nefarious purposes such as spam campaigns and denial of service attacks, and in some cases even by nation-states for political goals. More recently, finance has been the target of many categories of malware, as the malicious software is used primarily to install cryptocurrency miners, or exfiltrate wallet credentials.

The key remediation suggested during the early days of malware was “don’t install or execute code that isn’t from someone you trust.”  Well, about that…

Public package managers become the weapon of choice

Attackers have shifted their focus to where software is built: public repositories like npm and PyPI. Initially, this took the form of typosquatting—registering malicious packages with names similar to popular ones—or dependency confusion, where public packages mimic internal naming conventions to trick build systems.

However, these methods rely on user error. To achieve widespread impact, attackers now target the source by compromising official, widely used packages.

Attracting the worm

Recent years have seen a surge in sophisticated campaigns targeting package maintainers:

  • Social engineering: The 2024 xz-utils backdoor resulted from a multi-year effort to gain publishing rights. In 2025, attackers used phished two-factor authentication credentials to hijack and publish malicious updates to popular npm packages.
  • Self-propagating worms: Modern malware now includes worms that exfiltrate credentials upon execution and automatically replicate the payload to any other packages the compromised user has permission to publish.

When a developer installs a compromised package, their credentials are often leaked immediately. For those with publishing privileges on major repositories, a single infection can trigger a chain reaction across the entire software ecosystem. To protect the codebase, organizations must verify every dependency and ensure security is built into the workflow from the start.

The risk of unverified dependencies

In an era where development speed is essential, teams often use AI to “vibe”- rapidly prototyping and building with generative tools. However, this speed creates a verification bottleneck. AI-generated code frequently relies on external libraries that may introduce security flaws  or, worse, active malware. 

Traditional vulnerabilities can sometimes be scheduled for later remediation, but a malicious package is different. It is not just another bug; its a critical blocker. If malware enters your environment, it can self-replicate, and compromise any package your credentials can access. 

Secure your workflow with SonarQube malicious package detection

To address this challenge, Sonar now includes malicious package detection capability within SonarQube Advanced Security in both Cloud and Server. This feature integrates directly into your existing CI/CD pipeline to ensure that all public third-party dependencies are secure before they ever reach production. Here is how it works:

  • Automated scanning: SonarQube automatically compares your dependencies against constantly updated lists of known malicious software
  • Real-time verification: Instead of performing manual audits, you get immediate feedback within your workflow, identifying risky dependencies the moment they are introduced.
  • Policy enforcement: Using quality gates, you can automatically fail pipelines if a malicious package is detected

Facing the fear

To fix the spread of malware, it must start at the public package managers. The good news is that many researchers are watching public package repositories; malicious software is usually taken down within minutes or hours of publishing. The bad news is that the widespread publishing of malicious software means that organizations need to take extra precautions to avoid them for the short time that they are public. To avoid malicious software in your organization, organizations can take multiple steps:

  • Avoid installing unversioned software: Malicious software is installed and gone within hours; the way it infects is from users who download and install the latest version without checking. By ensuring all dependencies in your application are pinned to specific, known good, versions, you can avoid accidental installs of malicious software.
  • Scan your dependencies for known malicious software: By comparing your third party dependencies against lists of known malicious software, you can ensure that you aren’t using any in your code repositories. With SonarQube Advanced Security, this can be done as a regular part of your continuous integration processes.

Immediately remediate if any malware is detected

When SonarQube flags a malicious package, it is a high-stakes event that requires an immediate cross-functional response. Malware isn’t like a normal code vulnerability where you may be able to postpone remediation until a convenient time. If malware is detected in your environment, follow these steps:

  • Inform your  security team: malware requires an immediate shift from development to incident response.
  • Isolate the environment: Consider any environment where it was installed as compromised
  • Reset credentials: Revoke and recreate any compromised credentials and secrets

Strengthen your code security 

Generating code at speed only adds value if that code is trustworthy. By integrating malicious package detection into your development workflow, you can protect sensitive data and ensure your codebase remains production-ready. Stop compromised dependencies from reaching your environment with SonarQube Advanced Security—available now for SonarQube Cloud and SonarQube Server 2026.1 LTA.