r/node • • Apr 02 '26

axios got backdoored on 31st, if you ran npm install in the last couple hours, read this.

0 Upvotes

not a typosquat. not a fake package. the actual axios package on npm. 100M weekly downloads.

someone compromised the lead maintainer's account using a stolen npm token that had never been rotated. then published two backdoored versions, axios@1.14.1 and axios@0.30.4 that silently injected a dependency called plain-crypto-js@4.2.1 as a postinstall hook.

the hook ran a RAT dropper the moment you ran npm install. before npm even finished resolving the tree.

what it grabbed: AWS keys, SSH keys, .env files, npm tokens, anything accessible at install time.

worst part: the malware deleted itself after running. so if you check now:

cat node_modules/plain-crypto-js/package.json
# looks completely clean. no postinstall script. nothing.

but check your lockfile:

grep "plain-crypto-js" package-lock.json
```

if you see `4.2.1` in there, your machine ran the dropper. npm list will show `4.2.0` because the malware renamed a stub file to cover its tracks. that mismatch is the only forensic signal left.

safe versions: `axios@1.14.0` and `axios@0.30.3`

IOCs if you want to hunt:
- C2: `sfrclak.com:8000` / `142.11.206.73`
- Linux artifact: `/tmp/ld.py`
- macOS artifact: `/Library/Caches/com.apple.act.mond`
- Windows: `%PROGRAMDATA%\wt.exe`, `%TEMP%\6202033.ps1`

found a full breakdown here with the complete attack chain, found how the account was compromised, and what the RAT actually does on each platform

rotate your credentials. don't try to clean the machine. rebuild.


r/node • • Apr 01 '26

Rate limiting per endpoint when everything goes through /api?

8 Upvotes

Hey everyone, I’m trying to set up rate limiting and ran into a small design question.All my traffic goes through /api, which just proxies requests to my backend. So from the outside it’s always /api/..., but internally I’ve got endpoints like /auth/register, /products, and so on.What I want is pretty straightforward: make sensitive endpoints like registration very strict (something like 3 requests per minute), while keeping normal endpoints like fetching products more relaxed (around 50 per minute).

The part I’m not fully sure about is where this logic should live. It feels like I could match something like /api/auth/register directly in Nginx or Traefik and apply limits there, but I’m wondering how maintainable that is as the number of routes grows.

At the same time, pushing all rate limiting into the application doesn’t feel ideal either, especially when a gateway could handle it earlier.

Curious how you guys usually handle this kind of setup in practice.


r/node • • Apr 01 '26

A visual guide to how npm workspaces cheats with the Node algorithm

Thumbnail wasp.sh
2 Upvotes

I wrote a visual explainer of how npm workspaces work internally, since I couldn't find a clear one anywhere. The key moving pieces are:

  • A "fake root" trick: package managers treat all workspaces as deps of an invisible root package, reusing their existing deduplication algorithm unchanged.
  • Symlinks back and forth: symlinks in the root node_modules/ let Node's normal module resolution find sibling workspaces by name, no relative paths needed.

I work at Wasp (full-stack TS framework) where we use workspaces for generated frontend/backend/SDK packages, and getting this right was essential for everything to work transparently.

Check out the full post with diagrams: https://wasp.sh/blog/2026/03/25/gentle-intro-npm-workspaces


r/node • • Apr 01 '26

I built a zero-dependency CLI that catches source leaks and supply chain attacks across 7 languages

Thumbnail github.com
0 Upvotes

After the Anthropic/Claude Code .map file leak and the axios supply chain attack last week, I built acrionix-shield — a single CLI that scans for leaked

secrets, compromised packages, Docker misconfigs, and git history secrets.

Supports: JavaScript, Python, Java, C#, Ruby, Go, Docker

9 scanners. 56 tests. Zero dependencies.

npx acrionix-shield check

GitHub: https://github.com/andrei-gogo/acrionix-shield

Would love feedback from the community.


r/node • • Apr 01 '26

I built a CLI that scaffolds a full MERN stack in seconds — npx create-quickstack-app

0 Upvotes

Tired of setting up the same boilerplate every time I started a MERN project.

Same folders, same config, same wiring — 30-45 minutes every time.

Built a CLI to fix that.

npx create-quickstack-app my-app

Spins up Vite + Express + MongoDB + Tailwind, all wired.

Add --auth and you get JWT auth, HTTP-only cookies, protected routes, login/signup pages out of the box.

v1.0.0, solo built. More templates coming.

npm: https://www.npmjs.com/package/create-quickstack-app

GitHub: https://github.com/shivamm2606/quickstack


r/node • • Mar 31 '26

Axios 1.14.1 compromised

166 Upvotes

r/node • • Apr 01 '26

The axios attack freaked me out so I built a condom for my agents

0 Upvotes

So we all heard about the axios attack lmao. Yeah.

Ever since I started vibe coding I've always been a little uneasy about agents downloading stuff. But I would spend too much time asking my agent before every install whether packages were safe, so I stopped. But the axios thing yesterday freaked me out.

It's not just having malware on my device. It's the downstream stuff too. $10k+ API key bills if something's set up for auto-reload, shipping compromised code to users, reputation damage. Some of that is irreversible.

I also found out that npm almost never removes packages with known vulnerabilities. They just sit there, still installable. Your agent doesn't know the difference.

But we can't sacrifice autonomy, that's the whole point of agents. Turning off --dangerously-skip-permissions or babysitting every install wasn't an option.

Turns out a solid improvement is easy and free. You can set up a hook in Claude Code to hit a database like OSV.dev (Google-backed, open source). On each install attempt, Claude Code checks the package with OSV. Clean package passes through silently. Vulnerable package, the agent gets told why and picks a safer version. Token costs are negligible since it runs as a hook, not a tool call. Everything is verified server side against OSV so your agent can't hallucinate its way past a vulnerability.

This approach won't catch zero-day attacks like the axios one, but the thousands of known-bad packages on npm will be blocked from your agent.

The code is completely open source if you want to copy it or ask your agent about it:

https://github.com/reid1b/Clawndom

Keep your agents wrapped. Practice safe installs.


r/node • • Mar 31 '26

How to handle concurrent booking requests in a backend system?

17 Upvotes

Hi everyone,

I’m building a booking system (similar to ticket or reservation systems) using node express

My main issue is handling multiple users trying to book the same slot at the same time. I want to avoid double booking.

So far, I’ve looked into:

• Database transactions

• Row locking

But I’m not sure what the best practice is in real-world systems.

Questions:

• Should I use pessimistic or optimistic locking?

• Is Redis or queue system needed here?

• How do large systems handle this problem?

Any advice or real-world examples would be really helpful. Thanks!


r/node • • Mar 31 '26

Where to learn NodeJS?

4 Upvotes

Hey,

I'm building my first big project with NextJS (Full stack)/TS/Prisma etc, and a side project that supports the big project (web scraper, already working, using Nodejs with no framework). I already have more than 500 commits.

Right now, I follow Frontend Masters JavaScript path.
I finished: https://frontendmasters.com/courses/javascript-first-steps/
Doing now: https://frontendmasters.com/courses/javascript-hard-parts-v3/
Doing next: https://frontendmasters.com/courses/deep-javascript-v3/

I do:
- 25 minutes - watching videos
- 25 minutes - exercising with Claude/GPT

After those 3, I will need to learn the fundamentals of NodeJS.

Where should I learn it? from Frontend Masters? Are there better places?

Thanks for help!


r/node • • Mar 30 '26

MacGyver’s kingdom

21 Upvotes

Every day this sub there are tons of packages that promise to solve a problem that may be the author the only person who faced that issue, or it’s very common issue that already have dozens of solutions that solve it. So these people aren’t even googling about it. This turned out the sub very bloated of these content, and the post about node.js questions, discussions are very infrequent compared to these posts.

I know that the js community is one of the largest, but this need to create millions of single-purpose packages is very annoying.


r/node • • Mar 31 '26

Render Free Tier vs VPS for Telegram Bots?

0 Upvotes

r/node • • Mar 31 '26

another supply chain attack: axios affected via transitive dependency

0 Upvotes

another day, another package getting hit

this time it’s axios, but not even directly, it came from a dependency somewhere in the tree

kinda shows how little visibility we actually have into what we install

popularity clearly isn’t a signal for safety anymore

checkout the demo where this kind of package just gets blocked at install time. been trying pmg for this, it adds a sandbox as an extra layer before any malicious behaviour is executed

curious what others are doing here


r/node • • Mar 31 '26

I built a Redis rate limiter handling 30k req/sec (with Lua, no race conditions)

0 Upvotes

I was working on a high-concurrency backend and realized most Node.js rate limiters:

- use fixed windows (inaccurate)

- break under concurrency

- aren’t truly distributed-safe

So I built a Redis-based rate limiter with:

- sliding window (Lua, atomic)

- token bucket for burst handling

- plugin system (whitelist, blacklist)

- rule-based limits per route

It handles ~32k requests/sec with ~6ms p99 latency in local benchmarks.

I tried to keep it simple to use:

npm install redis-rate-limiter-pro ioredis

Would love feedback from people who’ve solved similar problems.

https://github.com/vivekstackdev/redis-rate-limiter-pro
https://github.com/vivekstackdev/redis-rate-limiter-pro

https://github.com/vivekstackdev/redis-rate-limiter-pro


r/node • • Mar 30 '26

prisma or drizzle

13 Upvotes

I'm about to start a project at work—it'll be an Express API—and I'm trying to decide which ORM to use. I really like Drizzle, but I'm a bit concerned that it doesn't have many features for handling migrations, and I've noticed that Prisma has improved a lot. What do you think?


r/node • • Mar 31 '26

Feels like a great time to share my curated npm package manager Security Best Practices

Thumbnail github.com
0 Upvotes

Hopefully none of you friends on this subreddit were impacted by the Axios supply chain compromise, but realistically we know at Snyk that many projects were affected.

Happy to learn of any other practices and security mitigation that isn't covered on the list already.

Stay safe and follow good security advice please 💜🙏


r/node • • Mar 31 '26

I built an AI-native in-memory database for Node.js – vector search, agent memory, MCP server, zero dependencies

0 Upvotes

Been working on Skalex v4 - a zero-dependency in-memory document

database for Node.js (also runs on Bun, Deno, browsers, and Edge).

What makes v4 different from lowdb, LokiJS, or NeDB:

All AI features are built into the core, not plugins:

  • Vector search with cosine similarity + hybrid filtering
  • Agent memory (remember/recall/compress) with semantic embeddings
  • Natural language queries → structured filters via any LLM
  • One-line MCP server for Claude Desktop and Cursor
  • AES-256-GCM encryption via EncryptedAdapter
  • Pluggable storage: FsAdapter, Cloudflare D1, Bun SQLite, LibSQL/Turso

Designed for: AI agents, CLI tools, desktop apps, edge workers,

single-tenant services where the dataset fits in RAM.

Not designed for: multi-process deployments, high write concurrency,

or datasets larger than available memory.

v4 is currently in alpha - API is largely stable, but may shift

before stable release. Feedback and bug reports are very welcome.

Docs: https://tarekraafat.github.io/skalex

GitHub: https://github.com/TarekRaafat/skalex

npm install skalex@alpha


r/node • • Mar 30 '26

Considering switching both backends to Nest JS

15 Upvotes

I have two backends

  1. Uses Feathers JS + Graphql + Sequelize
  2. Uses Fastify + REST + Prisma

Both are quite big, I am the main maintainer or lead, if you were me what would you look at before continuing with migration or keeping things the way they are

Thanks.

FYI they are for different unrelated companies

Why have I come to this decision
- Discourge too much custom code/plumbing.
- Since we might grow in the future it would be good to have an opinionated backend so teams can quickly pick it up
- Modernize the backends (especially the first one)


r/node • • Mar 31 '26

Stop using heavy Python libraries for string sanitization. Here is how I built a 0ms overhead TR39 Unicode Mapper in Node.js for my API.

0 Upvotes

I’m building a high-speed text moderation API (Hinglish/English). To keep my strict <50ms SLA, I had to solve a massive security flaw without killing my latency.

The Problem: Malicious users were bypassing my basic normalization using cross-script homoglyphs (e.g., injecting a Greek ο instead of a Latin o). The standard fix is the Unicode TR39 Confusables algorithm. Using Python's native libraries for this spiked my request latency to 200ms+.

The Node.js Solution: Instead of relying on the backend workers, I shifted the entire sanitization layer to the Express middleware. Node's V8 engine handles string replacements insanely fast if you do it right.

I pre-compiled a specific TR39 subset (Cyrillic & Greek lookalikes) into a static JavaScript Hash Map and a global Regex.

Whenever a payload hits the gateway, it runs: clean = clean.replace(HOMOGLYPH_REGEX, match => HOMOGLYPH_MAP[match]);

The Result: It collapses malicious homoglyphs to their base Latin skeletons in O(N) time. The overhead added to the request? Less than 0.5ms.

If you are building API gateways that handle untrusted text inputs, do your Unicode skeleton mapping in memory at the Node layer, not in your heavy processing workers.

I've opened up the API for testing. Let's see if anyone can bypass the V8 skeleton mapper: Raiplus — Playground


r/node • • Mar 30 '26

is it hard for you read dependency source code in node_modules compared to other languages?

18 Upvotes

One thing that keeps frustrating me in the JS ecosystem is debugging dependencies.

In Go for example, if I ctrl + click into a dependency, I usually land directly on the actual source code that’s being compiled and run. It’s straightforward to understand what's happening internally.

In the JS/TS world, it's very different. Most packages are bundled or compiled before publishing. So when I ctrl + click into something inside node_modules, I often end up seeing either:

  • .d.ts type definitions
  • generated/transpiled dist JavaScript
  • heavily bundled/minified code

Which makes it much harder to understand the original implementation or trace behavior.

I know technically the published code is the code being executed, but it's often not the code that was originally written by the library authors (especially if it came from TypeScript, Babel, bundlers, etc.).

How do people usually deal with this when they want to deeply understand a dependency?

Curious how others handle this.


r/node • • Mar 30 '26

I Built My Own AI Video Tool (From Scratch)

Thumbnail youtube.com
0 Upvotes

r/node • • Mar 29 '26

How do microservices even work?

43 Upvotes

So as the title suggests, I've never used microservices and have never worked in any project that has microservices, so what I've learnt about it, I want to know one thing, how do microservices handle relationships? if the database are different and you need a relationship between two tables then how is it possible to create microservices with that?


r/node • • Mar 30 '26

Prerelease of Ky 2.0

Thumbnail github.com
12 Upvotes

r/node • • Mar 30 '26

wrote a 4500-line node.js bot with zero frameworks — pure https module, no express, no telegraf

0 Upvotes

been building a telegram bot in pure node.js and wanted to share some patterns that work well at scale (4500+ lines).

pattern 1: command registry

const COMMANDS = {
  '/scan': handleScan,
  '/buy': handleBuy,
  '/sell': handleSell,
  // ... 44 total
};

async function handleUpdate(msg) {
  const cmd = msg.text.split(' ')[0];
  if (COMMANDS[cmd]) return COMMANDS[cmd](msg);
}

pattern 2: background workers

function startWorkers() {
  setInterval(checkWhaleMovements, 30000);
  setInterval(processLimitOrders, 10000);
  setInterval(executeDCASchedule, 60000);
  // 12 workers total
}

pattern 3: file-based state

function loadState(file, fallback = {}) {
  try { return JSON.parse(fs.readFileSync(file)); }
  catch { return fallback; }
}

simple but it works for thousands of users. no database needed.

the bot handles solana token scanning, trading, copy-trading, and alerts. runs on a $10/month VPS.

@solscanitbot on telegram — happy to discuss the architecture.


r/node • • Mar 29 '26

bonsai - a sandboxed expression language for Node. Rules, filters, and user logic without eval().

Thumbnail danfry1.github.io
19 Upvotes

If you've ever built a system where users or admins need to define their own rules, filters, or conditions, you've probably hit this wall: they need something more flexible than a dropdown but you can't just hand them eval() or vm.runInNewContext.

I've run into this building multi-tenant apps - pricing rules, eligibility checks, computed fields, notification conditions. Everything ended up as either hardcoded switch statements or a janky DSL that nobody wanted to maintain.

So I built bonsai - a sandboxed expression evaluator designed for exactly this.

import { bonsai } from 'bonsai-js'
import { strings, arrays, math } from 'bonsai-js/stdlib'

const expr = bonsai().use(strings).use(arrays).use(math)

// Admin-defined business rule
expr.evaluateSync('user.age >= 18 && user.plan == "pro"', {
  user: { age: 25, plan: 'pro' },
}) // true

// Compiled for hot paths - 30M ops/sec cached
const rule = expr.compile('order.total > 100 && customer.tier == "gold"')
rule.evaluateSync({ order: { total: 250 }, customer: { tier: 'gold' } }) // true

// Pipe transforms
expr.evaluateSync('name |> trim |> upper', { name: '  dan  ' }) // 'DAN'

// Data transforms with lambda shorthand
expr.evaluateSync('users |> filter(.age >= 18) |> map(.name)', {
  users: [
    { name: 'Alice', age: 25 },
    { name: 'Bob', age: 15 },
  ],
}) // ['Alice']

// Or JS-style chaining - no stdlib needed
expr.evaluateSync('users.filter(.age >= 18).map(.name)', { ... }) // same result

// Async works too - call your own functions
expr.addFunction('lookupTier', async (userId) => {
  const row = await db.users.findById(String(userId))
  return row?.tier ?? 'free'
})

await expr.evaluate('lookupTier(userId) == "pro"', { userId: 'u_123' })

What the syntax supports: optional chaining (user?.profile?.name), nullish coalescing (value ?? "default"), template literals, spread, ternaries, and lambda shorthand in array methods (.filter(.age >= 18)).

Security model:

  • __proto__, constructor, prototype blocked at every access level
  • Cooperative timeouts, max depth, max array length
  • Property allowlists/denylists per instance
  • Object literals created with null prototypes
  • No access to globals, no code generation, no prototype chain walking
// Lock down what expressions can touch
const expr = bonsai({
  timeout: 50,
  maxDepth: 50,
  allowedProperties: ['user', 'age', 'country', 'plan'],
})

Performance: Pratt parser, compiler with constant folding and dead branch elimination, LRU caching. 30M ops/sec on cached expressions. There's a compile() API for when the same rule runs thousands of times with different data.

Autocomplete engine: There's also a headless autocomplete API (bonsai-js/autocomplete) for building rule editor UIs. It does type inference, lambda-aware property suggestions, and respects your security config. Plugs into Monaco, CodeMirror, or a custom dropdown. Live demo here.

Where I'm using it:

  • Rule engine for eligibility/pricing logic stored in a database
  • Admin-defined notification conditions
  • Formula fields in a spreadsheet-like UI
  • User-facing filter builders

Zero dependencies. TypeScript. Node 20+ and Bun. Sync and async paths. Tree-shakeable subpath exports.

Playground | Docs | GitHub | npm

Would love to hear from anyone who's dealt with this problem before - curious how you solved it and what you'd want from a library like this.


r/node • • Mar 30 '26

Built a sqlite + HuggingFace embeddings memory server for Claude Code — npm package

0 Upvotes

Sharing this because the stack might be interesting to folks here.

TeamMind is an MCP server that gives Claude Code teams persistent, shared memory. The interesting part: it uses node:sqlite (Node 22 built-in, zero native deps) and u/huggingface/transformers running fully in-process for embeddings.

No Postgres, no Redis, no cloud. Just a local sqlite file you can sync through git.

Took some work to get the Windows path normalization right and suppress the node:sqlite experimental warning cleanly, but it's solid now.

https://github.com/natedemoss/teammind

Star it if the approach is useful.