Middleware order and missing checks
In Express, app.use(auth) only protects routes registered after it, and router-level middleware only covers that router. Tests should request every discovered route with no credentials, with a low-privilege user and with another user's object IDs. Admin routers mounted at /admin or /internal without their own guard are a frequent finding.
Injection patterns specific to Node
- NoSQL injection: with body parsing enabled, a field like {"password": {"$ne": null}} reaches Mongoose or the MongoDB driver as an operator unless input is cast or sanitised.
- Server-side JavaScript injection: eval, new Function or vm calls on user input give code execution. OWASP NodeGoat's eval-based injection is the textbook case.
- Prototype pollution: deep-merge of request JSON can set __proto__ properties that change application behaviour later.
- Command injection through child_process.exec with interpolated strings.
Authentication and session mistakes
- JWTs verified without pinning the algorithm, signed with weak secrets, or decoded with jwt.decode instead of jwt.verify.
- express-session with default in-memory store and weak secrets in production.
- No rate limiting on login, password reset or OTP endpoints.
- Stack traces returned to clients because NODE_ENV is not set to production.
Running Pentest-Swarm against an Express API
Pentest-Swarm sends real requests to the running service and confirms what it can prove. Its bundled lab profiles include OWASP NodeGoat, with deterministic chains for a cross-user IDOR on /allocations/:id and eval-based server-side JS injection, which makes a good dry run before testing your own app.
- Use the api-security playbook against your staging base URL for BOLA, BFLA and mass-assignment checks.
- If you use swagger-jsdoc or similar and serve /openapi.json, /swagger.json or /api-docs, recon finds it and maps every documented route.
- Pass a test user's token with
--author--headerto reach authenticated routes; jwt_tool is in the arsenal for JWT weaknesses. - Use
--safe-modeon shared environments to block destructive commands before execution.
Where it falls short
Black-box testing will not find an unsafe merge or eval that no reachable route exercises, and it cannot read your package-lock to list vulnerable dependencies. Combine it with npm audit or a software composition tool and with SAST rules for eval, child_process and unsanitised Mongo queries.
Questions
What is the most common Express vulnerability you find?
Broken access control: routes that check you are logged in but not that the object or function belongs to you. It is a logic flaw no framework setting prevents.
Does helmet make an Express app secure?
Helmet sets useful HTTP response headers. It does nothing for authorisation, injection or business logic, which is where most serious findings are.
Can Pentest-Swarm test a Node app with MongoDB?
Yes. NoSQL injection is one of the vulnerability classes it tests for, and it works over HTTP regardless of the database behind the API.