CompTIA Security Plus Mock Test Q581

Which of the following BEST describes a protective countermeasure for SQL injection?

A. Eliminating cross-site scripting vulnerabilities
B. Installing an IDS to monitor network traffic
C. Validating user input in web applications
D. Placing a firewall between the Internet and database servers

Correct Answer: C
Section: Threats and Vulnerabilities

By validating user input and preventing special characters, we can prevent the injection of client-side scripting code.
SQL injection is a code injection technique, used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker). SQL injection must exploit a security vulnerability in an application’s software, for example, when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as an attack vector for websites but can be used to attack any type of SQL database.

Incorrect Answers:
A: Eliminating cross-site scripting vulnerabilities is always a good idea. However, that will not prevent SQL Injection attacks. Therefore this answer is incorrect.
B: An intrusion detection system (IDS) is a device or software application that monitors network or system activities for malicious activities or policy violations and produces reports to a management station. IDS come in a variety of “flavors” and approach the goal of detecting suspicious traffic in different ways. There are network based (NIDS) and host based (HIDS) intrusion detection systems. Some systems may attempt to stop an intrusion attempt but this is neither required nor expected of a monitoring system. Intrusion detection and prevention systems (IDPS) are primarily focused on identifying possible incidents, logging information about them, and reporting attempts. In addition, organizations use IDPSes for other purposes, such as identifying problems with security policies, documenting existing threats and deterring individuals from violating security policies.
An IDS is not used to prevent SQL Injection attacks. Therefore this answer is incorrect.
D: A firewall is used to restrict the flow of traffic between subnets based on rules that specify what source/destination IP addresses, ports and protocols are allowed. A firewall is not used to prevent SQL Injection attacks. Therefore this answer is incorrect.