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

Description

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

Submission Date :

July 19, 2006, midnight

Modification Date :

2023-06-29 00:00:00+00:00

Organization :

MITRE
Extended Description

A duplicate key entry -- if the alist is designed properly -- could be used as a constant time replace function. However, duplicate key entries could be inserted by mistake. Because of this ambiguity, duplicate key entries in an association list are not recommended and should not be allowed.

Example Vulnerable Codes

Example - 1

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



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

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

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.

© cvefeed.io
Latest DB Update: Nov. 22, 2024 5:27