securityAnswer last reviewed July 2026

When you're building a Node backend, what vulnerability classes are you actually defending against, and where does each one get into the system?

Strong answers name the vulnerability classes that actually hit Node backends and point at the exact spot each one gets in, instead of reciting OWASP.

What an AI-prepared candidate might say

So the big ones would be injection, broken auth and authorization, sensitive data exposure, and then vulnerable dependencies, that kind of thing. Injection is like SQL injection where you're concatenating strings into queries, and command injection when user input gets passed to a shell. For auth I'd do proper session or token handling with secure cookie flags, and check authorization on every request. Secrets go in environment variables, never in the repo, and traffic runs over TLS obviously. Dependencies are kind of a Node-specific problem because a typical app pulls in this huge tree of packages, so I run npm audit and keep a lockfile committed. And then the usual stuff, validate and sanitize user input, set security headers, rate limiting to slow down abuse. Basically defense in depth, so one mistake doesn't sink the whole thing.

Senior

I like naming these by mechanism, because each one has a specific door it walks in through. Command injection comes in through child_process. exec and execSync run their string through a shell, so any user input in there can carry shell metacharacters. execFile and spawn without shell: true pass arguments as an array straight to the binary, no shell involved at all, and that just deletes the whole class. Pick the array form and you're done with it.

Prototype pollution is the weird Node one. An attacker sends keys like __proto__ in a parsed JSON body or a merged query object, and that writes onto Object.prototype. Now every object in the process inherits the polluted property, and behavior changes nowhere near where the injection happened, which makes it miserable to debug. It gets in through recursive merges, Object.assign from untrusted data, sloppy query parsers.

Then there's input-driven denial of service, which comes in through the body parser and the regex engine. Deeply nested JSON, a huge body with no size limit, a regex with catastrophic backtracking, the ReDoS thing. Any of those lets a tiny request burn a ton of CPU or memory. Payload size limits, depth limits, and keeping nested quantifiers out of your regexes covers it.

And the dependency tree. Your own code is a fraction of what actually runs. Lockfiles pin versions, sure, but a compromised package or a malicious install script executes with your privileges. Last one is secrets exposure through config, credentials sitting in the repo, in logs, in error output. The point is each class maps to an actual line of code or config, so you can audit for it instead of waving at 'validate input.'

Staff

When I bring this into a design review I order it by blast radius, because you're never fixing everything at once. Some of these hand an attacker the whole box, others just degrade one endpoint, and they should not get equal attention. Remote code execution goes on top. Command injection through child_process, a malicious dependency running at install or runtime, deserializing untrusted data into something executable. Those get the hard controls. No shell interpolation anywhere, execFile and spawn with array args, install scripts reviewed or flat-out disabled in CI, lockfile with integrity hashes.

Next tier down is auth bypass and data exposure. Prototype pollution flipping an authorization flag lives here, so do secrets leaking into logs. I don't trust humans to catch these in review, I put automated gates on them. A scanner that flags exec calls with interpolation, a secret scanner in CI that actually fails the build, dependency provenance so a package from an unexpected publisher gets caught.

Below that, input-driven DoS. It hurts availability but doesn't hand anyone access, so it gets rate limits, body-size caps enforced during the read, regex review. It doesn't block a release the way an RCE finding does, and I'm comfortable saying that out loud.

The thing I'll push back on hard is a wall of npm audit warnings treated like a security program. I've watched a team drown in those, and most of them were non-exploitable transitive advisories in dev dependencies, which is exactly how the one exploitable path gets missed. Spend the review budget on the catastrophic classes, automate the rest, and tie the whole model to specific Node entry points, with gates on anything that grants code execution.

Trap flags
  • A lot of people just rattle off the OWASP top ten, 'injection, broken auth, XSS', with nothing Node-specific behind any of it and no threat model holding it together.
  • Watch out for lumping everything under 'validate your inputs'. JSON parsing, prototype pollution, and ReDoS are three different doors, and the interviewer wants to hear that you know it.
  • 'Sanitize inputs and use HTTPS' as the whole answer goes nowhere, you have not named a single concrete Node attack surface.
Follow-up chain
When you're building a Node backend, what vulnerability classes are you actually defending against, and where does each one get into the system? | NodeBook