# Secrets and Attacks

Secrets and Attacks: Keeping Secrets Out of Your Code, The Attacks to Expect: Injection and Mass Assignment.

Updated: November 19, 2026

1. [Keeping Secrets Out of Your Code](https://www.ask-codey.com/lessons/node-security-secrets) (Journeyman): An API's secrets, such as the key that signs its tokens and its database password, live in environment variables loaded from a .env file that Git never sees, with a committed .env.example naming them, a check at startup that each one is set, and a new secret at once if one ever reaches GitHub.
2. [The Attacks to Expect: Injection and Mass Assignment](https://www.ask-codey.com/lessons/node-security-common-attacks) (Journeyman): The first things attackers try against an API are a MongoDB operator where text belongs, a body that sets fields it shouldn't, and errors that give details away, so an API checks that fields are text, copies only an allow-list of fields, answers errors in plain words and runs npm audit.

Source: https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-security-secrets-and-attacks
