Node.js app security: a checklist from OWASP's guidance
Review Node.js request limits, asynchronous errors, permissions, headers and dependencies without treating runtime controls as a sandbox.
OWASP's NodeJS Security Cheat Sheet says Node.js apps are prone to the same web vulnerabilities as other frameworks and groups its advice under application security, error and exception handling, server security and platform security. We read all of its text on 15 November 2026. We skimmed its code samples without running them and did not read the Node.js and Express pages it links. Everything attributed is OWASP's. Module names appear only because the sheet names them, and we do not endorse them. Versions and flags are the sheet's statements; check the current Node.js documentation before relying on them.
Application security
- Set request size limits, by content type rather than one global number, since file uploads need more room than JSON. The sheet notes JSON is riskier than multipart because parsing JSON blocks. Attackers can lie about the Content-Type header, so validate the body against the declared type before processing.
- Do not block the event loop. Node.js runs your code on a single thread around non-blocking I/O, so a slow synchronous operation delays everyone. The sheet also warns about ordering bugs: a synchronous call outside an asynchronous callback may run first (its example deletes a file before the callback reads it), and such races can affect security, for example authentication in a callback with authenticated actions outside it.
- Validate input. The sheet shows how Express turns query strings into different types: a repeated or bracketed parameter can arrive as an array or an object instead of the string your code expects. Validate type, not just content.
- Escape output for the destination context (see our XSS posts) and log application activity, which helps debugging and incident response.
- Monitor the event loop and return 503 when response times pass a threshold, as one defence against overload.
- Protect against brute force on login: rate limiting, CAPTCHA and account lockout are all mentioned. One sample uses in-memory state that the sheet marks as unsuitable for production.
- Use CSRF protection if you rely on credentials browsers attach automatically; use the framework's own defence first.
- Remove unneeded routes. Frameworks that auto-generate API routes can expose more than intended.
- Prevent HTTP parameter pollution, where repeated parameters are read unpredictably (in Express as arrays).
- Return only what is necessary. Do not send whole user records, only the fields the client needs.
- Use object property descriptors to make properties non-writable or non-extensible where it helps.
- Use access control lists with least privilege per role.
Permissions
The sheet says a Permission Model exists from Node.js 20, is stable from 23.5.0 (also backported to22.13.0 per the official documentation), and is turned on with the --permission flag, with separate allow flags for file reads, file writes, child processes, workers, native addons and WASI. Its warning: symbolic links are followed even when they point outside the allowed paths, so avoid relative symlinks inside allowed paths. The current official documentation (https://nodejs.org/api/permissions.html) calls it a seat belt for trusted code, not a sandbox or protection against malicious code. Available permissions differ by release; use your deployed release's documentation.
Errors and exceptions
Handle uncaughtException by cleaning up, logging and exiting, so the process does not continue in an unknown state. Listen for error events on emitters. In asynchronous callbacks, pass an Error as the first argument and propagate it; callback failures must be routed to the framework's error handler. Promise rejection handling depends on the Express version and handler style; do not assume all asynchronous errors are caught automatically.
Server security
- Cookie flags:
httpOnly,SecureandSameSiteon session cookies. - Security headers, using a helper package that wraps many small header middlewares: Strict-Transport-Security, X-Frame-Options, Content-Security-Policy, X-Content-Type-Options, cache controls, and removing X-Powered-By. For X-XSS-Protection, the sheet says the header is deprecated and recommends setting it to 0. For CSP, it says the helper does little validation and recommends a CSP checker.
Platform security
- Keep packages up to date and scan them; it mentions
npm auditand other tools (see our post on vulnerable dependencies). - Avoid dangerous functions such as
eval(), and take care with thefsandvmmodules when input is user-controlled. - Avoid slow regular expressions (ReDoS), which can hang the app on crafted input.
- Run security linters, but the sheet says they do not replace static analysis security testing (SAST) tools with data-flow tracking.
- Use strict mode so that silent errors are thrown.
- Follow general application security principles too.
Questions for your team
- Which routes accept bodies, and what size and type limits apply to each?
- Do any handlers do slow synchronous work, or use regexes on user input?
- What happens to errors raised inside callbacks?
- Which unused routes or auto-generated endpoints are still on?
- Are cookie flags and security headers set, and checked after each framework upgrade?
Related: REST API security checklist, error handling without leaking details, XSS prevention for app teams, vulnerable dependencies.
Limits
One OWASP page, text read in full; code samples skimmed and untested; linked pages unread. Node.js version statements and module names reflect the sheet on the fetch date and may be out of date. We give no code and no statistics. Not every item applies to every app.
By Omnistu.