Security

Malicious Next.js Repos Target Developers via VS Code

3 min read

Summary

Microsoft Defender Experts uncovered a campaign using malicious Next.js repositories, often disguised as job take-home assignments, to compromise developers through normal VS Code and app startup workflows. The repos can automatically execute attacker-controlled JavaScript on folder open or when the project is run, potentially exposing source code, environment variables, and cloud credentials—making this a serious supply-chain and developer workstation security threat.

Need help with Security?Talk to an Expert

Introduction: why this matters

Developer workstations and build environments are high-value targets because they often hold source code, signing material, and secrets (API tokens, cloud credentials) in environment variables. Microsoft Defender Experts reports a campaign seeding malicious Next.js repositories—often wrapped as job-related “take-home” assessments—designed to blend into normal developer workflows and reliably trigger code execution.

What’s new / key findings

Microsoft observed multiple related repositories with shared naming conventions and reused loader logic. While the initial lure varies, the end state is consistent: runtime retrieval and in-memory execution of attacker-controlled JavaScript, followed by staged C2.

1) VS Code workspace execution on folder open

Some repos include .vscode/tasks.json configured with runOn: "folderOpen". If a developer opens (and trusts) the project, a task runs automatically and launches a Node script that fetches a JavaScript loader (observed staged on Vercel) and executes it.

2) Build-time execution when running the app

Other variants trigger when a developer starts the project (for example, npm run dev). These repos embed malicious logic in seemingly normal assets (e.g., a trojanized jquery.min.js). The asset decodes a base64 URL, retrieves the loader (again, frequently from Vercel), and executes it in memory.

3) Backend startup execution with env exfiltration + dynamic RCE

A third path activates during server initialization/module import. Repos may contain a .env value like AUTH_API=<base64>. On startup, backend code decodes the endpoint, posts process.env to the attacker, then executes returned JavaScript using dynamic compilation (e.g., new Function("require", response.data)(require)). This can leak sensitive configuration and enables operator-driven follow-on payload delivery.

Stage 1 registration → staged command-and-control

Across all paths, execution converges on an initial “registrar” stage that profiles the host and polls a registration endpoint, receiving an instanceId to correlate subsequent activity. Telemetry also noted persistent callbacks to attacker-controlled infrastructure (including HTTP traffic on port 300) after initial staging.

Impact for IT admins and security teams

  • Higher risk on developer endpoints: Opening a repo can be enough to execute code if workspace tasks are trusted.
  • Credential exposure: The backend startup path can exfiltrate environment variables (cloud keys, database credentials, CI tokens).
  • Harder detection: In-memory execution and staged loaders can reduce obvious on-disk artifacts.

Action items / next steps

  • Developer guidance: Treat take-home assessments and unfamiliar repos as untrusted; avoid clicking “Trust” in VS Code until reviewed.
  • Repo inspection: Flag/inspect .vscode/tasks.json (especially runOn: "folderOpen"), unexpected Node scripts under .vscode/, and minified libraries that don’t match known-good hashes.
  • Secret hygiene: Reduce reliance on long-lived secrets in .env; use managed identities/short-lived tokens where possible and rotate any exposed credentials.
  • Detection & controls: Monitor Node.js processes for unusual outbound connections (e.g., dev tools calling staging domains followed by unknown C2), and consider egress restrictions from developer devices and build agents.
  • Hunting: Search code hosting and internal mirrors for naming “families” and structural reuse patterns described by Microsoft (near-duplicate repos, similar loaders, repeated staging endpoints).

Need help with Security?

Our experts can help you implement and optimize your Microsoft solutions.

Talk to an Expert

Stay updated on Microsoft technologies

Microsoft DefenderNext.jssupply chain securityVisual Studio CodeNode.js

Related Posts

Security

macOS ClickFix Campaign Hides Behind Fingerprinting

Microsoft Threat Intelligence reports that a macOS ClickFix campaign has shifted from openly serving malicious lures to using server-side browser fingerprinting that mainly exposes the payload to likely macOS victims. The change makes the operation harder for crawlers, sandboxes, and defenders to spot, increasing the importance of hunting for shared infrastructure patterns and strengthening endpoint protections.

Security

Microsoft CNAPP Leader: KuppingerCole 2026 Report

Microsoft has been named a Leader across all four categories in KuppingerCole’s 2026 CNAPP Leadership Compass, highlighting Defender for Cloud’s unified approach to cloud and AI security. The recognition matters for security teams as CNAPP platforms increasingly focus on exploitability, attack path analysis, AI security posture, and integrated SOC operations across multicloud environments.

Security

ChainDrop npm Attack: Self-Propagating Worm Explained

Microsoft has detailed ChainDrop, a large-scale npm supply chain attack that compromised more than 400 packages using a self-propagating credential-stealing worm. The campaign matters because it targets developer workstations and CI/CD pipelines, steals cloud and publishing credentials, and can automatically republish infected packages across additional publishers.

Security

Microsoft Defender Device Isolation Stops Ransomware

Microsoft Defender’s attack disruption now includes automatic device isolation for compromised endpoints, adding a new containment layer beyond user-based response. In a published QNET case study, Defender isolated an endpoint in 128 seconds, stopping a multi-stage ransomware-related attack before persistence, credential theft, or lateral movement could occur.

Security

Zero Trust for AI: New Microsoft Security Tools

Microsoft has expanded its Zero Trust for AI strategy with new assessment capabilities, a DevSecOps pillar in the Zero Trust Workshop, and practical implementation guidance. The updates help security and platform teams assess AI-related risk, secure AI-assisted development, and build a phased roadmap for adopting Zero Trust controls across AI systems.

Security

CaptiveCrunch Malware Campaign Targets Travelers

Microsoft has disclosed CaptiveCrunch, an active campaign linked to Midnight Blizzard that hijacks traffic on hospitality and captive portal networks to steal credentials and deliver malware. The threat is especially relevant for organizations with frequent travelers because attackers are abusing Entra ID device code flows, fake update prompts, and adversary-in-the-middle phishing to compromise corporate accounts and endpoints.