---
title: "CWE-242: Use of Inherently Dangerous Function"
url: https://radicalnotion.ai/cwe/cwe-242
type: cwe
description: "The product calls a function that can never be guaranteed to work safely, regardless of how it is used."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-242: Use of Inherently Dangerous Function

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 11
- **Of those, in CISA KEV:** 0
- **New in 2026:** 2
- **CWE catalog version:** 4.21

## Description

The product calls a function that can never be guaranteed to work safely, regardless of how it is used.

## Modes of introduction

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

## Applicable platforms

**Languages:** C (Undetermined), C++ (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Varies by Context | The consequences vary depending on the behavior of the affected function. |
| Other | Modify Memory | Some functions can be subject to buffer overflows. For example, an attacker can easily send arbitrarily-sized input to gets() and overflow the destination buffer. In C++, an attacker can easily send arbitrarily-sized input to the \>\> operator and overflow the destination buffer. |

## Potential mitigations

### Build and Compilation, Implementation

Identify a list of prohibited API functions and prohibit developers from using these functions, providing safer alternatives. In some cases, automatic code analysis tools or the compiler can be instructed to spot use of prohibited functions, such as the "banned.h" include file from Microsoft's SDL. \[REF-554\] \[REF-1009\] \[REF-7\]

### Testing

Use grep or static analysis tools to spot usage of dangerous functions.

## 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 code below calls gets() to read information into a buffer.

Bad code:

```c
char buf[BUFSIZE];
gets(buf);
```

The gets() function in C is inherently unsafe.

### Example 2

The code below calls the gets() function to read in data from the command line.

Bad code:

```c
    char buf[24];
    printf("Please enter your name and press <Enter>\n");
    gets(buf);
    ...
}
```

However, gets() is inherently unsafe, because it copies all input from STDIN to the buffer without checking size. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2007-4004 | FTP client uses inherently insecure gets() function and is setuid root on some systems, allowing buffer overflow |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2017-1002157 | modulemd uses an unsafe function for processing externally provided data | critical | 9.3 | - | No | 2019-01-10 |
| CVE-2024-52324 | Ruijie Reyee OS Use of Inherently Dangerous Function | critical | 9.2 | - | No | 2024-12-06 |
| CVE-2026-6477 | PostgreSQL libpq lo\_\* functions let server superuser overwrite client stack memory | high | 8.8 | - | No | 2026-05-14 |
| CVE-2025-49215 | Trend Micro Endpoint Encryption GetGroupFilteredUsers SQL Injection Privilege Escalation Vulnerability | high | 8.8 | - | No | 2025-06-17 |
| CVE-2022-36310 | - | high | 8.8 | - | No | 2022-08-16 |
| CVE-2017-0904 | private\_address\_check vulnerable to bypass of Resolv.getaddresses method | high | 8.1 | - | No | 2017-11-13 |
| CVE-2025-1994 | IBM Cognos Command Center code execution | high | 7.8 | - | No | 2025-08-26 |
| CVE-2025-1331 | IBM CICS TX code execution | high | 7.8 | - | No | 2025-05-08 |
| CVE-2021-42543 | AzeoTech DAQFactory | high | 7.8 | - | No | 2021-11-05 |
| CVE-2021-40698 | ColdFusion Use of Inherently Dangerous Function Leads To Security feature bypass | high | 7.4 | - | No | 2023-09-07 |
| CVE-2026-11980 | Code execution in IBM Desktop App | high | 7.3 | - | No | 2026-07-30 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-1177](https://radicalnotion.ai/cwe/cwe-1177) | Use of Prohibited Code |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Dangerous Functions | - | - |
| CERT C Secure Coding | Do not use vfork() | POS33-C | CWE More Abstract |
| Software Fault Patterns | Use of an improper API | SFP3 | - |

## Frequently asked questions

### What is CWE-242?

The product calls a function that can never be guaranteed to work safely, regardless of how it is used.

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

11 recorded CVEs are attributed to CWE-242, including CVE-2017-1002157, CVE-2024-52324 and CVE-2026-6477.

### How do you prevent CWE-242?

Identify a list of prohibited API functions and prohibit developers from using these functions, providing safer alternatives. In some cases, automatic code analysis tools or the compiler can be instructed to spot use of prohibited functions, such as the "banned.h" include file from Microsoft's SDL.

### How is CWE-242 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-242?

Exploiting CWE-242 can lead to: Varies by Context, Modify Memory.

### Is CWE-242 actively exploited?

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

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

---

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