Node.js Developer interview question · Most asked
What are key security practices for Node.js web applications?
Summary
Validate all input (schemas), use parameterized queries, set security headers (helmet), apply rate limiting, keep dependencies patched (npm audit, Dependabot), avoid eval/child_process.exec with user input, protect against prototype pollution, store secrets in env/secret managers, and run as a non-root user.
Longer Answer
Also: limit request body sizes, use HTTPS, configure CORS narrowly, hash passwords with bcrypt/argon2, set secure cookie flags, and avoid exposing stack traces. Node's permission model (--permission) can restrict file system and child process access.
Key Points
- Validate input, parameterize queries
- Helmet, CORS, rate limits
- Patch dependencies; audit
- No eval/exec with user input
- Least privilege runtime
More most-asked Node.js Developer questions
- Why is CPU-bound work a problem in Node.js and how do you handle it?
- What are streams in Node.js and what is backpressure?
- What is the difference between `process.nextTick`, Promise microtasks, `setImmediate` and `setTimeout(fn, 0)`?
- Explain the phases of the Node.js event loop.
- What is Node.js and why is it well suited to I/O-heavy servers?
- How has asynchronous code evolved in Node.js: callbacks, Promises and async/await?
- Walk through how an Express app handles a request, including errors from async handlers.
- What are the differences between CommonJS and ES modules in Node.js?