8news

Tech • AI • Robotics

VIDEO
ENFR
TodayShortsTop StoriesYour topicFor youTopicsAll videosYT channelsArchivesSearchFavorites

How to Avoid Getting Hacked in Vibe Coding (Claude Code, Codex, Cursor)

5/10
AI Eng.Ben BKAugust 23, 2026 at 02:14 PM19:12
Audio player
0:00 / 0:00

TL;DR

Using npm install without safeguards can expose developers to supply-chain attacks through deeply nested dependencies, and a hardened PNPM setup plus Socket Firewall can sharply reduce that risk.

KEY POINTS

Why a routine install can become dangerous

A single npm install does not fetch only one library. It can pull in dozens or hundreds of direct and transitive dependencies, any of which may be compromised. That makes JavaScript package ecosystems an attractive target for supply-chain attackers seeking access to large numbers of developer machines.

Recent attacks were not theoretical

On 4 August 2026, multiple widely used packages linked to Kiv and Casable were reported compromised. Some affected versions contained a malicious preinstall script designed to steal data such as crypto assets, AWS keys and GitHub tokens. Because the compromised code sat deep in dependency trees, projects could be exposed without developers ever knowingly installing the package by name.

Transitive dependencies widen the blast radius

Popular tools such as ESLint can pull in large dependency chains indirectly. That means a compromised package several layers down can still execute on a machine during installation. In these cases, importing the package into application code is not even necessary; install-time scripts alone may be enough to trigger malicious behavior.

Switching from npm to PNPM adds supply-chain protections

PNPM remains compatible with the npm ecosystem but includes controls aimed at package security. Key protections include delayed adoption of fresh releases, trust-policy checks, blocking unusual transitive sources and strict handling of dependency build scripts. The recommendation is to install a stable PNPM release rather than the newest package published hours earlier.

A seven-day release delay is a strong first filter

A hardened configuration can set minimumReleaseAge to 10080 minutes, or 7 days, and fail installs that cannot meet that threshold. This blocks packages published too recently, giving the ecosystem time to detect malicious releases. Since many harmful packages are identified within minutes or hours, delaying installs by a week can eliminate a large share of immediate risk.

PNPM can reject suspicious dependency behavior

With trustPolicy: no-downgrade, PNPM can refuse a new version if its trust profile drops unexpectedly. With blockExoticSubdeps: true, deeply nested dependencies are prevented from quietly fetching code from Git repositories or arbitrary tarballs. These controls are intended to stop unusual behavior that often appears in supply-chain attacks.

Install scripts should require explicit approval

The highest-risk behavior often comes from preinstall, install and postinstall scripts. PNPM can be configured so that dependency build scripts must be reviewed and approved explicitly, and installs fail otherwise. That forces developers to inspect why a package needs install-time execution before allowing it to run.

Socket Firewall adds another free barrier

Socket Firewall Free can sit in front of package-manager commands and inspect requests before packages are installed. It can block packages already confirmed as malicious, warn on suspicious ones and also help protect against threats hidden in transitive dependencies. It does not catch every unknown malware sample, but it adds a useful extra layer at no cost.

Lockfiles are a core security control

The file pnpm-lock.yaml records the exact dependency tree that was resolved, including transitive packages and integrity data. Unlike package.json, which may allow version ranges, the lockfile captures what was actually installed. Committing the lockfile to Git and using pnpm install --frozen-lockfile helps prevent silent dependency drift.

Auditing and tracing still matter

pnpm audit helps check installed dependencies against known security issues, especially when focused on high and critical alerts. It is not an antivirus and cannot detect brand-new malware on its own. For packages flagged in reports but not directly installed, pnpm why can trace which dependency introduced them.

Development agents should be constrained

Coding agents often default to npm install automatically when adding features or scaffolding projects. A safer workflow is to enforce PNPM only, add hooks that block npm usage and keep the hardened workspace policy in every new project. That reduces the chance that automation will bypass security decisions during rapid development.

CONCLUSION

JavaScript package installation has become a supply-chain security problem as much as a convenience feature. Enforcing PNPM, delaying fresh releases, reviewing install scripts and adding Socket Firewall can materially lower the risk of malware entering through dependencies.

Explain this
Full transcript

More from AI Eng.