Security for Expresss
Express security practice is hardening an app against common attacks. It includes setting secure HTTP headers with helmet, configuring CORS narrowly, rate limiting, hashing passwords with bcrypt or Argon2, protecting sessions and cookies, validating input and keeping dependencies updated with npm audit.
Stage: Security and Release · Part of the Express roadmap · Last reviewed 19 November 2026
What to learn in Security
- Add helmet to set headers such as Content-Security-Policy and X-Content-Type-Options
- Configure CORS to allow only trusted origins and methods
- Apply rate limiting to login and public endpoints to slow abuse
- Hash passwords with bcrypt and store session cookies with httpOnly, secure and sameSite flags
- Scan and update dependencies with npm audit and lock files
Security interview questions
What does CORS protect against and what does it not?
CORS is a browser rule that stops a web page from reading responses from another origin unless the server allows it. It does not protect the API from non-browser clients such as curl, so authentication and authorisation are still required.
Why should you never store passwords as plain text or with a fast hash?
If the database leaks, plain text exposes every account and fast hashes such as MD5 can be brute forced quickly. Use a slow, salted algorithm like bcrypt or Argon2, which makes each guess expensive.
Where Security fits in the Express roadmap
Security belongs to the Security and Release stage (intermediate level). Ship safely.
Other units in this stage
Back to the full Express roadmap