Prepare for the Ethical Hacking Essentials Test. Study with flashcards and multiple-choice questions, each exam includes hints and explanations. Get ready to ace your certification exam!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What practice aids developers in defending against SQL injection attacks?

  1. Test the content of string variables

  2. Use global variables

  3. Allow all user input

  4. Restrict database access

The correct answer is: Test the content of string variables

Testing the content of string variables is a crucial practice in defending against SQL injection attacks. SQL injection occurs when an attacker is able to manipulate a SQL query by injecting malicious code through user inputs. By rigorously testing the content of string variables, developers can ensure that only expected and valid data is processed in SQL queries, thereby preventing potential harmful input from being executed. This practice often involves using parameterized queries or prepared statements, which separate SQL code from data, ensuring that user input cannot alter the intended logic of the query. Other options, such as using global variables, allowing all user input, or restricting database access, do not directly address the specific vulnerabilities that SQL injection exploits. Global variables can actually introduce additional risks and complexity, while allowing all user input can directly lead to exploit opportunities. Restricting database access is good practice for security but does not defend against SQL injection by itself. Therefore, thoroughly testing string variables is a proactive measure to mitigate these risks effectively.