Type Confusion Vulnerability in enum-map Package: Enum Trait Implementation Flaw

enum-map Updated 01 Aug 2026

Summary

21/07/2026
N/A
Yes i
Unrated
Not published

RUSTSEC-2026-0218: Enum trait allows type confusion when manually implemented. Affects enum-map versions >= 3.0.0-0.gat.0, < 3.1.0. Fixed in 3.1.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The enum-map package is a Rust library designed to facilitate the creation and manipulation of enumerated maps, allowing developers to associate values with enum variants efficiently. It leverages Rust's type system to ensure safety and performance. However, a flaw in the implementation of the Enum trait can lead to severe type confusion, compromising the integrity of the application using this library.

Vulnerability Detail

The vulnerability arises from the enum-map package's Enum trait, which did not enforce that the element type of the Array associated type must match the array's generic parameter V. This oversight allows developers to implement the Enum trait in a way that leads to type confusion, potentially resulting in memory corruption. For instance, a manual implementation could declare an Array<V> with elements that are not of type V, leading to unpredictable behavior and security risks.

How To Fix

Minimum fixed version

3.1.0

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid manually implementing the Enum trait in a way that does not adhere to the expected type constraints. Ensure that any custom implementations maintain type consistency with the generic parameter V. For example, do not implement the Enum trait like this:

struct IntentionallyWrong;

impl Enum for IntentionallyWrong {
    type Array<V> = [String; 4];

    fn from_usize(_: usize) -> Self {
        IntentionallyWrong
    }

    fn into_usize(self) -> usize {
        0
    }
}

Conclusion

The enum-map package contains a critical vulnerability related to the Enum trait implementation that can lead to type confusion and memory corruption. It is essential to update to version 3.1.0 or later to mitigate this risk. Additionally, developers should be cautious when implementing the Enum trait to ensure type safety.

See every vulnerability recorded for enum-map →

Share this vulnerability

FAQ

The enum-map package is a Rust library that allows developers to create maps indexed by enum variants, providing a type-safe way to associate values with enums.

The vulnerability is a type confusion issue in the Enum trait implementation, which can lead to memory corruption when the associated types do not match.

You can use Vulert, a tool that monitors and alerts for open-source vulnerabilities in real-time. Visit Vulert Scanner to check your application without any signup.

If exploited, this vulnerability can lead to unpredictable behavior, crashes, or even security breaches due to memory corruption.

Update your Cargo.toml file to specify version 3.1.0 or later and run 'cargo update' to apply the changes.

Related vulnerabilities

Recent vulnerabilities recorded for enum-map.

How To Fix

Minimum fixed version

3.1.0

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback