Injection - Examples
Bad vs Good Code Comparisons
❌ VULNERABLE:``python
query = f"SELECT * FROM users WHERE id = {user_id}"
`
✅ SECURE:
`python
cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
``
Key Takeaways
- Never concatenate user input into queries
- Use parameterized queries always
- Validate input format
- Apply least privilege
What's Next?
- Overview: Understand what injection is
- Attack Vectors: Learn how attacks happen
- Prevention: Best practices for prevention
- Lab: Hands-on practice
---
Part of the OWASP Top 10 Educational Repository