112-52 · Question #146
Which technique is MOST effective in preventing SQL Injection attacks?
The correct answer is A. Input validation and prepared statements. Input validation combined with prepared statements forms the strongest defense against SQL injection because prepared statements separate SQL code from user-supplied data, making it impossible for malicious input to alter query logic - even if an attacker injects characters like
Question
Which technique is MOST effective in preventing SQL Injection attacks?
Options
- AInput validation and prepared statements
- BDisabling TLS encryption
- CAllowing dynamic SQL queries
- DIncreasing database size
How the community answered
(43 responses)- A93% (40)
- B2% (1)
- D5% (2)
Explanation
Input validation combined with prepared statements forms the strongest defense against SQL injection because prepared statements separate SQL code from user-supplied data, making it impossible for malicious input to alter query logic - even if an attacker injects characters like '; DROP TABLE users; --, they are treated as literal data, not executable SQL.
Why the distractors fail:
- B (Disabling TLS) removes encryption for data in transit, which actually worsens security and has no bearing on SQL injection.
- C (Allowing dynamic SQL) is the root cause of SQL injection vulnerabilities - concatenating user input directly into queries is exactly what attackers exploit.
- D (Increasing database size) is a capacity concern with zero relevance to attack prevention.
Memory tip: Think of prepared statements as a menu with fixed slots - the chef (database) only fills in the blanks (parameters) you allow; a customer can't rewrite the menu itself no matter what they write on the order slip.
Topics
Community Discussion
No community discussion yet for this question.