Integer Overflow and Buffer Overflow in GMP: CVE-2021-43618

gmp Updated 02 Oct 2025

Summary

15/11/2021
N/A
Yes i
High
7.5

ALPINE-CVE-2021-43618: GNU Multiple Precision Arithmetic Library (GMP) through 6.2.1 has an mpz/inp_raw.c integer overflow and resultant buffer overflow via crafted input, leading to a segmentation fault on 32-bit platforms. Affects gmp versions < 6.2.1-r1. Fixed in 6.2.1-r1. 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 GNU Multiple Precision Arithmetic Library (GMP) is a widely used library for arbitrary-precision arithmetic, supporting integers, rational numbers, and floating-point numbers. It is known for its performance and efficiency in handling large numbers, making it essential for applications in cryptography, numerical analysis, and computational mathematics. However, a vulnerability has been identified in versions up to 6.2.1 that could lead to severe security issues.

Vulnerability Detail

The vulnerability arises from an integer overflow in the mpz/inp_raw.c file of GMP, which can be exploited through crafted input. This flaw can lead to a buffer overflow, resulting in a segmentation fault, particularly on 32-bit platforms. The implications of this vulnerability are significant, as it could allow an attacker to execute arbitrary code or crash the application, compromising the integrity and availability of the system.

How To Fix

Minimum fixed version

6.2.1-r1

This is the first release that contains the fix.

sudo apk add --upgrade gmp

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

Workaround

As a temporary measure, you can avoid using the vulnerable functionality of the GMP library until you can apply the patch. However, this is not a long-term solution and updating to the patched version is strongly recommended.

Conclusion

The CVE-2021-43618 vulnerability in the GMP library poses a significant risk due to its potential for exploitation through integer and buffer overflows. It is crucial to update to the patched version 6.2.1-r1 to mitigate these risks and ensure the security of applications relying on this library.

See every vulnerability recorded for gmp →

Share this vulnerability

FAQ

CVE-2021-43618 is a vulnerability in the GNU Multiple Precision Arithmetic Library (GMP) that can lead to an integer overflow and buffer overflow, potentially allowing for arbitrary code execution.

If your application uses GMP versions prior to 6.2.1-r1, it may be susceptible to crashes or exploitation through crafted inputs, leading to security breaches.

If an immediate update is not possible, refrain from using the vulnerable features of the GMP library as a temporary workaround until you can apply the patch.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. Simply upload your manifest file like package-lock.json to check for vulnerabilities.

The CVSS score for CVE-2021-43618 is 7.5, indicating a high severity level that requires prompt attention.

Related vulnerabilities

Recent vulnerabilities recorded for gmp.

How To Fix

Minimum fixed version

6.2.1-r1

This is the first release that contains the fix.

sudo apk add --upgrade gmp

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