CVE-2021-4070: Off-by-one Error in v2fly/v2ray-core

Summary

24/02/2022
Yes i
Critical
9.1

CVE-2021-4070: Off-by-one Error in v2fly/v2ray-core. Affects github.com/v2fly/v2ray-core/v4 versions < 4.44.0. Fixed in 4.44.0. How to fix ↓

Also tracked for

The same CVE-2021-4070 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 Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

v2fly/v2ray-core is a Go package that provides a platform for building proxy servers. It is widely used for its robustness and flexibility in handling network traffic. However, prior to version 4.44.0, v2fly/v2ray-core is vulnerable to an off-by-one error. This vulnerability arises from incorrect indexing operations on arrays, slices, or strings, where an index equal to or greater than the length of the object is used. As a result, the index can be out of bounds, leading to potential memory corruption or information disclosure.

Vulnerability Detail

The off-by-one error in v2fly/v2ray-core can have severe consequences. By using an index that is equal to or greater than the length of an array, slice, or string, the code can access memory beyond the intended boundaries. This can result in various security issues, such as overwriting critical data, causing crashes, or leaking sensitive information. An attacker who can exploit this vulnerability may be able to execute arbitrary code, escalate privileges, or launch denial-of-service attacks.

How To Fix

Latest published version: v4.45.2 as of 23 Oct 2026

go get github.com/v2fly/v2ray-core/v4@v4.45.2

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

If you need the minimum change

4.44.0

This is the first release that contains the fix.

go get github.com/v2fly/v2ray-core/v4@v4.44.0

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

Workaround

As a workaround, developers can manually modify the affected code to ensure that indexing operations use an index that is strictly less than the length of the array, slice, or string. Here is an example of how the code can be modified:

def indexOutOfBounds(arr []int, index int) int {
  if index >= len(arr) {
    return -1 // or handle the error appropriately
  }
  return arr[index]
}

Conclusion

The off-by-one error in v2fly/v2ray-core prior to version 4.44.0 poses a critical security risk. It can lead to memory corruption, crashes, or information disclosure, potentially allowing attackers to execute arbitrary code or launch denial-of-service attacks. To mitigate this vulnerability, it is essential to update to v2fly/v2ray-core version 4.44.0 or later. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for github.com/v2fly/v2ray-core/v4 →

Share this vulnerability

FAQ

An off-by-one error is a programming mistake where an index or counter is incremented or decremented incorrectly by one, leading to unexpected behavior or vulnerabilities. In this case, the vulnerability arises from using an index equal to or greater than the length of an array, slice, or string.

The consequences of this vulnerability can be severe. It can result in memory corruption, crashes, or information disclosure. An attacker who can exploit this vulnerability may be able to execute arbitrary code, escalate privileges, or launch denial-of-service attacks.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using only the Gopkg.lock file without requiring access to the code or installation.

Yes, developers can manually modify the affected code to ensure that indexing operations use an index that is strictly less than the length of the array, slice, or string. However, it is strongly recommended to update to v2fly/v2ray-core version 4.44.0 or later to apply the official fix.

Yes, the CVSS score for this vulnerability is 9.1, indicating a critical severity level. It is crucial to address this vulnerability promptly to mitigate potential risks.

How To Fix

Latest published version: v4.45.2 as of 23 Oct 2026

go get github.com/v2fly/v2ray-core/v4@v4.45.2

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

If you need the minimum change

4.44.0

This is the first release that contains the fix.

go get github.com/v2fly/v2ray-core/v4@v4.44.0

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