SQL Injection (Portswigger) Flashcards
What does SQLi stand for?
SQL Injection
What is SQLi?
SQL injection is a web security vulnerability that allows an attacker to interfere with the queries that an application makes to its database.
What does SQLi allow an attacker to do?
It allows an attacker to view data that they are not normally able to retrieve.
What kind of data could an attacker using SQLi view?
They could view data belonging to other users, or any other data that the application itself is able to access.
What could an attacker using SQLi do that’s common?
An attacker could modify or delete data, causing persistent changes to the applications behavior.
What could an attacker using SQLi do that’s not common
An attacker could escalate an SQL injection attack to compromise the underlying server or other back-end infrastructure, or perform a denial-of-service attack.
What is the impact of a successful SQL injection attack?
It can result in unauthorized access to sensitive data, such as passwords, credit card details, or personal user information.
What could an attacker potentially do with SQLi that is not very common?
An attacker could obtain a persistent backdoor into an organization’s systems, leading to a long-term compromise that can go unnoticed for an extended period.
List 5 SQLi examples and give a brief explanation about each one.
- Retrieving hidden data: can modify an SQL query to return additional results
- Subverting application logic: can change a query to interfere with the application’s logic
- UNION attacks: can retrieve data from different database tables
- Examining the database: can extract information about the version and structure of the database
- Blind SQLi: where the results of a query you could control are not returned in the application’s responses
Explain the double-dash sequence for revealing hidden data.
It’s a comment indicator in SQL, and means that the rest of the query is interpreted as a comment. This effectively removes the remainder of the query which could show hidden data.
What is this an example of and what could it do?
SELECT * FROM users WHERE username = ‘administrator’–’ AND password = ‘’
Subverting application logic
It returns the user whose username is administrator and successfully logs the attacker in as that user
What keyword would an attacker use to leverage an SQL injection vulnerability to retrieve data from other tables within a database?
UNION
What is this an example of and what does it do?
An application executes the following query containing the user input “Gifts”:
SELECT name, description FROM products WHERE category = ‘Gifts’
then an attacker can submit the input:
’ UNION SELECT username, password FROM users–
Retrieving data from other database tables
(SQL injection UNION attacks*)
This will cause the application to return all usernames and passwords along with the names and descriptions of products.
What are two ways of exploring a database?
Query the version details e.g.
Oracle:
SELECT * FROM v$version
Determine what database tables exist e.g.
Most databases you can use this to list the tables:
SELECT * FROM information_schema.tables
True or False?
Many instances of SQL injection are blind vulnerabilities.
If True, what does this mean?
It means the application does not return the results of the SQL query or the details of any database errors within its responses.
Give 3 examples of techniques that can be used to exploit blind injection vulnerabilities.
- Change the logic of the query to trigger a detectable difference in the application’s response depending on the truth of a single condition. This might involve injecting a new condition into some Boolean logic, or conditionally triggering an error such as a divide-by-zero.
- Conditionally trigger a time delay in the processing of the query, allowing you to infer the truth of the condition based on the time that the application takes to respond.
- Trigger an out-of-band network interaction, using OAST techniques. This technique is extremely powerful and works in situations where the other techniques do not. Often, you can directly exfiltrate data via the out-of-band channel, for example by placing the data into a DNS lookup for a domain that you control.
True or False?
The majority of SQL injection vulnerabilities can be found quickly and reliably using Burp Suite’s web vulnerability scanner.
True
List 5 typical tests to manually detect every entry point in an application via SQL injection.
- Submitting the single quote character ‘ and looking for errors or other anomalies.
- Submitting some SQL-specific syntax that evaluates to the base (original) value of the entry point, and to a different value, and looking for systematic differences in the resulting application responses.
- Submitting Boolean conditions such as OR 1=1 and OR 1=2, and looking for differences in the application’s responses
- Submitting payloads designed to trigger time delays when executed within an SQL query, and looking for differences in the time taken to respond.
- Submitting OAST payloads designed to trigger an out-of-band network interaction when executed within an SQL query, and monitoring for any resulting interactions.