CWEweakness

CWE-89 Improper Neutralization of Special Elements used in an SQL Command

High Official page ↗
Alternate terms
SQL Injection, SQLi
Abstraction
Base
Structure
Simple
Status
Stable
Likelihood of exploit
High
Languages
Go, Not Language-Specific, Python, SQL
CWE version
5.0

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

• Confidentiality, Integrity, Availability: Execute 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. • Confidentiality: Read Application Data — Since SQL databases generally hold sensitive data, loss of confidentiality is a frequent problem with SQL injection vulnerabilities. • Authentication: Gain 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 Control: Bypass 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. • Integrity: Modify 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.

Potential mitigations

• [Architecture and Design] Use 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 Design] If 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 procedures. These features should accept parameters or variables and support strong typing. Do not dynamically construct and execute query strings within these features using "exec" or similar functionality, since this may re-introduce the possibility of SQL injection. [REF-867] • [Architecture and Design, Operation] Run 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 administrator, especially in day-to-day operations. Specifically, follow the principle of least privilege when creating user accounts to a SQL database. The database users should only have the minimum privileges necessary to use their account. If the requirements of the system indicate that a user can read and modify their own data, then limit their privileges so they cannot read/write others' data. Use the strictest permissions possible on all database objects, such as execute-only for stored procedures. • [Architecture and Design] For 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. • [Implementation] While 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 white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88). Instead of building a new implementation, such features may be available in the database or programming language. For example, the Oracle DBMS_ASSERT package can check or enforce that parameters have certain properties that make them less vulnerable to SQL injection. For MySQL, the mysql_real_escape_string() API function is available in both C and PHP. • [Implementation] Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When constructing SQL query strings, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. This will indirectly limit the scope of an attack, but this technique is less important than proper output encoding and escaping. Note that proper output encoding, escaping, and quoting is the most effective solution for preventing SQL injection, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent SQL injection, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, the name "O'Reilly" would likely pass the validation step, since it is a common last name in the English language. However, it cannot be directly inserted into the database because it contains the "'" apostrophe character, which would need to be escaped or otherwise handled. In this case, stripping the apostrophe might reduce the risk of SQL injection, but it would produce incorrect behavior because the wrong name would be recorded. When feasible, it may be safest to disallow meta-characters entirely, instead of escaping them. This will provide some defense in depth. After the data is entered into the database, later processes may neglect to escape meta-characters before use, and you may not have control over those processes. • [Architecture and Design] When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. • [Implementation] Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success. If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files. Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not. In the context of SQL Injection, error messages revealing the structure of a SQL query can help attackers tailor successful attack strings. • [Operation] Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481. • [Operation, Implementation] When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.

Detection methods

• Automated Static Analysis: This weakness can often be detected using automated static analysis tools. Many modern tools use data flow analysis or constraint-based techniques to minimize the number of false positives. Automated static analysis might not be able to recognize when proper input validation is being performed, leading to false positives - i.e., warnings that do not have any security consequences or do not require any code changes. Automated static analysis might not be able to detect the usage of custom API functions or third-party libraries that indirectly invoke SQL commands, leading to false negatives - especially if the API/library code is not available for analysis. • Automated Dynamic Analysis: This weakness can be detected using dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results. • Manual Analysis: Manual analysis can be useful for finding this weakness, but it might not achieve desired code coverage within limited time constraints. This becomes difficult for weaknesses that must be considered for all inputs, since the attack surface can be too large. • Automated Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective: • Bytecode Weakness Analysis - including disassembler + source code weakness analysis • Binary Weakness Analysis - including disassembler + source code weakness analysis • Dynamic Analysis with Automated Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective: • Database Scanners Cost effective for partial coverage: • Web Application Scanner • Web Services Scanner • Dynamic Analysis with Manual Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful: Cost effective for partial coverage: • Fuzz Tester • Framework-based Fuzzer • Manual Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective: • Manual Source Code Review (not inspections) Cost effective for partial coverage: • Focused Manual Spotcheck - Focused manual analysis of source • Automated Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective: • Source code Weakness Analyzer • Context-configured Source Code Weakness Analyzer • Architecture or Design Review: According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective: • Formal Methods / Correct-By-Construction Cost effective for partial coverage: • Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)

Observed examples

• CVE-2024-6847: SQL injection in AI chatbot via a conversation message • CVE-2025-26794: SQL injection in e-mail agent through SQLite integration • CVE-2023-32530: SQL injection in security product dashboard using crafted certificate fields • CVE-2021-42258: SQL injection in time and billing software, as exploited in the wild per CISA KEV. • CVE-2021-27101: SQL injection in file-transfer system via a crafted Host header, as exploited in the wild per CISA KEV. • CVE-2020-12271: SQL injection in firewall product's admin interface or user portal, as exploited in the wild per CISA KEV. • 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-2004-0366: Chain: SQL injection in library intended for database authentication allows SQL injection and authentication bypass. • CVE-2008-2790: SQL injection through an ID that was supposed to be numeric. • CVE-2008-2223: SQL injection through an ID that was supposed to be numeric. • CVE-2007-6602: SQL injection via user name. • CVE-2008-5817: SQL injection via user name or password fields. • CVE-2003-0377: SQL injection in security product, using a crafted group name. • CVE-2008-2380: SQL injection in authentication library. • CVE-2017-11508: SQL injection in vulnerability management and reporting tool, using a crafted password.

Related

Attack pattern · CAPEC (6)

  • CAPEC-108 Command Line Execution through SQL Injection attack pattern
  • CAPEC-109 Object Relational Mapping Injection attack pattern
  • CAPEC-110 SQL Injection through SOAP Parameter Tampering attack pattern
  • CAPEC-470 Expanding Control over the Operating System from the Database attack pattern
  • CAPEC-66 SQL Injection attack pattern
  • CAPEC-7 Blind SQL Injection attack pattern

Observed example · CVE (15)

  • CVE-2025-26794 Exim 4.98 before 4.98.1, when SQLite hints and ETRN serialization are used, allows remote SQL injection. vulnerability
  • CVE-2024-6847 The Chatbot with ChatGPT WordPress plugin before 2.4.5 does not properly sanitise and escape a parameter before using it in a SQL… vulnerability
  • CVE-2023-32530 Vulnerable modules of Trend Micro Apex Central (on-premise) contain vulnerabilities which would allow authenticated users to perform a SQL… vulnerability
  • CVE-2021-42258 BQE BillQuick Web Suite 2018 through 2021 before 22.0.9.1 allows SQL injection for unauthenticated remote code execution, as exploited in… vulnerability
  • CVE-2021-27101 Accellion FTA 9_12_370 and earlier is affected by SQL injection via a crafted Host header in a request to document_root.html. vulnerability
  • CVE-2020-12271 A SQL injection issue was found in SFOS 17.0, 17.1, 17.5, and 18.0 before 2020-04-25 on Sophos XG Firewall devices, as exploited in the… vulnerability
  • CVE-2019-3792 Pivotal Concourse version 5.0.0, contains an API that is vulnerable to SQL injection. vulnerability
  • CVE-2017-11508 SecurityCenter versions 5.5.0, 5.5.1 and 5.5.2 contain a SQL Injection vulnerability that could be exploited by an authenticated user with… vulnerability
  • CVE-2008-5817 Multiple SQL injection vulnerabilities in index.php in Web Scribble Solutions webClassifieds 2005 allow remote attackers to execute… vulnerability
  • CVE-2008-2380 SQL injection vulnerability in authpgsqllib.c in Courier-Authlib before 0.62.0, when a non-Latin locale Postgres database is used, allows… vulnerability
  • CVE-2008-2790 SQL injection vulnerability in detail.php in MountainGrafix easyTrade 2.x allows remote attackers to execute arbitrary SQL commands via the… vulnerability
  • CVE-2008-2223 SQL injection vulnerability in group_posts.php in vShare YouTube Clone 2.6 allows remote attackers to execute arbitrary SQL commands via… vulnerability
  • CVE-2007-6602 SQL injection vulnerability in app/models/identity.php in NoseRub 0.5.2 and earlier allows remote attackers to execute arbitrary SQL… vulnerability
  • CVE-2004-0366 SQL injection vulnerability in the libpam-pgsql library before 0.5.2 allows attackers to execute arbitrary SQL statements. vulnerability
  • CVE-2003-0377 SQL injection vulnerability in the web-based administration interface for iisPROTECT 2.2-r4, and possibly earlier versions, allows remote… vulnerability

Child of · CWE (2)

  • CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness
  • CWE-943 Improper Neutralization of Special Elements in Data Query Logic weakness

Referenced by CAPEC · weakness (6)

  • CAPEC-108 Command Line Execution through SQL Injection attack pattern
  • CAPEC-109 Object Relational Mapping Injection attack pattern
  • CAPEC-110 SQL Injection through SOAP Parameter Tampering attack pattern
  • CAPEC-470 Expanding Control over the Operating System from the Database attack pattern
  • CAPEC-66 SQL Injection attack pattern
  • CAPEC-7 Blind SQL Injection attack pattern

Referenced by CVE · weakness (21,484)

  • CVE-2026-110184 The Newsmatic theme for WordPress is vulnerable to blind SQL Injection via the 'slug' parameter in all versions up to, and including, 1.5.0… vulnerability
  • CVE-2026-114358 This vulnerability exists in the Radius Xenia M2M Platform due to insufficient validation of user supplied input in the password recovery… vulnerability
  • CVE-2026-11587 SQL injection allowing an authenticated user with access to ACL management to read and modify the Centreon database vulnerability
  • CVE-2026-115964 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in StylemixThemes Motors… vulnerability
  • CVE-2026-115965 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in BuddyPress BuddyPress buddypress… vulnerability
  • CVE-2026-118192 The JoomSport – for Sports: Team & League, Football, Hockey & more plugin for WordPress is vulnerable to generic SQL Injection via the… vulnerability
  • CVE-2026-39736 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in Crocoblock JetEngine jet-engine… vulnerability
  • CVE-2026-49142 OpenEMR before 8.5.0 contains an authenticated SQL injection vulnerability in the Syndromic Surveillance module that allows users with… vulnerability
  • CVE-2026-61996 Subscriber SQL Injection in MLS On The Fly <= 1.8.1.5 versions. vulnerability
  • CVE-2026-89216 The vTables WordPress plugin before 0.3 does not properly sanitise and escape a parameter before using it in a SQL statement, which allows… vulnerability
  • CVE-2026-93855 The SendPress Newsletters plugin for WordPress is vulnerable to time-based SQL Injection via the 'subscriberid' parameter in all versions… vulnerability
  • CVE-2026-93904 The Social Web Suite – Social Media Auto Post, Social Media Auto Publish plugin for WordPress is vulnerable to generic SQL Injection via… vulnerability
  • CVE-2026-103792 Dell PowerProtect Data Domain Management Center, Feature Release versions 7.7.1.0 through 8.8, LTS2024 release versions 7.13.1.0 through… vulnerability
  • CVE-2026-104694 The Thrive Automator WordPress plugin before 11.2 does not properly sanitize and escape a parameter's array key before using it in a SQL… vulnerability
  • CVE-2026-111027 The Welcart e-Commerce WordPress plugin before 2.12.6 does not properly sanitise and escape a parameter before using it in a SQL query, and… vulnerability
  • CVE-2026-111411 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in Aman FunnelKit Automations… vulnerability
  • CVE-2026-111850 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in BuddyPress BuddyPress buddypress… vulnerability
  • CVE-2026-115224 The Customer Engagement System WordPress plugin before 2.0.2 does not safely build the SQL statements that store a popup's page and… vulnerability
  • CVE-2026-115281 The Recipe Card Blocks Lite WordPress plugin before 3.6.4 does not sanitize and cast a block and shortcode attribute before concatenating… vulnerability
  • CVE-2026-115603 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in Advanced Ads GmbH Advanced Ads –… vulnerability
  • CVE-2026-115607 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in Crowd Favorite DXP ToolKit… vulnerability
  • CVE-2026-116609 The WP Visitor Statistics (Real Time Traffic) plugin for WordPress is vulnerable to SQL Injection via the 'from' (and sibling… vulnerability
  • CVE-2026-116750 The VikRentCar Car Rental Management System plugin for WordPress is vulnerable to blind SQL Injection via the 'catid' parameter in all… vulnerability
  • CVE-2026-118378 Tabularis before 0.28.0 contains an SQL injection vulnerability in its SQLite driver that allows MCP clients to execute stacked statements… vulnerability
  • CVE-2026-14571 A Blind SQL Injection vulnerability in Futurum Software’s management software, caused by a lack of adequate validation and sanitisation of… vulnerability
  • CVE-2026-54455 OpenCATS is an open-source applicant tracking system and recruitment CRM for staffing agencies and hiring teams. vulnerability
  • CVE-2026-61569 AVideo is a video-sharing Platform. vulnerability
  • CVE-2026-76005 The WP Inventory Manager plugin for WordPress is vulnerable to time-based SQL Injection via 'sort_order' Shortcode Attribute in all… vulnerability
  • CVE-2026-86386 Dell PowerProtect Data Domain Management Center, Feature Release versions 7.7.1.0 through 8.8, LTS2024 release versions 7.13.1.0 through… vulnerability
  • CVE-2026-86401 Dell PowerProtect Data Domain Management Center, Feature Release versions 7.7.1.0 through 8.8, LTS2024 release versions 7.13.1.0 through… vulnerability
Show all 21,484 ›

Referenced by CWE · can precede (1)

  • CWE-456 Missing Initialization of a Variable weakness

Referenced by CWE · child of (1)

  • CWE-564 Use of Hibernate with HQL/SQL Query String Containing External Input weakness

Referenced by CWE · has member (11)

  • CWE-1200 Weaknesses in the 2019 CWE Top 25 Most Dangerous Software Errors view
  • CWE-1337 Weaknesses in the 2021 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1340 CISQ Data Protection Measures view
  • CWE-1350 Weaknesses in the 2020 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1387 Weaknesses in the 2022 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1425 Weaknesses in the 2023 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1430 Weaknesses in the 2024 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1435 Weaknesses in the 2025 CWE Top 25 Most Dangerous Software Weaknesses view
  • CWE-1468 Weaknesses Addressed by the OWASP Golang Secure Coding Practices Guide view
  • CWE-635 Weaknesses Originally Used by NVD from 2008 to 2016 view
  • CWE-884 CWE Cross-section view

Referenced by OWASP · mapped cwe (2)