Vulnerabilities in pkg:golang/github.com/v2fly/v2ray-core/v4

PACKAGE
Advisory Identifier: GHSA-4cxw-hq44-r344
Advisory Summary

CVE-2021-4070 is a CRITICAL (CVSS 9.1) off-by-one error vulnerability (CWE-193: Off-by-one Error) affecting Github.com/v2fly/v2ray core/v4 libraries in the Go ecosystem. The issue involves off-by-one error in v2fly/v2ray-core. Remediation is available by upgrading affected packages to version 4.44.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/v2fly/v2ray-core/v4

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/v2fly/v2ray-core/v4. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-4cxw-hq44-r344 CVE-2021-4070 CRITICAL Off-by-one Error in v2fly/v2ray-core

CVE-2021-4070 at a Glance

CVE Identifier CVE-2021-4070
GHSA Identifier GHSA-4cxw-hq44-r344
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-193: Off-by-one Error
Affected Product Github.com/v2fly/v2ray core/v4
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-4070

To remediate this vulnerability, upgrade all affected Github.com/v2fly/v2ray core/v4 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/v2fly/v2ray-core/v4 fixed: 4.44.0
Upgrade github.com/v2fly/v2ray-core/v4 to 4.44.0
github.com/v2fly/v2ray-core fixed: Latest secure release
Upgrade github.com/v2fly/v2ray-core to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/v2fly/v2ray-core/v4

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-4070, inspect your project dependencies for Github.com/v2fly/v2ray core/v4:

inspect dependencies for github.com/v2fly/v2ray-core/v4

Analyze the terminal output to locate any version of Github.com/v2fly/v2ray core/v4 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.44.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-193: Off-by-one Error, where a product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value. In Github.com/v2fly/v2ray core/v4, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

v2fly/v2ray-core prior to 4.44.0 is vulnerable to an off-by-one error. Indexing operations on arrays, slices, or strings should use an index at most one less than the length. If the index is checked for being less than or equal to the length (`<=`), instead of less than the length (`<`), the index could be out of bounds.

CVE-2021-4070 Affected Github.com/v2fly/v2ray core/v4 Versions

2 component(s)
Fixed Versions:
4.44.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/v2fly/v2ray-core/v4
Go
< 4.44.0
4.44.0
github.com/v2fly/v2ray-core
Go

References

Frequently Asked Questions

What is CVE-2021-4070?
CVE-2021-4070 is a security vulnerability in Github.com/v2fly/v2ray core/v4 involving Off-by-one Error in v2fly/v2ray-core under CWE-193: Off-by-one Error.
Which Github.com/v2fly/v2ray core/v4 versions are affected?
Affected versions include releases prior to 4.44.0 across affected packages: github.com/v2fly/v2ray-core/v4, github.com/v2fly/v2ray-core.
What version fixes CVE-2021-4070?
Upgrading to 4.44.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/v2fly/v2ray-core/v4 affected?
Yes, github.com/v2fly/v2ray-core/v4 is affected in releases prior to 4.44.0. Upgrade your dependency to 4.44.0 or later.
Is github.com/v2fly/v2ray-core affected?
Yes, github.com/v2fly/v2ray-core is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2021-4070?
CVE-2021-4070 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H.
What CWE is associated with CVE-2021-4070?
CVE-2021-4070 is classified under CWE-193: Off-by-one Error (A product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value.).
How can I check Go dependencies for CVE-2021-4070?
Run the dependency tree command: 'inspect dependencies for github.com/v2fly/v2ray-core/v4'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4cxw-hq44-r344",
  "modified" : "2022-03-03T19:17:50Z",
  "published" : "2022-02-24T00:00:52Z",
  "aliases" : [ "CVE-2021-4070" ],
  "summary" : "Off-by-one Error in v2fly/v2ray-core",
  "details" : "v2fly/v2ray-core prior to 4.44.0 is vulnerable to an off-by-one error. Indexing operations on arrays, slices, or strings should use an index at most one less than the length. If the index is checked for being less than or equal to the length (`<=`), instead of less than the length (`<`), the index could be out of bounds.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/v2fly/v2ray-core/v4"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.44.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/v2fly/v2ray-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 4.44.0"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-4070"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/v2fly/v2ray-core/commit/c1af2bfd7aa59a4482aa7f6ec4b9208c1d350b5c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/v2fly/v2ray-core"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/8da19456-4d89-41ef-9781-a41efd6a1877"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-193" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-02-24T20:44:31Z",
    "nvd_published_at" : "2022-02-23T20:15:00Z"
  }
}