CVE-2022-23772: Uncontrolled memory consumption in math/big

stdlib Updated 02 Oct 2025

Summary

23/05/2022
Yes i
Unrated
Not published

CVE-2022-23772: Uncontrolled memory consumption in math/big. Affects stdlib across 2 version ranges.

< 1.16.14 >= 1.17.0-0, < 1.17.7

Fixed in 1.16.14 or 1.17.7, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-23772 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

The 'math/big' package in the Go standard library provides arbitrary-precision arithmetic operations on integers and floating-point numbers. It is commonly used for handling large numbers and performing precise calculations. However, a vulnerability has been discovered in the 'Rat.SetString' function of the 'math/big' package, which can lead to uncontrolled memory consumption.

Vulnerability Detail

The 'Rat.SetString' function in the 'math/big' package has an overflow issue that can be exploited to consume excessive amounts of memory. This vulnerability can be triggered by passing a specially crafted string as input to the function. An attacker could potentially abuse this vulnerability to cause a denial-of-service (DoS) condition by exhausting system resources. The issue was identified by Emmanuel Odeke.

How To Fix

Latest published version: go1.25.5 as of 22 Oct 2026

go get stdlib@vgo1.25.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.16.14 1.16.14
    go get stdlib@v1.16.14
  • >= 1.17.0-0, < 1.17.7 1.17.7
    go get stdlib@v1.17.7

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a temporary workaround, developers can validate and sanitize user input before passing it to the 'Rat.SetString' function. By implementing proper input validation, the risk of triggering the vulnerability can be mitigated. Here is an example of how to sanitize the input:

import (
	"math/big"
	"strconv"
)

func sanitizeInput(input string) (*big.Rat, error) {
	_, err := strconv.ParseFloat(input, 64)
	if err != nil {
		return nil, err
	}

	r := new(big.Rat)
	r.SetFloat64(input)

	return r, nil
}

Conclusion

The 'math/big' package in Go is vulnerable to uncontrolled memory consumption due to an overflow issue in the 'Rat.SetString' function. This vulnerability can be mitigated by updating to the patched versions of Go (1.16.14 or 1.17.7) and implementing proper input validation. It is important to stay informed about vulnerabilities and regularly update dependencies to ensure the security of your applications. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

This vulnerability can lead to uncontrolled memory consumption, potentially causing a denial-of-service (DoS) condition by exhausting system resources.

Versions 0.0.0 to 1.16.13 and versions 1.17.0 to 1.17.6 of Go are affected by this vulnerability.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your Gopkg.lock file and the tool will analyze it for any open-source vulnerabilities, including this one.

At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is important to apply the recommended fixes to prevent any potential exploitation.

You can find more information about this vulnerability in the Go vulnerability database at https://pkg.go.dev/vuln/GO-2021-0317.

Related vulnerabilities

Recent vulnerabilities recorded for stdlib.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Latest published version: go1.25.5 as of 22 Oct 2026

go get stdlib@vgo1.25.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.16.14 1.16.14
    go get stdlib@v1.16.14
  • >= 1.17.0-0, < 1.17.7 1.17.7
    go get stdlib@v1.17.7

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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