---
title: "CWE-462: Duplicate Key in Associative List (Alist)"
url: https://radicalnotion.ai/cwe/cwe-462
type: cwe
description: "Duplicate keys in associative lists can lead to non-unique keys being mistaken for an error."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-462: Duplicate Key in Associative List (Alist)

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** Low
- **CVEs with this as primary weakness:** 1
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

Duplicate keys in associative lists can lead to non-unique keys being mistaken for an error.

## Background

For some kinds of association lists, a duplicate key entry is a valid operation that replaces the original key in constant time.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | Duplicate key entries could be inserted by mistake, introducing an ambiguity. |

## Applicable platforms

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Quality Degradation, Varies by Context | If an alist contains duplicate key entries, this introduces an ambiguity in which it cannot be predicted which key value will be selected. |

## Potential mitigations

### Implementation

Use a hash table instead of an alist.

### Implementation

Use an alist which checks the uniqueness of hash keys with each entry before inserting the entry.

### Implementation

Duplicate key entries in an association list are not recommended and should not be allowed.

## 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.)

## Demonstrative examples

### Example 1

The following code adds data to a list and then attempts to sort the data.

Bad code:

```python
alist = []
while (foo()): #now assume there is a string data with a key basename
    queue.append(basename,data)
    queue.sort()
```

Since basename is not necessarily unique, this may not sort how one would like it to be.

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-21085 | PingFederate OAuth Grant attribute duplication may use excessive memory | low | 2.1 | - | No | 2025-06-15 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-694](https://radicalnotion.ai/cwe/cwe-694) | Use of Multiple Resources with Duplicate Identifier |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Duplicate key in associative list (alist) | - | - |
| CERT C Secure Coding | Beware of multiple environment variables with the same effective name | ENV02-C | - |

## Frequently asked questions

### What is CWE-462?

Duplicate keys in associative lists can lead to non-unique keys being mistaken for an error.

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

1 recorded CVE is attributed to CWE-462: CVE-2025-21085.

### How do you prevent CWE-462?

Use a hash table instead of an alist.

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

Exploiting CWE-462 can lead to: Quality Degradation, Varies by Context.

### Is CWE-462 actively exploited?

1 recorded CVE is caused by CWE-462; it is not currently in CISA's KEV catalog of actively exploited flaws.

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

---

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