惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
V
Vulnerabilities – Threatpost
NISL@THU
NISL@THU
PCI Perspectives
PCI Perspectives
爱范儿
爱范儿
腾讯CDC
Recent Announcements
Recent Announcements
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Threatpost
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
F
Fortinet All Blogs
G
GRAHAM CLULEY
P
Proofpoint News Feed
K
Kaspersky official blog
IT之家
IT之家
P
Privacy International News Feed
Apple Machine Learning Research
Apple Machine Learning Research
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Check Point Blog
博客园_首页
C
CERT Recently Published Vulnerability Notes
博客园 - Franky
V
Visual Studio Blog
C
Cybersecurity and Infrastructure Security Agency CISA
N
Netflix TechBlog - Medium
A
About on SuperTechFans
月光博客
月光博客
Latest news
Latest news
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
Spread Privacy
Spread Privacy
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
Attack and Defense Labs
Attack and Defense Labs
P
Palo Alto Networks Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
AI Hallucinated Dependencies Are the New Supply Chain Attack: How to Stop Them
Toni Antunov · 2026-04-29 · via DEV Community

This article was originally published on LucidShark Blog.


Your AI coding agent just invented a package that doesn't exist. It happens dozens of times a day in codebases everywhere. The agent confidently writes import { parseJWT } from 'jwt-lite-parser', you run npm install, and one of two things happens: the install fails with a module-not-found error, or it succeeds because someone registered that exact package name yesterday.

The second outcome is the dangerous one.

AI model hallucinations in dependency names are not a minor inconvenience. They are an active attack surface. Threat actors monitor AI-generated code repositories and developer forums, extract hallucinated package names, and register them on npm, PyPI, and RubyGems before you notice. They fill those packages with credential stealers, backdoors, or supply chain worms. By the time your developer runs npm install, they are already compromised.

This is not a theoretical risk. Socket Security and Checkmarx have documented dozens of cases in 2025 and 2026 where attackers specifically targeted AI model hallucination patterns, registering the exact phantom names generated by popular coding assistants. The Bitwarden CLI worm this week used a related vector: a preinstall hook in a legitimate package. The hallucinated-dependency attack skips that step entirely. There is no supply chain to poison when you can simply register the name the model made up.

Active threat in 2026: Security researchers have confirmed that attackers actively monitor GitHub Copilot, Claude Code, and Cursor output for hallucinated package names and register them within hours. The attack is called "AI package hallucination hijacking" and it requires no exploitation skill: just a npm account and fast monitoring.

How AI Models Hallucinate Package Names

Language models are trained on code, documentation, and Stack Overflow posts. They absorb naming conventions, API patterns, and package ecosystems. When generating code, they predict plausible package names based on patterns, not registry lookups. A model trained on thousands of repositories that use JWT parsing will confidently generate import statements for packages like jwt-parser, jwt-lite, fast-jwt-parse, or express-jwt-middleware. Some of these exist. Some do not. The model has no way to know the difference at generation time.

The problem compounds with niche domains. If you ask an AI agent to add Kubernetes operator support, database migration utilities, or cloud provider SDKs, the hallucination rate increases sharply. The model's training data is thinner, naming conventions are less standardized, and the space of plausible-sounding names is larger.

Here is a real pattern researchers have documented: an AI agent generates a utility function that imports from @aws-utils/s3-presign-helper. The package doesn't exist. The developer commits the code, the lockfile doesn't include it yet, and the CI pipeline fails on install. The developer types the package name into Google, finds nothing, and manually substitutes the correct AWS SDK call. Problem solved, they think.

What they don't see: three days earlier, a different developer in a different company hit the same hallucination. They opened a GitHub issue about it. An attacker read the issue, registered @aws-utils/s3-presign-helper on npm with a readme that looks plausible, and added a postinstall hook that exfiltrates environment variables. Now when your CI pipeline installs it, your AWS credentials leave your environment silently.

The Detection Gap: Why Your Current Tooling Misses This

Standard dependency auditing tools like npm audit, pip-audit, and Dependabot are built around a different threat model: known vulnerabilities in existing, legitimate packages. They compare your dependency tree against vulnerability databases. A freshly registered malicious package has no CVEs yet. It's too new. These tools will not flag it.

SAST tools don't help here either. They analyze code patterns, not registry state. A hallucinated import looks identical to a legitimate one at the AST level.

The detection gap sits specifically between code generation and package installation. The hallucinated name exists as a string literal in your source code. Until someone runs npm install, no tool in the standard pipeline has a reason to validate whether the name is legitimate.

// This looks perfectly fine to SAST, linters, and code review
import { parseJWT } from 'jwt-lite-parser';  // Does this package exist?
import { hashPassword } from 'bcrypt-fast';  // Is it what it claims to be?
import { encrypt } from '@crypto-utils/aes'; // Who published it?

Enter fullscreen mode Exit fullscreen mode

By the time npm install resolves these names, you've already accepted the package into your environment. The postinstall hook runs with the same permissions as your build process.

Five Concrete Checks to Close the Gap

The remediation lives at the intersection of SCA tooling and pre-install validation. Here is what each layer needs to do.

1. Validate dependency names before they enter your lockfile

Before running npm install on new imports in AI-generated code, verify the package exists and has a credible history:

#!/bin/bash
# validate-deps.sh - run before npm install on AI-generated code

check_package() {
  local pkg=$1
  local result=$(curl -s "https://registry.npmjs.org/${pkg}" 2>/dev/null)
  local created=$(echo "$result" | python3 -c "
import json, sys, datetime
try:
    d = json.load(sys.stdin)
    # Get creation date of first version
    times = d.get('time', {})
    if 'created' in times:
        created = times['created'][:10]
        age_days = (datetime.date.today() - datetime.date.fromisoformat(created)).days
        dl_count = d.get('downloads', {}).get('last-month', 'unknown')
        print(f'exists,created={created},age={age_days}d')
    else:
        print('not-found')
except:
    print('not-found')
" 2>/dev/null)

  if [[ "$result" == *'"error"'* ]] || [[ "$created" == "not-found" ]]; then
    echo "FAIL: $pkg - not found on npm registry"
    return 1
  fi

  local age=$(echo "$created" | grep -oP 'age=\K[0-9]+')
  if [[ -n "$age" ]] && [[ "$age" -lt 30 ]]; then
    echo "WARN: $pkg - registered less than 30 days ago (age: ${age}d)"
  else
    echo "OK: $pkg - $created"
  fi
}

# Extract imports from staged changes
git diff --cached --name-only | grep -E '\.(ts|js|tsx|jsx)$' | while read file; do
  grep -oP "from ['\"](@?[a-z][a-z0-9\-@/\.]+)['\"]" "$file" | \
    grep -oP "(@?[a-z][a-z0-9\-@/\.]+)" | \
    sort -u | while read pkg; do
      # Skip relative imports and node built-ins
      if [[ "$pkg" != .* ]] && [[ "$pkg" != /* ]]; then
        check_package "$pkg"
      fi
    done
done

Enter fullscreen mode Exit fullscreen mode

2. Flag packages with no download history

Legitimate packages accumulate download counts over time. A package with zero downloads in the last month on a name that sounds like a common utility is a strong signal of hallucination hijacking:

# Check npm download count for the last week
check_downloads() {
  local pkg=$1
  local weekly=$(curl -s "https://api.npmjs.org/downloads/point/last-week/${pkg}" | \
    python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('downloads',0))" 2>/dev/null)

  if [[ "$weekly" -lt 100 ]]; then
    echo "SUSPICIOUS: $pkg has only $weekly downloads last week"
    return 1
  fi
  echo "OK: $pkg ($weekly downloads/week)"
}

Enter fullscreen mode Exit fullscreen mode

3. Verify publisher trust before first install

For any new package entering your dependency tree, check whether the publisher has a history of trusted packages. A publisher account created last week with one package is a strong red flag:



import requests
import datetime

def check_publisher_trust(package_name: str) -> dict:
    """Check if a package's publisher has an established track record."""
    r = requests.get(f"https://registry.npmjs.org/{package_name}")
    if r.status_code != 200:
        return {"trusted": False, "reason": "package not found"}

    data = r.json()
    maintainers = data.get("maintainers", [])
    created = data.get("time", {}).get("created", "")

    if not maintainers:
        return {"trusted": False, "reason": "no maintainers listed"}

    # Check publisher account age via npm API
    first_maintainer = maintainers[0].get("name", "")
    if created:
        pkg_age = (datetime.date.today() -
                   datetime.date.fromisoformat(created[:10])).days
        if pkg_age
**Why pre-commit?** Running at commit time catches the problem before the dependency ever enters the lockfile or gets installed. The developer sees the warning while the context is fresh, before the code is reviewed or merged. Post-install hooks are too late: by the time CI runs npm install, the malicious code has already executed in the CI environment.


## The Broader Pattern: AI-Amplified Supply Chain Risk


Hallucinated dependency hijacking is one instance of a larger pattern: AI coding tools dramatically expand the attack surface of your software supply chain. Before AI agents, a developer who needed a new package would search npm, read the readme, check the download count, and make a deliberate choice. AI agents skip every step of that evaluation. They emit package names as confidently as they emit function bodies, and the developer's attention is on the logic, not the package metadata.


The supply chain tooling the industry built over the last decade assumes human-paced, human-evaluated dependency management. That assumption is now wrong for any team using AI coding tools at scale. The tooling needs to move earlier in the pipeline, closer to where the AI output enters the codebase, and it needs to be automated rather than relying on developer attention.


This is the same argument that applies to SAST, secret scanning, and code coverage gates in AI-assisted workflows. The AI generates fast. The checks need to be faster, automated, and positioned at the commit boundary so they don't slow the developer down but do catch the problems before they propagate.


**Key stat:** Socket Security found that npm package hallucination hijacking attempts increased 340% in Q1 2026 compared to Q1 2025, directly correlated with the adoption curve of agentic coding tools. The attack is cheap to execute and growing.


## What a Complete Defense Looks Like


Defending against AI hallucination hijacking requires three layers working together:


- **Pre-commit:** Validate all new dependency imports against the npm/PyPI/RubyGems registry, check package age and download history, cross-reference against your approved dependency list. Block commits that introduce suspicious packages.

- **CI/CD:** Run `npm install --ignore-scripts` as a default, validate lockfile integrity on every run, run a full SCA scan including new packages not yet in vulnerability databases (check for age, publisher reputation, and file content anomalies).

- **Lockfile hygiene:** Commit your lockfile, treat lockfile changes as security-relevant, require explicit review for any package addition or version change. The lockfile is the audit trail.


None of these checks are complex in isolation. The problem is that most development environments have none of them applied to the AI-generated code path specifically. Developers trust the agent's output more than they should, and the tooling doesn't compensate for that trust.


**LucidShark automates all three layers.** The pre-commit hook validates new dependency names against the npm registry and your approved package list. The CI integration runs SCA with publisher reputation checks. The lockfile monitor flags drift between commits. All of it runs locally, with no code leaving your machine. Install in under a minute: `npx lucidshark init`. Full setup at [lucidshark.com](https://lucidshark.com).


The attack is straightforward: find what the model made up, register it, wait for developers to install it. The defense is equally straightforward: validate before you install, automate the validation, and treat every AI-generated import as unverified until proven otherwise. The gap between those two positions is a pre-commit hook and a registry lookup. Close it before someone else exploits it.





### Share this article


                [Share on Twitter](https://twitter.com/intent/tweet?text=AI%20Hallucinated%20Dependencies%20Are%20the%20New%20Supply%20Chain%20Attack%3A%20How%20to%20Stop%20Them&url=https%3A%2F%2Flucidshark.com%2Fblog%2Fai-hallucinated-dependencies-supply-chain-attack-2026)
                [Share on LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Flucidshark.com%2Fblog%2Fai-hallucinated-dependencies-supply-chain-attack-2026&title=AI%20Hallucinated%20Dependencies%20Are%20the%20New%20Supply%20Chain%20Attack%3A%20How%20to%20Stop%20Them)

Enter fullscreen mode Exit fullscreen mode