The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
N/A
Threat Mapped score: 0.0
Industry: Finiancial
Threat priority: Unclassified
CVE: CVE-2023-32530
SQL injection in security product dashboard using crafted certificate fields
CVE: CVE-2021-42258 — KEV
SQL injection in time and billing software, as exploited in the wild per CISA KEV.
CVE: CVE-2021-27101 — KEV
SQL injection in file-transfer system via a crafted Host header, as exploited in the wild per CISA KEV.
CVE: CVE-2020-12271 — KEV
SQL injection in firewall product's admin interface or user portal, as exploited in the wild per CISA KEV.
CVE: CVE-2019-3792
An automation system written in Go contains an API that is vulnerable to SQL injection allowing the attacker to read privileged data.
CVE: CVE-2004-0366
chain: SQL injection in library intended for database authentication allows SQL injection and authentication bypass.
CVE: CVE-2008-2790
SQL injection through an ID that was supposed to be numeric.
CVE: CVE-2008-2223
SQL injection through an ID that was supposed to be numeric.
CVE: CVE-2007-6602
SQL injection via user name.
CVE: CVE-2008-5817
SQL injection via user name or password fields.
CVE: CVE-2003-0377
SQL injection in security product, using a crafted group name.
CVE: CVE-2008-2380
SQL injection in authentication library.
CVE: CVE-2017-11508
SQL injection in vulnerability management and reporting tool, using a crafted password.
N/A
Phase | Note |
---|---|
Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |
Implementation | This weakness typically appears in data-rich applications that save user inputs in a database. |
Intro: In 2008, a large number of web servers were compromised using the same SQL injection attack string. This single string worked against many different programs. The SQL injection was then used to modify the web sites to serve malicious code.
Intro: The following code dynamically constructs and executes a SQL query that searches for items matching a specified name. The query restricts the items displayed to those where owner matches the user name of the currently-authenticated user.
Body: The query that this code intends to execute follows:
... string userName = ctx.getAuthenticatedUserName(); string query = "SELECT * FROM items WHERE owner = '" + userName + "' AND itemname = '" + ItemName.Text + "'"; sda = new SqlDataAdapter(query, conn); DataTable dt = new DataTable(); sda.Fill(dt); ...
Intro: This example examines the effects of a different malicious value passed to the query constructed and executed in the previous example.
Body: If an attacker with the user name wiley enters the string:
name'; DELETE FROM items; --
Intro: MS SQL has a built in function that enables shell command execution. An SQL injection in such a context could be disastrous. For example, a query of the form:
Body: Where $user_input is taken from an untrusted source.
SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='$user_input' ORDER BY PRICE
Intro: This code intends to print a message summary given the message ID.
Body: The programmer may have skipped any input validation on $id under the assumption that attackers cannot modify the cookie. However, this is easy to do with custom client code or even in the web browser.
$id = $_COOKIE["mid"]; mysql_query("SELECT MessageID, Subject FROM messages WHERE MessageID = '$id'");
Intro: This example attempts to take a last name provided by a user and enter it into a database.
Body: While the programmer applies an allowlist to the user input, it has shortcomings. First of all, the user is still allowed to provide hyphens, which are used as comment structures in SQL. If a user specifies "--" then the remainder of the statement will be treated as a comment, which may bypass security logic. Furthermore, the allowlist permits the apostrophe, which is also a data / command separator in SQL. If a user supplies a name with an apostrophe, they may be able to alter the structure of the whole statement and even change control flow of the program, possibly accessing or modifying confidential information. In this situation, both the hyphen and apostrophe are legitimate characters for a last name and permitting them is required. Instead, a programmer may want to use a prepared statement or apply an encoding routine to the input to prevent any data / directive misinterpretations.
$userKey = getUserID(); $name = getUserInput(); # ensure only letters, hyphens and apostrophe are allowed $name = allowList($name, "^a-zA-z'-$"); $query = "INSERT INTO last_names VALUES('$userKey', '$name')";