Skip to content

Latest commit

 

History

History
101 lines (59 loc) · 3.85 KB

security.md

File metadata and controls

101 lines (59 loc) · 3.85 KB

13. Security (Basics only) 5%

Security checklist:

  1. Embrace linter security rules:

  2. Limit concurrent requests using a middleware:

  3. Extract secrets from config files or use packages to encrypt them:

  4. Prevent query injection vulnerabilities with ORM/ODM libraries.

The following libraries have built-in protection agains injection attacks:

- https://github.com/sequelize/sequelize
- https://github.com/tgriesser/knex
- https://github.com/Automattic/mongoose
  1. Avoid DOS attacks by explicitly setting when a process should crash.

  2. Adjust the HTTP response headers for enhanced security:

  3. Constantly and automatically inspect for vulnerable dependencies:

  4. Avoid using the Node.js crypto library for handling passwords, use Bcrypt:

  5. Escape HTML, JS and CSS output

  6. Validate incoming JSON schemas:

  7. Support blacklisting JWT tokens:

  8. Limit the allowed login requests of each user

  9. Run Node.js as non-root user:

  10. Limit payload size using a reverse-proxy or a middleware:

  11. Avoid JavaScript eval statements

  12. Prevent evil RegEx from overloading your single thread execution:

  13. Avoid module loading using a variable

  14. Run unsafe code in a sandbox:

  15. Take extra care when working with child processes:

  16. Hide error details from clients:

  17. Configure 2FA for npm or Yarn

  18. Modify session middleware settings:

  19. A list of 40 generic security advice (not specifically Node.js-related):

    • Require MFA/2FA for root account
    • Rotate passwords and access keys frequently, including SSH keys
    • Apply strong password policies, both for ops and in-application user management, see OWASP password recommendation
    • Do not ship or deploy with any default credentials, particularly for admin users
    • se only standard authentication methods like OAuth, OpenID, etc. — avoid basic authentication
    • Auth rate limiting: Disallow more than X login attempts (including password recovery, etc.) in a period of Y minutes
    • On login failure, don’t let the user know whether the username or password verification failed, just return a common auth error
    • Consider using a centralized user management system to avoid managing multiple account per employee (e.g. GitHub, AWS, Jenkins, etc) and to benefit from a battle-tested user management system

For more information see also https://github.com/i0natan/nodebestpractices/tree/security-best-practices-section#-65-collection-of-common-generic-security-best-practices-15-items