# 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/fastapi-security-secrets) (Journeyman): A secret typed into the code goes wherever the code goes, GitHub included, so an API reads its secrets from environment variables, keeps them in a .env file that .gitignore leaves out, commits a .env.example instead, stops at startup when one is missing, and rotates any secret that was ever pushed.
2. [The Attacks to Expect: Injection and Mass Assignment](https://www.ask-codey.com/lessons/fastapi-security-common-attacks) (Journeyman): An API online gets requests no app of yours would send, so it keeps typed text out of its SQL with placeholders, takes only the fields a person may change with a model that forbids extras, answers errors without their inner details, and checks its packages for known holes with pip-audit.

Source: https://www.ask-codey.com/courses/python-web-apis/topics/fastapi-secrets-and-attacks
