How Do Vibe-Coded Apps Get Hit by npm Supply Chain Attacks?
npm supply chain attacks hit vibe-coded apps through malicious packages and unpinned lockfiles. Here's how to audit, harden, and protect your dependencies.
npm supply chain attacks are now one of the top three security risks for vibe-coded apps in 2026. When a developer builds a product with Lovable, Bolt, or Cursor, the AI scaffolds dependencies automatically — selecting packages, adding them to package.json, and testing that the app runs without auditing whether those packages are trustworthy. In March 2026, attackers published malicious patch versions of axios, one of the most widely-used HTTP client libraries in the npm ecosystem, and apps that lacked committed lockfiles or used mutable version ranges installed the malicious code on the next npm install. The result: credential harvesting, data exfiltration, and in some cases, full backend compromise. This is a gap that preventing API key exposure alone does not close — the attack happens before your application code runs at all.
This post covers what an npm supply chain attack is, why AI-scaffolded apps are specifically at risk, what the March 2026 incidents revealed about the vibe-coded app ecosystem, and the concrete steps — lockfile commits, dependency audits, registry configuration, CI hardening — that close the gaps. The techniques apply to any app built with Lovable, Bolt, Cursor, v0, Replit, or any other AI coding assistant that manages npm dependencies on your behalf.
What Is an npm Supply Chain Attack?
An npm supply chain attack compromises software through the dependencies an application installs from the registry — not through the application's own code. The attacker targets a package rather than your application directly. When your app installs the compromised package, their code runs with the same privileges as your build or runtime environment. The npm registry hosts over 3.3 million packages, and even a single compromised dependency buried four levels deep in a transitive tree can reach production before anyone notices.
- →Compromised maintainer account: attacker gains access to an existing package's npm publishing credentials — often through a phishing attack or a leaked CI token — and pushes a new, malicious version. The package name, publisher, and history all look legitimate. Apps that use a mutable version range like ^1.5.0 or the latest tag pull the new version automatically on the next install.
- →Typosquatting: attacker registers a package with a name visually similar to a popular package — lodash vs ldoash, express vs expresss, colors vs colour. AI coding tools, working from token prediction, have been shown to suggest near-miss package names that happen to match attacker-registered names.
- →Dependency confusion: attacker registers a public npm package with the same name as a private internal package at a higher version number. npm resolves to the public registry version, installing the attacker's package instead. This requires knowing your internal package names — often discoverable from exposed package-lock.json files, error logs, or public repositories.
- →Malicious install scripts: the attack vector in most real incidents is the postinstall or preinstall lifecycle script in package.json. npm runs these scripts automatically during installation with full system access. A malicious package can read environment variables, exfiltrate credentials, download secondary payloads, or modify your application code during the build — all before your app boots.
Why AI Coding Tools Create Specific Dependency Risks
Every AI coding tool that manages your project's dependencies introduces the same gap: the AI adds packages based on training data and token prediction, not on current npm registry health. A package that was legitimate and widely used when the model was trained may have been abandoned, transferred to a new maintainer, or actively targeted by the time you run npm install.
- →Bulk package installation: AI tools often scaffold an entire feature with five or ten new dependencies in a single prompt response. No single package gets reviewed before it lands in package.json. The app works, so the dependencies feel validated — but 'works' and 'safe' are different tests, and a postinstall script can steal credentials while the app still boots normally.
- →No lockfile on new projects: Lovable and Bolt generate a package.json but do not always commit a package-lock.json or pnpm-lock.yaml to the initial repository. Without a lockfile, every npm install resolves fresh against the registry — which means the app might install a different version of a package today than it did last week, including a version published by an attacker since the last build.
- →Mutable version ranges: AI tools default to caret ranges (^1.5.0) which allow any minor or patch update within the same major version. In practice, this means your app silently accepts any new version an attacker publishes within that range on the next install.
- →Dependency bloat: vibe-coded apps tend to have higher package counts than manually-written apps because the AI includes utility packages it has seen in similar contexts. Each additional dependency is another attack surface — and a larger surface area means higher odds that one package in the tree gets targeted.
- →AI package hallucination: AI tools sometimes suggest packages that do not exist on npm. When developers run npm install and the package resolves to something unexpected, it may be because an attacker registered the hallucinated name in anticipation of exactly this. This pattern was documented in multiple 2026 incident post-mortems.
The March 2026 Axios Attack: What Happened and Why It Hit Vibe-Coded Apps Hard
In March 2026, attackers published malicious patch versions of axios and several downstream packages by compromising a maintainer account. The malicious code ran in the postinstall script, read the process.env object at install time, and exfiltrated any keys matching patterns associated with cloud credentials, Supabase service role keys, Stripe secret keys, and OpenAI API keys. Apps that ran npm install without first verifying the lockfile diff received the malicious version. CI/CD pipelines that used npm install instead of npm ci — which enforces lockfile integrity — also ran the malicious script.
- →Two major npm supply chain attacks hit the ecosystem in eleven days during March 2026, including an attack on a popular CI security scanner tool. The pattern: compromise a maintainer account, publish a malicious patch, wait for install automation to distribute it, then revoke the malicious version before broad detection.
- →Vibe-coded apps were disproportionately represented in incident reports because they tended to lack committed lockfiles, used npm install in CI rather than npm ci, and stored credentials in environment variables readable at build time — exactly what the malicious postinstall script targeted.
- →The incident also exposed a monitoring gap: most vibe-coded app teams had no alerting on new npm package versions being installed in their CI pipeline. The first indicator of compromise was often an external alert from a secrets scanner, not internal monitoring.
- →Supabase published a supply chain security advisory in May 2026 specifically for projects using Edge Functions, noting that npm-sourced dependencies in Edge Function bundles carry the same risk and recommending lockfile commits and audit steps before each Edge Function deployment.
- →The Cloud Security Alliance's April 2026 research note on AI codegen vulnerability debt found that less than 25% of developers building with AI coding tools ran SCA (software composition analysis) tooling against AI-suggested packages — a standing invitation for the attack pattern the axios incident demonstrated.
Dependency Confusion and Typosquatting: Two Vectors Specific to AI-Generated Code
Beyond compromised legitimate packages, two distinct attack shapes specifically target AI-generated dependency lists. Dependency confusion attacks exploit npm's resolution algorithm. Typosquatting attacks exploit the imprecision of AI package name suggestions — a gap that does not exist when a developer manually types a known package name but opens consistently when an AI generates one.
- →Dependency confusion setup: the attacker registers a public npm package with the same name as a private internal package at a high version number (e.g., 99.0.0). When npm install runs, it sees the public version 99.0.0 as higher than your internal 1.2.3 and installs the attacker's package. Fix: add a .npmrc file with `@your-scope:registry=https://your-internal-registry.com` for every private package, so internal names are never resolved against the public npm registry.
- →Typosquatting via AI suggestions: in documented studies, AI coding tools occasionally suggest packages whose names differ from the intended package by a single character — a transposition, a missing letter, or a different suffix. These near-miss names are often pre-registered by squatters waiting for exactly this. Before installing any package an AI tool suggests, verify the exact name on npmjs.com, check the weekly download count, and confirm the publisher identity matches the project you expect.
- →Scope confusion: AI tools sometimes suggest a package without the correct npm scope prefix — for example, suggesting react-query instead of @tanstack/react-query. The unscoped name may resolve to an entirely different package, potentially one registered by an attacker targeting this AI suggestion pattern.
- →Mitigation: treat every AI-suggested package as unknown until verified on npmjs.com. Run npm install one package at a time for new additions rather than accepting a full AI-generated package.json without review. For teams with an internal registry, block the public npm registry entirely for production builds and require all packages to pass through the internal mirror.
How to Audit npm Dependencies in a Vibe-Coded App
A dependency audit covers three layers: known vulnerability CVEs, suspicious package metadata, and unexplained new packages that appeared since the last deploy. Run these steps before every production deployment and after any AI-assisted feature addition that modified package.json. For the broader security posture of your app before launch, run DeployReady first — it catches environment variable patterns and exposed secrets automatically, then follow the dependency-specific steps below.
- →`npm audit`: run this in every project root. It checks installed packages against the npm advisory database and reports severity-rated CVEs. Use `npm audit --production` to limit the scan to production dependencies only. Fix anything rated high or critical before shipping. Use `npm audit fix` with caution — it updates versions and can introduce breaking changes; always review the diff before committing.
- →`npm ls <package-name>`: traces which direct dependency pulled in a transitive package you do not recognize. If you see a package in your lockfile you cannot account for, run `npm ls <name>` to understand its origin before accepting it.
- →Review package metadata on npmjs.com: for any new dependency added in the last sprint, check the package page. Look at weekly download count (a sudden drop or spike is suspicious), number of maintainers (a package with one maintainer and no recent commits is higher risk), and the publish date of the latest version (a version published hours before your build is a flag worth investigating before you deploy).
- →Commit and diff your lockfile: the lockfile records the exact version tree that was installed. Any unexpected version change since the last commit means something resolved differently — either a legitimate upstream update or an attacker's new version. Run `git diff package-lock.json` after any install that modifies the lockfile, and understand every version change before merging.
- →Check for install scripts: inspect the scripts block of any new or changed package — `cat node_modules/<package>/package.json | grep -A5 scripts`. A postinstall or preinstall script in a package you did not explicitly add deserves a code review before you let it run in your environment.
Hardening Your npm Configuration Before Deployment
These configuration changes apply before any package is installed and close specific attack vectors that application code alone cannot address. They complement the GitHub Actions supply-chain hardening required for a secure CI/CD pipeline — the pipeline's own permissions need to be tightened before any npm hardening inside it matters.
- →Commit a lockfile on day one: every new project, regardless of which scaffold tool created it, must have its package-lock.json (npm) or pnpm-lock.yaml (pnpm) committed in the first commit. Without a lockfile, the project runs against floating registry versions on every build.
- →Use `npm ci` in CI/CD: unlike `npm install`, `npm ci` requires a committed lockfile, installs exactly the versions recorded in it, and exits with an error if the lockfile is out of sync with package.json. This is the correct command for reproducible builds in any automated environment. npm install in CI is a risk — it updates the lockfile silently if versions resolve differently.
- →Disable install scripts globally: add `ignore-scripts=true` to your project's .npmrc file. This prevents any package's lifecycle scripts (postinstall, preinstall) from running automatically. Some packages need their scripts for native module compilation — allow those explicitly with `--ignore-scripts=false` on a case-by-case basis and document the exception. For projects that do not compile native modules, disabling install scripts by default eliminates the most common supply chain exploit path.
- →Use the overrides field for critical packages: in package.json, the overrides field (npm v8+) forces a specific version of a transitive dependency regardless of what the packages in your dependency tree request. After a supply chain incident touches a commonly-used package like axios, undici, or got, pin the patched version via overrides until all direct dependencies have updated their own requirements.
- →Consider a private registry mirror: for production build environments, configure .npmrc to point at an internal registry (Artifactory, Verdaccio, or GitHub Packages) rather than directly at registry.npmjs.org. The mirror can hold approved, reviewed versions and require a manual gate before accepting new upstream releases.
Frequently Asked Questions
What is an npm supply chain attack?
An npm supply chain attack compromises an application by targeting one of its dependencies rather than its own code. The attacker publishes a malicious version of an existing package, registers a lookalike package name (typosquatting), or exploits npm's dependency resolution to substitute an attacker-controlled package for a legitimate one (dependency confusion). The malicious code runs when the application installs its dependencies — often in a postinstall script — with access to the build environment's credentials and file system.
Are vibe-coded apps more vulnerable to npm supply chain attacks?
Yes, for three reasons. First, AI coding tools install dependencies automatically and in bulk without developer review, increasing the odds that a malicious or typosquatted package enters the project. Second, vibe-coded projects often lack committed lockfiles, meaning every build resolves fresh against the registry and may pick up newly published malicious versions. Third, vibe-coded apps tend to store API keys and service credentials in environment variables accessible at build time — exactly what malicious postinstall scripts read and exfiltrate. The combination of automatic dependency management and credential availability makes vibe-coded apps a consistently high-value target.
How do I check if my app installed a compromised npm package?
Run `npm audit` in your project root to check installed packages against the advisory database. For targeted investigation, review your package-lock.json diff since the last known-good deploy and inspect any packages whose versions changed unexpectedly. Cross-reference against published advisories for the specific package. If you suspect a compromise, rotate any credentials that were accessible in the build environment before the incident — secrets can be exfiltrated without leaving obvious application-level logs.
What is a dependency confusion attack in npm?
A dependency confusion attack exploits npm's package resolution algorithm. If an attacker registers a public npm package with the same name as one of your private internal packages and publishes it at a higher version number, npm will install the attacker's public package instead of your private one during the next npm install. The fix is to configure a .npmrc file that routes all private package names through your internal registry so they are never resolved against the public npm registry.
Does DeployReady scan for npm supply chain vulnerabilities?
DeployReady's static analysis flags exposed credentials in environment variable files, hardcoded secret patterns in source code, and misconfigured security headers — all of which reduce the blast radius of a supply chain compromise. It is the fastest way to get an automated baseline on your app's security posture before launch. For dependency-specific coverage, supplement it with npm audit and the lockfile verification and CI hardening steps in this post. The two are complementary: DeployReady covers the credential and configuration surface; npm audit covers the dependency vulnerability surface.
How Belsoft Helps Secure Your Vibe-Coded App's Dependency Stack
Most vibe-coded apps that come through a Belsoft security audit share the same dependency hygiene gaps: no committed lockfile, npm install running in CI, caret version ranges across the board, and no process for reviewing AI-suggested packages before installation. We cover this surface explicitly in our security audit for vibe-coded apps — reviewing package.json and lockfile history, testing whether install scripts execute in the CI environment, checking for known-vulnerable transitive dependencies, and verifying that build-time credentials are scoped and rotated.
Run DeployReady first to get the automated baseline in seconds — it catches exposed secrets, security header gaps, and common misconfigurations that every app should clear before launch. A Belsoft engineer goes further: manual review of the dependency tree, tracing transitive packages back to their publishers, reviewing CI pipeline configuration for supply chain exposure, and walking through the credential rotation steps needed after any suspected compromise. If you built with Lovable, Bolt, Cursor, v0, or any other AI coding tool and you have not reviewed your app's dependency security, that review should happen before your next production deployment.
“An app that works is not an app that is safe. The npm install that runs in four seconds can ship an attacker's code to production — and the lockfile you never committed is the door they walked through.”
Written by
Marco Silva
Security Engineer, Belsoft Solutions
More from the blog
Ready to partner?
Let's talk about your company.
30 minutes. No pitch. We talk through how you run today and where AI and automation would help.
Book a free audit
