Secrets and Attacks

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

Updated

  1. Keeping Secrets Out of Your Code (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 (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.