Chapter 2
Chapter 2
Last week
• We discussed:
• Malicious Software (Malware)
• Ransomware
• Brute force attack
• Man-in-the-middle attack
• We conducted a brute force attack in the lab.
This Lecture
• We will discuss code injection attack
• SQL injection
• In lab 3, you will have the chance to conduct SQL injection attack.
What is code injection attack?
What is software program?
Data
(e.g., username, password) output
input
Code
(e.g., java, node, SQL)
What is software program?
Data
(e.g., username, password) output
input
Data
(e.g., username, password) output
input
Code
(e.g., java, node, SQL) output
input
Code
(e.g., java, node, SQL) output
input
• The goal of code injection can vary but often includes data disclosure,
data tampering, bypassing access controls, or executing malicious
actions on the server or client-side systems.
General Example of code injection?
Data
(1, 2) output
input
Computer
Code
(x + Y)
General Example of code injection?
Data
(1, 2) output
input
Computer
1+2
Code
(x + Y)
General Example of code injection?
Data
(1, 2) output
input 3
Computer
1+2
Code
(x + Y)
General Example of code injection? What if I turn the data
into code?
Data
(1, 2) output
input 3
Computer
1+2
Code
(x + Y)
General Example of code injection? What if I turn the data
into code?
Data
(1, 2 / 0) output
input
Computer
Code
(x + Y)
General Example of code injection? What if I turn the data
into code?
Data
(1, 2 / 0) output
input
Computer
1+2/0
Code
(x + Y)
General Example of code injection? What if I turn the data
into code?
Data
(1, 2 / 0) output
input Error
Computer
1+2/0
Code
(x + Y)
Types of code injections
• SQL Injection (SQLi): This occurs when an attacker is able to inject
malicious SQL queries into an input field of an application, which are
then executed by the database. It can lead to unauthorized access to
or manipulation of the database.
• Cross-Site Scripting (XSS): In this attack, malicious scripts are injected
into content that is then served to other users. When the malicious
content is executed, it can steal cookies, session tokens, or other
sensitive information from the users.
SQL injection
• What is SQL?
• SQL, which stands for Structured Query Language, is a standard programming
language specifically designed for managing and manipulating relational
databases.
UPDATE Students SET Major = 'Software Engineering' WHERE Major = 'Computer Science';
SQL injection (SQL Review)
UPDATE Students SET Major = 'Software Engineering' WHERE Major = 'Computer Science';
SQL injection (SQL Review)
Delete Student with StudentID = 3
To delete the student whose StudentID is 3:
SELECT * FROM Students WHERE Major = ' ’; DELETE FROM Students; --’
SQL injection vulnerabilities
• SQL injection vulnerabilities occur when an application insecurely
accepts user input that is directly included in SQL statements without
proper validation or sanitization. This can allow attackers to
manipulate SQL queries and potentially access or modify data in ways
not intended by the application developer.
Where is the SQL injection vulnerabilities?
Where is the SQL injection vulnerabilities?
Accepts user input that is
directly included in SQL
statements