Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-89 (SQL命令中使用的特殊元素转义处理不恰当(SQL注入)) — Vulnerability Class 9015

9015 vulnerabilities classified as CWE-89 (SQL命令中使用的特殊元素转义处理不恰当(SQL注入)). AI Chinese analysis included.

CWE-89 represents a critical input validation weakness where software constructs SQL commands using untrusted data without properly sanitizing special characters. Attackers typically exploit this vulnerability by injecting malicious SQL syntax into user-facing inputs, such as login fields or search queries, to manipulate the database’s behavior. This exploitation can lead to unauthorized data access, data modification, or complete system compromise by bypassing authentication or executing arbitrary commands. Developers mitigate this risk by implementing strict input validation and, most effectively, using parameterized queries or prepared statements. These techniques ensure that user input is treated strictly as data rather than executable code, thereby preventing the injection of malicious SQL elements. By separating code logic from data inputs, applications maintain integrity and protect sensitive information from unauthorized manipulation.

MITRE CWE Description
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.
Common Consequences (5)
Confidentiality, Integrity, AvailabilityExecute Unauthorized Code or Commands
Adversaries could execute system commands, typically by changing the SQL statement to redirect output to a file that can then be executed.
ConfidentialityRead Application Data
Since SQL databases generally hold sensitive data, loss of confidentiality is a frequent problem with SQL injection vulnerabilities.
AuthenticationGain Privileges or Assume Identity, Bypass Protection Mechanism
If poor SQL commands are used to check user names and passwords or perform other kinds of authentication, it may be possible to connect to the product as another user with no previous knowledge of the password.
Access ControlBypass Protection Mechanism
If authorization information is held in a SQL database, it may be possible to change this information through the successful exploitation of a SQL injection vulnerability.
IntegrityModify Application Data
Just as it may be possible to read sensitive information, it is also possible to modify or even delete this information with a SQL injection attack.
Mitigations (5)
Architecture and DesignUse a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482]. For example, consider using persistence layers such as Hibernate or Enterprise Java Beans, which can provide significant protection against SQL injection if used properly.
Architecture and DesignIf available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated. Process SQL queries using prepared statements, parameterized queries, or stored procedur…
Architecture and Design, OperationRun your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database ad…
Architecture and DesignFor any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
ImplementationWhile it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or whit…
Examples (2)
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.
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.
... 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); ...
Bad · C#
SELECT * FROM items WHERE owner = <userName> AND itemname = <itemName>;
Informative
CVE IDTitleCVSSSeverityPublished
CVE-2022-2876 SourceCodester Student Management System index.php sql injection — Student Management System 6.3 Medium2022-08-18
CVE-2022-2847 SourceCodester Guest Management System front.php sql injection — Guest Management System 6.3 Medium2022-08-16
CVE-2022-2812 SourceCodester Guest Management System index.php sql injection — Guest Management System 7.3 High2022-08-14
CVE-2022-35942 loopback-connector-postgresql Vulnerable to Improper Sanitization of `contains` Filter — loopback-connector-postgresql 9.3 Critical2022-08-12
CVE-2022-35956 update_by_case before 0.1.3 vulnerable to sql injection — activerecord-update-by-case 5.8 Medium2022-08-12
CVE-2022-2803 SourceCodester Zoo Management System animals.php sql injection — Zoo Management System 6.3 Medium2022-08-12
CVE-2022-2802 SourceCodester Gas Agency Management System login.php sql injection — Gas Agency Management System 7.3 High2022-08-12
CVE-2022-2801 SourceCodester Automated Beer Parlour Billing System Login sql injection — Automated Beer Parlour Billing System 6.3 Medium2022-08-12
CVE-2022-2797 SourceCodester Student Information System view_student.php sql injection — Student Information System 6.3 Medium2022-08-12
CVE-2022-2774 SourceCodester Library Management System student.php sql injection — Library Management System 6.3 Medium2022-08-11
CVE-2022-2772 SourceCodester Apartment Visitor Management System action-visitor.php sql injection — Apartment Visitor Management System 6.3 Medium2022-08-11
CVE-2022-2771 SourceCodester Simple Online Book Store System bookPerPub.php sql injection — Simple Online Book Store System 6.3 Medium2022-08-11
CVE-2022-2770 SourceCodester Simple Online Book Store System book.php sql injection — Simple Online Book Store System 6.3 Medium2022-08-11
CVE-2022-2766 SourceCodester Loan Management System index.php sql injection — Loan Management System 7.3 High2022-08-11
CVE-2022-2747 SourceCodester Simple Online Book Store book.php sql injection — Simple Online Book Store 6.3 Medium2022-08-11
CVE-2022-2745 SourceCodester Gym Management System Add New Trainer add_trainers.php sql injection — Gym Management System 6.3 Medium2022-08-11
CVE-2022-2728 SourceCodester Gym Management System index.php sql injection — Gym Management System 6.3 Medium2022-08-09
CVE-2022-2727 SourceCodester Gym Management System login.php sql injection — Gym Management System 6.3 Medium2022-08-09
CVE-2022-2726 SEMCMS Ant_Check.php sql injection — SEMCMS 6.3 Medium2022-08-09
CVE-2022-2724 SourceCodester Employee Management System aprocess.php sql injection — Employee Management System 6.3 Medium2022-08-09
CVE-2022-2723 SourceCodester Employee Management System eprocess.php sql injection — Employee Management System 6.3 Medium2022-08-09
CVE-2022-2722 SourceCodester Simple Student Information System manage_course.php sql injection — Simple Student Information System 6.3 Medium2022-08-09
CVE-2022-2715 SourceCodester Employee Management System eloginwel.php sql injection — Employee Management System 6.3 Medium2022-08-09
CVE-2022-2269 Website File Changes Monitor < 1.8.3 - Admin+ SQLi — Website File Changes Monitor 7.2 -2022-08-08
CVE-2022-2708 SourceCodester Gym Management System login.php sql injection — Gym Management System 5.5 Medium2022-08-08
CVE-2022-2707 SourceCodester Online Class and Exam Scheduling System faculty_sched.php sql injection — Online Class and Exam Scheduling System 6.3 Medium2022-08-08
CVE-2022-2706 SourceCodester Online Class and Exam Scheduling System class_sched.php sql injection — Online Class and Exam Scheduling System 6.3 Medium2022-08-08
CVE-2022-2705 SourceCodester Simple Student Information System manage_department.php sql injection — Simple Student Information System 6.3 Medium2022-08-08
CVE-2022-2703 SourceCodester Gym Management System Exercises Module sql injection — Gym Management System 6.3 Medium2022-08-08
CVE-2022-2700 SourceCodester Gym Management System GET Parameter sql injection — Gym Management System 4.7 Medium2022-08-08

Vulnerabilities classified as CWE-89 (SQL命令中使用的特殊元素转义处理不恰当(SQL注入)) represent 9015 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.