---
title: "CWE-943: Improper Neutralization of Special Elements in Data Query Logic"
url: https://radicalnotion.ai/cwe/cwe-943
type: cwe
description: "The product generates a query intended to access or manipulate data in a data store such as a database, but it does not neutralize or incorrectly neutralizes special elements that can modify the intended logic of the query."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-943: Improper Neutralization of Special Elements in Data Query Logic

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 166
- **Of those, in CISA KEV:** 1
- **New in 2026:** 150
- **CWE catalog version:** 4.21

## Description

The product generates a query intended to access or manipulate data in a data store such as a database, but it does not neutralize or incorrectly neutralizes special elements that can modify the intended logic of the query.

While this weakness is most commonly associated with SQL injection, there are many other query languages that are also subject to injection attacks, including HTSQL, LDAP, DQL, XQuery, Xpath, and "NoSQL" languages.

## Alternate terms

- **NoSQL Injection, NoSQLi:** Injection of data query language into NoSQL databases such as Cassandra, ElasticSearch, MongoDB, Redis, and others

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity, Availability, Access Control | Bypass Protection Mechanism, Read Application Data, Modify Application Data, Varies by Context | - |

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

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.

Bad code:

```c#
...
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);
...
```

Informative code:

```
SELECT * FROM items WHERE owner = <userName> AND itemname = <itemName>;
```

Attack code:

```
name' OR 'a'='a
```

Attack code:

```
SELECT * FROM items WHERE owner = 'wiley' AND itemname = 'name' OR 'a'='a';
```

Attack code:

```
OR 'a'='a
```

Attack code:

```
SELECT * FROM items;
```

### Example 2

The code below constructs an LDAP query using user input address data:

Bad code:

```java
context = new InitialDirContext(env);
String searchFilter = "StreetAddress=" + address;
NamingEnumeration answer = context.search(searchBase, searchFilter, searchCtls);
```

Because the code fails to neutralize the address string used to construct the query, an attacker can supply an address that includes additional LDAP queries.

### Example 3

Consider the following simple XML document that stores authentication information and a snippet of Java code that uses XPath query to retrieve authentication information:

Informative code:

```xml
<users>
    <user>
        <login>john</login>
        <password>abracadabra</password>
        <home_dir>/home/john</home_dir>
    </user>
    <user>
        <login>cbc</login>
        <password>1mgr8</password>
        <home_dir>/home/cbc</home_dir>
    </user>
</users>
```

Bad code:

```java
XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression xlogin = xpath.compile("//users/user[login/text()='" + login.getUserName() + "' and password/text() = '" + login.getPassword() + "']/home_dir/text()");
Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File("db.xml"));
String homedir = xlogin.evaluate(d);
```

Attack code:

```
//users/user[login/text()='john' or ''='' and password/text() = '' or ''='']/home_dir/text()
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2024-50672 | NoSQL injection in product for building eLearning courses allows password resets using a query processed by the Mongoose find function |
| CVE-2021-20736 | NoSQL injection in team collaboration product |
| CVE-2020-35666 | NoSQL injection in a PaaS platform using a MongoDB operator |
| CVE-2014-2503 | Injection using Documentum Query Language (DQL) |
| CVE-2014-2508 | Injection using Documentum Query Language (DQL) |

## Real CVEs with this weakness (sample of 12 of 166)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-42884 | JNDI Injection vulnerability in SAP NetWeaver Enterprise Portal | medium | 6.5 | - | Yes | 2025-11-11 |
| CVE-2024-4872 | Improper Neutralization of Special Elements in Data Query Logic in Hitachi Energy FACTS Control Platform (FCP) | critical | 9.9 | - | No | 2024-08-27 |
| CVE-2022-36084 | cruddl vulnerable to AQL injection through flexSearch | critical | 9.9 | - | No | 2022-09-08 |
| CVE-2026-125120 | Mongoose: sanitizeFilter not applied on countDocuments | critical | 9.8 | - | No | 2026-11-09 |
| CVE-2026-8649 | Institution scope bypass vulnerability in custom reports | critical | 9.8 | - | No | 2026-07-08 |
| CVE-2026-40351 | FastGPT: NoSQL Injection in loginByPassword leads to Authentication Bypass | critical | 9.8 | - | No | 2026-04-17 |
| CVE-2026-120201 | Jpom 2.10.0 through 2.11.12 Authentication Bypass via JPOM-USER-TOKEN Header | critical | 9.3 | - | No | 2026-10-31 |
| CVE-2026-41274 | Flowise: Cypher Injection in GraphCypherQAChain | critical | 9.3 | - | No | 2026-04-23 |
| CVE-2026-32248 | Parse Server: Account takeover via operator injection in authentication data identifier | critical | 9.3 | - | No | 2026-03-12 |
| CVE-2026-29793 | NoSQL Injection via WebSocket id Parameter in MongoDB Adapter | critical | 9.3 | - | No | 2026-03-10 |
| CVE-2026-20284 | Cisco Identity Search Engine SXP REST API SQL Injection Vulnerability | critical | 9.1 | - | No | 2026-09-16 |
| CVE-2026-45689 | Rocket.Chat: Pre-Auth NoSQL Injection in OAuth2 Token Endpoint leading to Arbitrary User ATO | critical | 9.1 | - | No | 2026-06-24 |

## Related attack patterns (CAPEC)

- [CAPEC-676](https://radicalnotion.ai/capec/capec-676): NoSQL Injection

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-74](https://radicalnotion.ai/cwe/cwe-74) | Improper Neutralization of Special Elements in Output Used by a Downstream Component |
| Child | [CWE-89](https://radicalnotion.ai/cwe/cwe-89) | Improper Neutralization of Special Elements used in an SQL Command |
| Child | [CWE-90](https://radicalnotion.ai/cwe/cwe-90) | Improper Neutralization of Special Elements used in an LDAP Query |
| Child | [CWE-643](https://radicalnotion.ai/cwe/cwe-643) | Improper Neutralization of Data within XPath Expressions |
| Child | [CWE-652](https://radicalnotion.ai/cwe/cwe-652) | Improper Neutralization of Data within XQuery Expressions |

## Frequently asked questions

### What is CWE-943?

The product generates a query intended to access or manipulate data in a data store such as a database, but it does not neutralize or incorrectly neutralizes special elements that can modify the intended logic of the query.

### What CVEs are caused by CWE-943?

166 recorded CVEs are attributed to CWE-943, including CVE-2025-42884, CVE-2024-4872 and CVE-2022-36084. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How is CWE-943 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-943?

Exploiting CWE-943 can lead to: Bypass Protection Mechanism, Read Application Data, Modify Application Data, Varies by Context.

### Is CWE-943 actively exploited?

Yes. 1 CWE-943 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 166 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/943.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-943). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
