CVE-2022-36078

CVE-2022-36078 is a high-severity uncontrolled resource consumption vulnerability in github.com/gagliardetto/binary (go), affecting versions < 0.7.1. It is fixed in 0.7.1.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

Binary vulnerable to Slice Memory Allocation with Excessive Size Value

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?

A workaround is not to rely on the dec.Decode(&val) function to parse the data, but to use a custom UnmarshalWithDecoder() method that reads and checks the length of any slice.

References

Are there any links users can visit to find out more?

For more information

If you have any questions or comments about this advisory:

Impact

What kind of vulnerability is it? Who is impacted?

The vulnerability is a memory allocation vulnerability that can be exploited to allocate slices in memory with (arbitrary) excessive size value, which can either exhaust available memory or crash the whole program.

When using github.com/gagliardetto/binary to parse unchecked (or wrong type of) data from untrusted sources of input (e.g. the blockchain) into slices, it's possible to allocate memory with excessive size.

When dec.Decode(&val) method is used to parse data into a structure that is or contains slices of values, the length of the slice was previously read directly from the data itself without any checks on the size of it, and then a slice was allocated. This could lead to an overflow and an allocation of memory with excessive size value.

Example:

package main

import (
	"github.com/gagliardetto/binary" // any version before v0.7.1 is vulnerable
	"log"
)

type MyStruct struct {
	Field1 []byte // field is a slice (could be a slice of any type)
}

func main() {
	// Let's assume that the data is coming from the blockchain:
	data := []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}
	
	var val MyStruct
	// - To determine the size of the val.Field1 slice, the decoder will read the length
	//   of the slice from the data itself without any checks on the size of it.
	//
	// - This could lead to an allocation of memory with excessive size value.
	//   Which means: []byte{0x01, 0x02, 0x03, 0x04} will be read as the length
	//   of the slice (= 67305985) and then an allocation of memory with 67305985 bytes will be made.
	//
	dec := binary.NewBorshDecoder(data)
	err := dec.Decode(&val)  // or binary.UnmarshalBorsh(&val, data) or binary.UnmarshalBin(&val, data) etc.
	if err != nil {
		log.Fatal(err)
	}
}

Crafted input forces the application to consume excessive CPU, memory, or other resources, degrading or denying service. Typical impact: denial of service.

CVE-2022-36078 has a CVSS score of 8.8 (High). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.7.1); upgrading removes the vulnerable code path.

Affected versions

github.com/gagliardetto/binary (< 0.7.1)

Security releases

github.com/gagliardetto/binary → 0.7.1 (go)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Has the problem been patched? What versions should users upgrade to?

The vulnerability has been patched in github.com/gagliardetto/binary v0.7.1

Users should upgrade to v0.7.1 or higher.

To upgrade to v0.7.1 or higher, run:

go get github.com/gagliardetto/[email protected]

# or

go get github.com/gagliardetto/binary@latest

Frequently Asked Questions

  1. What is CVE-2022-36078? CVE-2022-36078 is a high-severity uncontrolled resource consumption vulnerability in github.com/gagliardetto/binary (go), affecting versions < 0.7.1. It is fixed in 0.7.1. Crafted input forces the application to consume excessive CPU, memory, or other resources, degrading or denying service.
  2. How severe is CVE-2022-36078? CVE-2022-36078 has a CVSS score of 8.8 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of github.com/gagliardetto/binary are affected by CVE-2022-36078? github.com/gagliardetto/binary (go) versions < 0.7.1 is affected.
  4. Is there a fix for CVE-2022-36078? Yes. CVE-2022-36078 is fixed in 0.7.1. Upgrade to this version or later.
  5. Is CVE-2022-36078 exploitable, and should I be worried? Whether CVE-2022-36078 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2022-36078 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2022-36078? Upgrade github.com/gagliardetto/binary to 0.7.1 or later.

Stop the waste.
Protect your environment with Kodem.