CWE-462: Duplicate Key in Associative List (Alist)
Duplicate keys in associative lists can lead to non-unique keys being mistaken for an error.
Last updated
Overview
CWE-462 (Duplicate Key in Associative List (Alist)) is a variant-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Background
For some kinds of association lists, a duplicate key entry is a valid operation that replaces the original key in constant time.
Real-world CVEs
1 recorded CVE is caused by CWE-462 (Duplicate Key in Associative List (Alist)). None so far in 2026 (1 in 2025).
Common consequences
What can happen when CWE-462 is exploited.
Quality Degradation, Varies by Context
Affects: Other
If an alist contains duplicate key entries, this introduces an ambiguity in which it cannot be predicted which key value will be selected.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-462, grouped by where in the lifecycle they apply.
Use a hash table instead of an alist.
Use an alist which checks the uniqueness of hash keys with each entry before inserting the entry.
Duplicate key entries in an association list are not recommended and should not be allowed.
How to detect it
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.)
Code examples
MITRE examples of the weakness in code.
The following code adds data to a list and then attempts to sort the data.
Vulnerable example
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.
Terminology & mappings
Mapped taxonomies
- 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
Common questions about CWE-462.
- 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.
Sources
References
- MITRE CWE definition (CWE-462) (opens in a new tab)
- CWE-462 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.21). CVE associations are aggregated and kept current by RadicalNotion.AI.
Track CWE-462 CVEs
Get an alert when a new CWE-462 CVE affects your products, with AI-written analysis and remediation steps.