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

推荐订阅源

P
Palo Alto Networks Blog
P
Proofpoint News Feed
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
罗磊的独立博客
J
Java Code Geeks
月光博客
月光博客
F
Full Disclosure
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
U
Unit 42
WordPress大学
WordPress大学
A
About on SuperTechFans
C
Cyber Attacks, Cyber Crime and Cyber Security
SecWiki News
SecWiki News
Security Latest
Security Latest
C
Check Point Blog
C
CERT Recently Published Vulnerability Notes
小众软件
小众软件
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
V
Visual Studio Blog
博客园_首页
NISL@THU
NISL@THU
I
Intezer
Spread Privacy
Spread Privacy
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Latest news
Latest news
Project Zero
Project Zero
博客园 - 叶小钗
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy International News Feed
博客园 - 【当耐特】
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
V
Vulnerabilities – Threatpost
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网

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
What We Actually Did About npm Supply Chain Attacks
Yasser's studio · 2026-05-30 · via DEV Community

In May 2026, attackers compromised 42 TanStack packages by poisoning a GitHub Actions build cache through a pull request. The malicious code exfiltrated AWS credentials, GCP tokens, Kubernetes secrets, and SSH keys from every developer who installed the affected versions. This was not an isolated incident. Hundreds of npm packages were compromised through similar vectors throughout 2025 and 2026.

GPC is a TypeScript CLI for the Google Play Developer API. It handles service account credentials, access tokens, and publish workflows for Android apps. If an attacker compromised our npm packages, they could steal every credential that passes through the tool.

This article covers every concrete protection we shipped across v0.9.50 through v0.9.80. Not theory. Not recommendations. What we actually changed, and what you can copy.

Key Takeaways

  • Delete your long-lived NPM_TOKEN and switch to Trusted Publisher (OIDC). It takes 10 minutes.
  • Add ignore-scripts=true to your .npmrc and explicitly allowlist packages that need postinstall hooks.
  • Pin every GitHub Action to a commit SHA, not a tag. Tags are mutable.
  • Staged Publishing adds a human approval gate before packages go live on npm. One compromised CI run cannot silently publish.
  • min-release-age=7 in .npmrc blocks freshly-published malicious packages from entering your dependency tree.
  • Isolate secret-dependent CI jobs from PR workflows. A fork PR should never see your credentials.

The npm Supply Chain Attack That Changed Our Approach

The TanStack attack (May 12, 2026, campaign name "Mini Shai-Hulud") worked like this:

  1. Attacker opened a normal-looking PR on the TanStack repo
  2. GitHub Actions ran CI tests on that PR automatically
  3. Code inside the PR stole the workflow's GitHub Actions cache write token
  4. Attacker used that token to plant poisoned files in the shared build cache
  5. The official release workflow later pulled from the poisoned cache, signed the malicious build, and published 84 compromised versions to npm

A git-resolved optionalDependency delivered the payload: its prepare script ran a 2.3 MB credential exfiltrator. Once the cache token was stolen, the PR could be closed. The poisoned cache persisted.

This attack vector is relevant to any project that:

  • Runs CI on pull requests from forks
  • Shares build caches between PR and release workflows
  • Uses npm publish with a long-lived token

GPC did all three before we hardened.

Layer 1: Kill the NPM_TOKEN

What we did: Switched from a stored NPM_TOKEN secret to npm Trusted Publisher (OIDC). Then deleted the token from GitHub Secrets entirely.

How it works: Your GitHub Actions workflow requests a short-lived OIDC token from npm at publish time. npm verifies the token came from your specific repository, branch, and workflow. No stored secret. Nothing to steal.

# .github/workflows/release.yml
permissions:
  id-token: write  # Required for OIDC token exchange with npm

steps:
  - uses: actions/setup-node@48b55a... # v6 (SHA-pinned)
    with:
      registry-url: "https://registry.npmjs.org"

  # npm authenticates via OIDC. No NPM_TOKEN needed.
  - run: pnpm release-staged
    env:
      NODE_AUTH_TOKEN: ""  # Explicitly empty. OIDC handles auth.

Enter fullscreen mode Exit fullscreen mode

Setup: Go to npmjs.com, navigate to each package's settings, and configure Trusted Publisher with your GitHub repo, branch, and workflow file. Takes about 2 minutes per package.

After our first successful OIDC publish (v0.9.77, May 22, 2026), we deleted the NPM_TOKEN from GitHub Secrets. It no longer exists anywhere.

Layer 2: Staged Publishing

What we did: Added a human approval gate between CI and npm.

Even with OIDC, a compromised CI pipeline could publish malicious code. Staged Publishing splits the process: CI stages packages to npm's holding area, then a maintainer reviews and approves each package with 2FA before it goes live.

// scripts/stage-publish.js (simplified)
for (const pkg of PACKAGES) {
  const { name, version } = pkgJson;
  const registryVersion = execFileSync("npm", ["view", name, "version"]);
  if (registryVersion === version) continue; // already published
  execSync("npm stage publish", { cwd: pkg });
}

Enter fullscreen mode Exit fullscreen mode

After CI runs, nothing is live yet. The maintainer goes to npmjs.com/settings/gpc-cli/staged-packages, reviews the staged packages, and approves with 2FA. Only then do packages appear on the registry.

A single compromised CI run cannot silently push malicious code to npm.

Layer 3: Block Install Scripts

What we did: Blocked all install scripts in CI, then allowlisted the two packages that genuinely need postinstall hooks.

Most npm supply chain attacks run during npm install via postinstall scripts. Block them by default and the vector disappears.

# Every CI workflow (ci.yml, release.yml, binary.yml, docs.yml, codeql.yml, bundle-size.yml)
- run: pnpm install --frozen-lockfile --ignore-scripts

Enter fullscreen mode Exit fullscreen mode

// package.json
{
  "pnpm": {
    "onlyBuiltDependencies": [
      "turbo",
      "esbuild"
    ]
  }
}

Enter fullscreen mode Exit fullscreen mode

Only turbo and esbuild are allowed to run install hooks. Every other dependency's lifecycle scripts are blocked. This is in all 6 CI workflows.

Starting with v0.9.80, the CI templates that gpc init generates for users also include --ignore-scripts.

Layer 4: Pin Actions to Commit SHAs

What we did: Pinned every GitHub Action to a full commit SHA instead of a mutable tag.

Git tags are mutable. An attacker who gains write access to a popular GitHub Action can move the v4 tag to point at malicious code. Every workflow that uses @v4 would then run the attacker's code.

# Before (vulnerable to tag-swap)
- uses: actions/checkout@v6

# After (immutable)
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

Enter fullscreen mode Exit fullscreen mode

We pinned all action references across all workflows. The comment after the SHA records which version it corresponds to, so Dependabot can still propose updates.

Layer 5: Isolate PR Secrets

What we did: Moved secret-dependent CI jobs to push events and added explicit fork-PR guards.

The TanStack attack worked because the PR workflow had access to secret environment variables. We restructured our CI so that:

  • PR workflows run tests with --ignore-scripts and no secrets
  • The dependency review job only runs on PRs (read-only, no secrets)
  • Security scanning (deepsec) runs on push to main only, not on PRs
  • Secret-dependent steps check github.event.pull_request.head.repo.full_name == github.repository to block fork PRs
# ci.yml: dependency review (read-only, safe on PRs)
dependency-review:
  if: github.event_name == 'pull_request'
  permissions:
    contents: read

# ci.yml: deepsec scan (needs API key, restricted to push)
deepsec:
  if: github.event_name == 'push'
  permissions:
    contents: read

Enter fullscreen mode Exit fullscreen mode

Layer 6: Block Freshly-Published Packages

What we did: Set min-release-age=7 in .npmrc.

# .npmrc
min-release-age=7

Enter fullscreen mode Exit fullscreen mode

pnpm rejects any package version published less than 7 days ago. A malicious version of a dependency cannot enter your tree for a week, giving the community time to detect and revert it.

This is a blunt instrument with a real tradeoff: you cannot adopt urgent security patches within the first week. For a CLI tool with 4 runtime dependencies, we decided the supply chain protection outweighs the patch delay.

Layer 7: Automated Scanning

What we did: Added Socket.dev, CodeQL, pnpm audit, and deepsec to the CI pipeline.

Tool Trigger What it catches
Socket.dev Every PR Malicious packages, typosquatting, obfuscated code
pnpm audit Every PR Known CVEs in production dependencies
CodeQL Every push Static analysis (injection, auth bypass)
deepsec Every push to main AI-powered security audit (RCE, SSRF, path traversal)
Dependency Review Every PR License issues, new dependency risks

Socket.dev is particularly effective against the TanStack-style attack because it detects git-resolved dependencies and obfuscated install scripts, which are the two primary delivery mechanisms.

Layer 8: Provenance and SBOM

What we did: Automatic provenance attestation via Trusted Publisher, plus CycloneDX SBOM on every release.

When you install @gpc-cli/cli, npm can verify that the package was built by our specific GitHub repository, on a specific commit, using a specific workflow. This is automatic with Trusted Publisher.

# Verify provenance of any @gpc-cli package
npm audit signatures

Enter fullscreen mode Exit fullscreen mode

We also generate a CycloneDX Software Bill of Materials on every release, archived as a CI artifact. If a dependency is later found to be compromised, the SBOM tells you exactly which GPC versions included it.

The Full Stack

Here is every layer in one table:

# Protection What it prevents
1 Trusted Publisher (OIDC) Stolen NPM_TOKEN publishing malicious packages
2 Staged Publishing (2FA) Compromised CI silently publishing
3 ignore-scripts + allowlist Malicious postinstall scripts during install
4 SHA-pinned Actions Tag-swap attacks on GitHub Actions
5 PR secret isolation Fork PRs stealing CI secrets
6 min-release-age=7 Freshly-published malicious dependency versions
7 Socket.dev + pnpm audit + CodeQL + deepsec Known vulnerabilities and malicious patterns
8 Provenance + SBOM Verifying package origin; tracking dependency history

No single layer is sufficient. The TanStack attack would have bypassed layers 1, 3, 6, 7, and 8. It specifically exploited the gap between layers 4 and 5 (cache poisoning via a PR that had access to write tokens). Defense in depth is not a cliche here. It is the only approach that works.

What You Can Do Today

If you maintain an npm package:

  1. Set up Trusted Publisher. Go to npmjs.com, configure OIDC for your repo. Delete your NPM_TOKEN.
  2. Add ignore-scripts=true to .npmrc. Allowlist the packages that genuinely need install hooks.
  3. Pin your GitHub Actions to SHAs. Run npx pin-github-action .github/workflows/*.yml to automate this.
  4. Add min-release-age=7 to .npmrc. Accept the tradeoff.
  5. Review your CI secrets exposure. Does your PR workflow have access to publish tokens? Fix that today.

If you are a consumer of npm packages:

  1. Check provenance. Run npm audit signatures on your project.
  2. Use a lockfile. Always --frozen-lockfile in CI.
  3. Review dependency changes. Use actions/dependency-review-action on PRs.

The npm ecosystem has a supply chain problem. Waiting for npm to solve it is not a strategy. Ship the protections yourself.


GPC is a TypeScript CLI for the Google Play Developer API. 217 endpoints, 2,343 tests, free to use.