PrepAway - Latest Free Exam Questions & Answers

How should you secure the queries?

You are developing an ASP.NET MVC application that uses forms authentication. The application uses SQL
queries that display customer order data.
Logs show there have been several malicious attacks against the servers.
You need to prevent all SQL injection attacks from malicious users against the application.
How should you secure the queries?

PrepAway - Latest Free Exam Questions & Answers

A.
Check the input against patterns seen in the logs and other records.

B.
Escape single quotes and apostrophes on all string-based input parameters.

C.
Implement parameterization of all input strings.

D.
Filter out prohibited words in the input submitted by the users.

Explanation:
SQL Injection Prevention, Defense Option 1: Prepared Statements (Parameterized Queries)
The use of prepared statements (aka parameterized queries) is how all developers should first be taught how to
write database queries. They are simple to write, and easier to understand than dynamic queries.
Parameterized queries forcethe developer to first define all the SQL code, and then pass in each parameter to
the query later. This coding style allows the database to distinguish between code and data, regardless of what
user input is supplied.
Prepared statements ensure that anattacker is not able to change the intent of a query, even if SQL commands
are inserted by an attacker.
SQL Injection Prevention Cheat Sheet


Leave a Reply