Comprehensive testing to identify security vulnerabilities and ensure APIs protect against attacks.
APIs are security-critical because they handle sensitive data and provide direct access to functions. Common vulnerabilities include missing authentication, weak authorization, SQL injection, and insecure data transmission. Security testing requires thinking like an attacker.
| Area | Test |
|---|---|
| Authentication | Can I access API without token or with invalid token? |
| Authorization | Can I access another user's data by changing user ID? |
| Input Validation | What happens with SQL injection or special characters? |
| Data Encryption | Is HTTPS enforced? Are credentials transmitted securely? |
| Rate Limiting | Can I overload API with rapid requests? |
Scenario: Your banking API handles sensitive financial transactions. A security audit reveals several vulnerabilities. You have 3 critical issues to fix: (1) User A can see User B's account balance by changing account_id in request, (2) Passwords are transmitted over HTTP (not HTTPS), (3) API has no rate limiting - attacker can brute force login 10,000 times/second. Prioritize these and explain your fixing approach with testing strategy.