---
title: "CWE-241: Improper Handling of Unexpected Data Type"
url: https://radicalnotion.ai/cwe/cwe-241
type: cwe
description: "The product does not handle or incorrectly handles when a particular element is not the expected type, e.g. it expects a digit (0-9) but is provided with a letter (A-Z)."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-241: Improper Handling of Unexpected Data Type

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 39
- **Of those, in CISA KEV:** 0
- **New in 2026:** 5
- **CWE catalog version:** 4.21

## Description

The product does not handle or incorrectly handles when a particular element is not the expected type, e.g. it expects a digit (0-9) but is provided with a letter (A-Z).

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Other | Varies by Context, Unexpected State | - |

## Potential mitigations

### Implementation (Input Validation)

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.

### Implementation (Input Validation)

Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-1999-1156 | FTP server crash via PORT command with non-numeric character. |
| CVE-2004-0270 | Anti-virus product has an assertion error when the line length is non-numeric. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-137513 | justhtml before 3.17.0 Denial of Service via Unicode Digit Numeric Entity | high | 8.7 | - | No | 2026-11-26 |
| CVE-2021-40116 | Multiple Cisco Products Snort Rule Denial of Service Vulnerability | high | 8.6 | - | No | 2021-10-27 |
| CVE-2024-58239 | tls: stop recv() if initial process\_rx\_list gave us non-DATA | high | 8.2 | - | No | 2025-08-22 |
| CVE-2022-29181 | Improper Handling of Unexpected Data Type in Nokogiri | high | 8.2 | - | No | 2022-05-20 |
| CVE-2022-39064 | - | high | 8.1 | - | No | 2022-10-14 |
| CVE-2025-37998 | openvswitch: Fix unsafe attribute parsing in output\_userspace() | high | 7.8 | - | No | 2025-05-29 |
| CVE-2025-21778 | tracing: Do not allow mmap() of persistent ring buffer | high | 7.8 | - | No | 2025-02-27 |
| CVE-2026-14916 | Kong API Gateway Enterprise: JWT Algorithm-Confusion | high | 7.7 | - | No | 2026-09-16 |
| CVE-2026-73785 | HPE IceWall Federation Agent and Proxy, Denial of Service vulnerability | high | 7.5 | - | No | 2026-09-11 |
| CVE-2025-63548 | - | high | 7.5 | - | No | 2026-05-01 |
| CVE-2024-25966 | - | high | 7.5 | - | No | 2024-05-14 |
| CVE-2023-30591 | NodeBB Pre-Authentication Denial-of-Service | high | 7.5 | - | No | 2023-09-29 |

## Related attack patterns (CAPEC)

- [CAPEC-48](https://radicalnotion.ai/capec/capec-48): Passing Local Filenames to Functions That Expect a URL

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-228](https://radicalnotion.ai/cwe/cwe-228) | Improper Handling of Syntactically Invalid Structure |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Wrong Data Type | - | - |
| CERT C Secure Coding | Do not assume that fgets() or fgetws() returns a nonempty string when successful | FIO37-C | CWE More Abstract |

## Frequently asked questions

### What is CWE-241?

The product does not handle or incorrectly handles when a particular element is not the expected type, e.g. it expects a digit (0-9) but is provided with a letter (A-Z).

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

39 recorded CVEs are attributed to CWE-241, including CVE-2026-137513, CVE-2021-40116 and CVE-2024-58239.

### How do you prevent CWE-241?

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.

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

Exploiting CWE-241 can lead to: Varies by Context, Unexpected State.

### Is CWE-241 actively exploited?

39 recorded CVEs are caused by CWE-241; none are currently in CISA's KEV catalog of actively exploited flaws.

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

---

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