Sins of SQL Injection Flashcards

1
Q

What is SQL injection?

A

SQL injection occurs when an attacker provides a database application with malformed data that is used to build a SQL statement using string concatenation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does SQL stand for?

A

Structured Query Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an example of malformed data in SQL injection?

A

Expecting a number for a calculation but receiving an alphabetical character or sentence instead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is string concatenation?

A

String concatenation is the process of adding characters, words, or sentences together to form a new string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Provide an example of a SQL statement vulnerable to injection.

A

Select creditcard_no from customer where customer_id = ‘+ id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can an attacker exploit this vulnerability?

A

By providing an input such as ‘1 or 2 > 1’ which retrieves all credit card information from the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are two methods to prevent SQL injection?

A

Validation and Sanitization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does validation help prevent SQL injection?

A

Validation ensures the input is of the expected type, such as checking if id is a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of sanitization in preventing SQL injection?

A

Sanitization removes illegal characters from the input to ensure it is safe.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are prepared statements and how do they help prevent SQL injection?

A

Prepared statements use placeholders for inputs and ensure that inputs are treated as data, not executable code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why is it important to understand the database you are using in the context of SQL injection?

A

To know if it supports stored procedures, the comment operator, and if it allows attackers to call extended functionality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What should you use to build SQL statements securely?

A

Parameterized queries, also known as prepared statements, placeholders, or parameter binding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Where should database connection information be stored?

A

In a location outside the application, such as a protected configuration file or the Windows registry.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why should you encrypt sensitive database data?

A

To protect it from unauthorized access and ensure data privacy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why should you avoid simply stripping out “bad words” from input?

A

Because there are many variants and escapes that may not be detected, and it can sometimes leave remnants of bad words.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the risks of using string concatenation to build SQL statements?

A

It is prone to SQL injection attacks if inputs are not properly sanitized.

17
Q

What is a dangerous practice regarding database account privileges?

A

Connecting to the database as a highly privileged account such as sa or root.

18
Q

Where should you avoid storing database configuration information?

A

In the web root.

19
Q

What is a secure way to manage user access to database objects?

A

Deny direct access to underlying database objects and grant access only to stored procedures and views.

20
Q

What should be done instead of using untrusted parameters in stored procedures?

A

Use parameterized queries and validate input for trustworthiness.