How to Prevent API Injection Attacks?
Short answer
C Validate, filter, and sanitize all incoming data.
Question
Key Takeaways
The exam tests your ability to distinguish generic security best practices from the specific control—input validation, filtering, and sanitization—that directly prevents injection attacks.
API injection attacks are mitigated by validating, filtering, and sanitizing all incoming data before processing. Community consensus strongly confirms option C as the correct defense against injection vectors.
Common mistake: Candidates often choose option D (short-lived tokens) because token management is a popular API security topic, but tokens authenticate callers and do not prevent malicious payloads from being injected.
Expert Analysis
Why the Answer Is Correct
Option C directly addresses the root cause of injection attacks: untrusted input reaching an interpreter or backend. Validating ensures data conforms to expected formats, filtering removes disallowed characters, and sanitization neutralizes payloads before execution. This defense-in-depth approach is the universally accepted method for preventing SQL injection, command injection, and similar API injection variants.
Why the Other Options Are Wrong
Option A (logging failed attempts) is a detective control that helps after an attack occurs but does nothing to block the malicious payload itself. Option B (password hashing with biometrics) strengthens user authentication but has no bearing on how incoming API data is processed. Option D (short-lived tokens and app authentication) reduces the blast radius of credential theft but does not inspect or neutralize injected content within otherwise valid requests.
Community Comment Notes
Commenters unanimously support option C, with multiple users linking to authoritative sources such as IEEE Computer Society and Escape.tech that emphasize input validation, sanitization, and escaping. Comment [5] adds valuable context by recommending parameterized queries as a complementary technique to separate code from user input, reinforcing the principle of never trusting raw data.
Official Reference
- https://www.computer.org/publications/tech-news/trends/api-injection-attacks-prevention
- https://escape.tech/blog/what-is-api-injection-attack-and-how-to-stop/
These links open the official vendor documentation in a new tab.
Exam Strategy
When a question mentions 'injection,' immediately look for the answer containing 'validate,' 'sanitize,' or 'filter.' Distractors often describe strong but unrelated controls like token rotation or logging—always match the control to the specific threat.
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 5 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 5
-
slacker_at_work 👍 2 Answered COptions A, B, and D are related to general security best practices but are not specifically targeted at preventing API injection attacks.
-
Mekai2020 👍 2 Answered C"validate" https://www.computer.org/publications/tech-news/trends/api-injection-attacks-prevention
-
masrur 👍 1 Answered Cinput validation, filtering, and sanitization for data integrity. Use parameterized queries to separate code from user inputs, preventing injections.
-
felix_simon 👍 1c Always validate, sanitize, and/or escape user inputs. https://escape.tech/blog/what-is-api-attack-and-how-to-stop/
-
chiacche 👍 1 Answered CAPI injection attack → Validate, filter, and sanitize all incoming data.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All 350-401 Questions
Access 218 questions with complete answers and detailed explanations.
View Full 350-401 Practice Test →