How do you secure a Node.js application?

Instruction: Describe the strategies to secure a Node.js application.

Context: This question evaluates the candidate's awareness of security practices and their ability to apply them in Node.js applications to prevent common vulnerabilities.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

Start with the application's trust boundaries and sensitive operations. Validate request types, size, ranges and allowed fields on the server. Use parameterized database queries and context-appropriate output handling; generic input sanitization does not replace either. Avoid evaluating user-supplied code or building shell commands from it.

Authenticate identities and authorize each operation against the specific resource and tenant...

Related Questions