Best Practices
Security Best Practices
Writing secure Python code and avoiding vulnerabilities
Interview: Security awareness — all levels
Security
Python applications face the same security threats as any web service. Key areas: input validation, dependency management, and secret handling.
Critical Rules
- Never use exec() or eval() on user input — allows arbitrary code execution
- Use parameterized queries — never string formatting for SQL
- Pin dependencies — use tools like Dependabot for vulnerability alerts
- Never commit secrets — use environment variables or vault services
- Validate and sanitize all input — especially from HTTP requests