Below you'll find a comprehensive Meteor security checklist that's intended to help you cover all the bases when it comes to securing your Meteor project. For a more in-depth guide to securing your application, be sure to read Secure Meteor!
Use Package Scan to check for Meteor packages with known vulnerabilities.
Your application code may be secure, but if you’re using a vulnerable Meteor package, your application is vulnerable.
Use Snyk and/or NSP to check for Node.js packages with known vulnerabilities.
Node.js dependencies lay the foundation for your Meteor application. Make sure that your foundation is sound.
Thoroughly check all method, publication, and route arguments.
check to make assertions about the type and shape of user inputs can prevent entire families of NoSQL injection vulnerabilities. Never pass unchecked data into a query.
Use trusted fields (like
this.userId) whenever possible.
Never use a user-provided field when a trusted alternative is available.
Verify that methods, publications, and server-side routes are making authentication and authorization checks.
Always verify that the current user has permission to do the thing they’re trying to do. Similarly, never assume that an unauthorized user can’t call a method or publication because it wasn’t publicly defined.
Always be aware of where your code is running.
Test that MongoDB queries are behaving as expected in all circumstances.
Incorrectly written queries can lead to over-publishing and the leaking of data to the client.
Rate limit and unblock your methods and publications where appropriate.
Take basic precautions against attackers potentially carrying out Denial of Services attacks through excessive method calls or subscriptions.
Avoid allow & deny collection validators.
Allow and deny rules can be hard to reason about and even harder to implement correctly.
Always whitelist the fields of documents returned by methods and subscriptions.
Whitelisting the fields returned by a query can prevent sensitive data being accidentally leaked to the client.
Use reactive data sources to securely invalidate cursors returned by publications.
Use reactive data sources like
this.userId, or the
reactive-publish package to continually ensure that a user is authorized to see the data being published.
Limit and audit the use of raw HTML injection.
Triple braces in Blaze,
dangerouslySetInnerHTML in React, and jQuery’s
html should be used sparingly. User-provided data being injected directly into the DOM must be thoroughly sanitized.
Check for other instances of cross-site scripting vulnerabilities.
Third party packages and plugins can sometimes be vulnerable to cross-site scripting attacks. Make sure you’re sanitizing user-provided data before handing it off to any front-end library.
Tighten up your content security policy.
browser-policy Meteor package to add a Content Security Policy to your application. Fine tune the CSP to meet your application’s needs.
Always use TLS/SSL.
force-ssl or configure your load balancer/reverse proxy to always redirect clients to a secure connection.
Consider rate limiting static asset and
Upfront work can mitigate the pain of Denial of Service attacks in the future.
Malicious users can inspect the source code and extract your sensitive business secrets or processes.
Never keep API tokens or other secrets directly in your source code.
Secrets kept in code can mistakenly find their way to the client where they can be discovered and abused by malicious users.
Don’t expose secrets through the
public field of
Secrets stored in
public will be exposed to the client.