CompTIA CySA+ (CS0-003) — Question 292

A company has recently experienced a security breach via a public-facing service. Analysis of the event on the server was traced back to the following piece of code:

SELECT * From user_data WHERE Username = 0 and userid= 1 or 1=1;--

Which of the following controls would be best to implement?

Answer options

Correct answer: D

Explanation

The correct answer is D, as validating user input is crucial in preventing SQL injection attacks, which this code demonstrates. Options A and B do not address the specific vulnerability related to input handling, while C focuses on access control rather than input validation.