Which technology type describes an SQL injection that has compromised a database

  1. Documents
  2. Computers
  3. Security

IoT Sec Quiz 2

Uploaded by

Pablo Parreño

0 ratings0% found this document useful (0 votes)

612 views10 pages

Document Information

click to expand document information

Description:

IoT Security

Original Title

IoT_Sec_Quiz_2

Copyright

© © All Rights Reserved

Share this document

Share or Embed Document

Sharing Options

  • Share on Facebook, opens a new window

    Facebook

  • Share on Twitter, opens a new window

    Twitter

  • Share on LinkedIn, opens a new window

    LinkedIn

  • Share with Email, opens mail client

    Email

  • Copy Link

    Copy Link

Did you find this document useful?

0%0% found this document useful, Mark this document as useful

0%0% found this document not useful, Mark this document as not useful

Is this content inappropriate?

Report this Document

SaveSave IoT_Sec_Quiz_2 For Later

0 ratings0% found this document useful (0 votes)

612 views10 pages

IoT Sec Quiz 2

Original Title:

IoT_Sec_Quiz_2

Uploaded by

Pablo Parreño

Description:

IoT Security

Full description

SaveSave IoT_Sec_Quiz_2 For Later

0%0% found this document useful, Mark this document as useful

0%0% found this document not useful, Mark this document as not useful

Embed

Share

Jump to Page

You are on page 1of 10

Search inside document

You're Reading a Free Preview
Pages 5 to 9 are not shown in this preview.

Buy the Full Version

Reward Your Curiosity

Everything you want to read.

Anytime. Anywhere. Any device.

No Commitment. Cancel anytime.

Which technology type describes an SQL injection that has compromised a database

Share this document

Share or Embed Document

Sharing Options

  • Share on Facebook, opens a new window
  • Share on Twitter, opens a new window
  • Share on LinkedIn, opens a new window
  • Share with Email, opens mail client
  • Copy Link

Quick navigation

  • Home

  • Books

  • Audiobooks

  • Documents

    , active

In computing, SQL injection is a code injection technique used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).[1][2] SQL injection must exploit a security vulnerability in an application's software, for example, when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as an attack vector for websites but can be used to attack any type of SQL database.

SQL injection attacks allow attackers to spoof identity, tamper with existing data, cause repudiation issues such as voiding transactions or changing balances, allow the complete disclosure of all data on the system, destroy the data or make it otherwise unavailable, and become administrators of the database server.

In a 2012 study, it was observed that the average web application received four attack campaigns per month, and retailers received twice as many attacks as other industries.[3]

History[edit]

The first public discussions of SQL injection started appearing around 1998;[4] for example, a 1998 article in Phrack Magazine.[5]

SQL injection (SQLI) was considered one of the top 10 web application vulnerabilities of 2007 and 2010 by the Open Web Application Security Project.[6] In 2013, SQLI was rated the number one attack on the OWASP top ten.[7] There are four main sub-classes of SQL injection:

The Storm Worm is one representation of Compounded SQLI.[12]

This classification represents the state of SQLI, respecting its evolution until 2010—further refinement is underway.[13]

Technical implementations[edit]

Incorrectly constructed SQL statements[edit]

This form of injection relies on the fact that SQL statements consist of both data used by the SQL statement and commands that control how the SQL statement is executed. For example, in the SQL statement

' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
0 the string '
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
1' is data and the fragment
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
2 is an example of a command (the value
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
3 is also data in this example).

SQL injection occurs when specially crafted user input is processed by the receiving program in a way that allows the input to exit a data context and enter a command context. This allows the attacker to alter the structure of the SQL statement which is executed.

As a simple example, imagine that the data '

' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
1' in the above statement was provided by user input. The user entered the string '
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
1' (without the apostrophes) in a web form text entry field, and the program used string concatenation statements to form the above SQL statement from the three fragments
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
6, the user input of '
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
1', and
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
8.

Now imagine that instead of entering '

' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
1' the attacker entered
SELECT * FROM users WHERE name = '' OR '1'='1';
0.

The program will use the same string concatenation approach with the 3 fragments of

' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
6, the user input of
SELECT * FROM users WHERE name = '' OR '1'='1';
0, and
' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 
8 and construct the statement
SELECT * FROM users WHERE name = '' OR '1'='1';
4. Many databases will ignore the text after the '--' string as this denotes a comment. The structure of the SQL command is now
SELECT * FROM users WHERE name = '' OR '1'='1';
5 and this will select all person rows rather than just those named 'susan' whose age is 2. The attacker has managed to craft a data string which exits the data context and entered a command context.

A more complex example is now presented.

Imagine a program creates a SQL statement using the following string assignment command :

SELECT * FROM users WHERE name = '' OR '1'='1';
6

This SQL code is designed to pull up the records of the specified username from its table of users. However, if the "userName" variable is crafted in a specific way by a malicious user, the SQL statement may do more than the code author intended. For example, setting the "userName" variable as:

' OR '1'='1

or using comments to even block the rest of the query (there are three types of SQL comments[14]). All three lines have a space at the end:

' OR '1'='1' --
' OR '1'='1' {
' OR '1'='1' /* 

renders one of the following SQL statements by the parent language:

SELECT * FROM users WHERE name = '' OR '1'='1';

SELECT * FROM users WHERE name = '' OR '1'='1' -- ';

If this code were to be used in authentication procedure then this example could be used to force the selection of every data field (*) from all users rather than from one specific user name as the coder intended, because the evaluation of '1'='1' is always true.

The following value of "userName" in the statement below would cause the deletion of the "users" table as well as the selection of all data from the "userinfo" table (in essence revealing the information of every user), using an API that allows multiple statements:

a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't

This input renders the final SQL statement as follows and specified:

SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't';

While most SQL server implementations allow multiple statements to be executed with one call in this way, some SQL APIs such as PHP's

SELECT * FROM users WHERE name = '' OR '1'='1';
7 function do not allow this for security reasons. This prevents attackers from injecting entirely separate queries, but doesn't stop them from modifying queries.

Blind SQL injection[edit]

Blind SQL injection is used when a web application is vulnerable to an SQL injection but the results of the injection are not visible to the attacker. The page with the vulnerability may not be one that displays data but will display differently depending on the results of a logical statement injected into the legitimate SQL statement called for that page. This type of attack has traditionally been considered time-intensive because a new statement needed to be crafted for each bit recovered, and depending on its structure, the attack may consist of many unsuccessful requests. Recent advancements have allowed each request to recover multiple bits, with no unsuccessful requests, allowing for more consistent and efficient extraction.[15] There are several tools that can automate these attacks once the location of the vulnerability and the target information has been established.[16]

Conditional responses[edit]

One type of blind SQL injection forces the database to evaluate a logical statement on an ordinary application screen. As an example, a book review website uses a query string to determine which book review to display. So the URL

SELECT * FROM users WHERE name = '' OR '1'='1';
8 would cause the server to run the query

SELECT * FROM bookreviews WHERE ID = '5';

from which it would populate the review page with data from the review with ID 5, stored in the table bookreviews. The query happens completely on the server; the user does not know the names of the database, table, or fields, nor does the user know the query string. The user only sees that the above URL returns a book review. A hacker can load the URLs

SELECT * FROM users WHERE name = '' OR '1'='1';
9 and
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
0, which may result in queries

SELECT * FROM bookreviews WHERE ID = '5' OR '1'='1';
SELECT * FROM bookreviews WHERE ID = '5' AND '1'='2';

respectively. If the original review loads with the "1=1" URL and a blank or error page is returned from the "1=2" URL, and the returned page has not been created to alert the user the input is invalid, or in other words, has been caught by an input test script, the site is likely vulnerable to an SQL injection attack as the query will likely have passed through successfully in both cases. The hacker may proceed with this query string designed to reveal the version number of MySQL running on the server:

SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
1, which would show the book review on a server running MySQL 4 and a blank or error page otherwise. The hacker can continue to use code within query strings to achieve their goal directly, or to glean more information from the server in hopes of discovering another avenue of attack.[17][18]

Second order SQL injection[edit]

Second order SQL injection occurs when submitted values contain malicious commands that are stored rather than executed immediately. In some cases, the application may correctly encode an SQL statement and store it as valid SQL. Then, another part of that application without controls to protect against SQL injection might execute that stored SQL statement. This attack requires more knowledge of how submitted values are later used. Automated web application security scanners would not easily detect this type of SQL injection and may need to be manually instructed where to check for evidence that it is being attempted.

Mitigation[edit]

An SQL injection is a well known attack and easily prevented by simple measures. After an apparent SQL injection attack on TalkTalk in 2015, the BBC reported that security experts were stunned that such a large company would be vulnerable to it.[19]

Object relational mappers[edit]

Developers can use ORM frameworks such as Hibernate[20] to create database queries in a safe and developer-friendly way. Since database queries are no longer constructed as strings, there is no danger of an injection vulnerability.[21]

While WAF products such as ModSecurity CRS[22] cannot prevent SQL injection vulnerabilities from creeping into a codebase, they can make discovery and exploitation significantly more challenging to an attacker.

Parameterized statements[edit]

With most development platforms, parameterized statements that work with parameters can be used (sometimes called placeholders or bind variables) instead of embedding user input in the statement. A placeholder can only store a value of the given type and not an arbitrary SQL fragment. Hence the SQL injection would simply be treated as a strange (and probably invalid) parameter value. In many cases, the SQL statement is fixed, and each parameter is a scalar, not a table. The user input is then assigned (bound) to a parameter.[23]

Easily put, using parameterized queries can definitely prevent SQL injection. This mainly means that your variables aren't query strings that would accept arbitrary SQL inputs, however, some parameters of given types are definitely necessary. Parameterized queries require the developer to define all the code. Therefore, without parameterized queries, anyone could put any kind of SQL code into the field, and have the database erased. But if the parameters were to set to '@username' then the person would only be able to put in a username without any kind of code.[24]

Enforcement at the coding level[edit]

Using object-relational mapping libraries avoids the need to write SQL code. The ORM library in effect will generate parameterized SQL statements from object-oriented code.

Escaping[edit]

A popular, though error-prone, way to prevent injections is to attempt to escape all characters that have a special meaning in SQL. The manual for an SQL DBMS explains which characters have a special meaning, which allows creating a comprehensive blacklist of characters that need translation. For instance, every occurrence of a single quote (

SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
2) in a parameter must be replaced by two single quotes (
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
3) to form a valid SQL string literal. For example, in PHP it is usual to escape parameters using the function
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
4 before sending the SQL query:

$mysqli = new mysqli('hostname', 'db_username', 'db_password', 'db_name');
$query = sprintf("SELECT * FROM `Users` WHERE UserName='%s' AND Password='%s'",
                  $mysqli->real_escape_string($username),                  $mysqli->real_escape_string($password));
$mysqli->query($query);

This function prepends backslashes to the following characters:

SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
5,
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
6,
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
7,
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
8,
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
2,
a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't
0 and
a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't
1. This function is normally used to make data safe before sending a query to MySQL.[25]
PHP has similar functions for other database systems such as pg_escape_string() for PostgreSQL. The function
a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't
2 works for escaping characters, and is used especially for querying on databases that do not have escaping functions in PHP. It returns a string with backslashes before characters that need to be escaped in database queries, etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).[26]
Routinely passing escaped strings to SQL is error prone because it is easy to forget to escape a given string. Creating a transparent layer to secure the input can reduce this susceptibility to error, if not entirely eliminate it.[27]

Pattern check[edit]

Integer, float or boolean, string parameters can be checked if their value is valid representation for the given type. Strings that must follow some strict pattern (date, UUID, alphanumeric only, etc.) can be checked if they match this pattern.

Database permissions[edit]

Limiting the permissions on the database login used by the web application to only what is needed may help reduce the effectiveness of any SQL injection attacks that exploit any bugs in the web application.

For example, on Microsoft SQL Server, a database logon could be restricted from selecting on some of the system tables which would limit exploits that try to insert JavaScript into all the text columns in the database.

What technology is used to secure lots?

A blockchain is decentralized, so there is no single authority that can approve the transactions or set specific rules to have transactions accepted.
XSS is a code injection method whereby a threat actor injects and executes malicious code within a web application by bypassing the mechanisms that validate input. The malicious code is executed in the browser of users accessing the exploited web application.

What is the intent of a threat actor that is performing a port scan against a targeted device?

Part of the reconnaissance process, an attacker can use the data collected by a port scan to find out what services a device is running and to get an idea of the OS being used. This data can then be used to flag vulnerable systems with the intention of exploiting them to gain access to the network.

What tool is used by nefarious individuals or groups to accelerate reconnaissance of Internet connected devices?

What tool is used by nefarious individuals or groups to accelerate reconnaissance of internet-connected devices? A threat actor uses network scanning tools and penetration tools to discover the IP address and manufacturer of a home wireless router.