Vulnerabilities in pkg:golang/github.com/ipfs/go-bitfield

PACKAGE
Advisory Identifier: GHSA-2h6c-j3gf-xp9r
Advisory Summary

CVE-2023-23626 is a MODERATE (CVSS 5.9) denial of service vulnerability (CWE-1284: Improper Validation of Specified Quantity in Input) affecting Github.com/ipfs/go bitfield libraries in the Go ecosystem. The issue involves ipfs go-bitfield vulnerable to dos via malformed size arguments. Remediation is available by upgrading affected packages to version 1.1.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/ipfs/go-bitfield

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/ipfs/go-bitfield. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-2h6c-j3gf-xp9r CVE-2023-23626 MODERATE IPFS go-bitfield vulnerable to DoS via malformed size arguments

CVE-2023-23626 at a Glance

CVE Identifier CVE-2023-23626
GHSA Identifier GHSA-2h6c-j3gf-xp9r
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-1284: Improper Validation of Specified Quantity in Input
Affected Product Github.com/ipfs/go bitfield
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.9

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

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

How to Fix CVE-2023-23626

To remediate this vulnerability, upgrade all affected Github.com/ipfs/go bitfield 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/ipfs/go-bitfield fixed: 1.1.0
Upgrade github.com/ipfs/go-bitfield to 1.1.0
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/ipfs/go-bitfield

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-23626, inspect your project dependencies for Github.com/ipfs/go bitfield:

inspect dependencies for github.com/ipfs/go-bitfield

Analyze the terminal output to locate any version of Github.com/ipfs/go bitfield in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.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-1284: Improper Validation of Specified Quantity in Input, where the product receives input that is expected to specify a quantity (such as size or length), but it does not validate or incorrectly validates that the quantity has the required properties. In Github.com/ipfs/go bitfield, 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

### Impact When feeding untrusted user input into the size parameter of `NewBitfield` and `FromBytes` functions, an attacker can trigger `panic`s. This happen when the `size` is a not a multiple of `8` or is negative. There were already a note in the `NewBitfield` documentation: > ``` > Panics if size is not a multiple of 8. > ```` But it incomplete and missing from `FromBytes`'s documentation. This has been replaced by returning an `(Bitfield, error)` and returning a non nil error if the size is wrong. ### Patches - https://github.com/ipfs/go-bitfield/commit/5e1d256fe043fc4163343ccca83862c69c52e579 ### Workarounds - Ensure `size%8 == 0 && size >= 0` yourself before calling `NewBitfield` or `FromBytes` ### References - https://github.com/ipfs/go-unixfs/security/advisories/GHSA-q264-w97q-q778

CVE-2023-23626 Affected Github.com/ipfs/go bitfield Versions

1 component(s)
Fixed Versions:
1.1.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/ipfs/go-bitfield
Go
< 1.1.0
1.1.0

References

Frequently Asked Questions

What is CVE-2023-23626?
CVE-2023-23626 is a security vulnerability in Github.com/ipfs/go bitfield involving IPFS go-bitfield vulnerable to DoS via malformed size arguments under CWE-1284: Improper Validation of Specified Quantity in Input.
Which Github.com/ipfs/go bitfield versions are affected?
Affected versions include releases prior to 1.1.0 across affected packages: github.com/ipfs/go-bitfield.
What version fixes CVE-2023-23626?
Upgrading to 1.1.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/ipfs/go-bitfield affected?
Yes, github.com/ipfs/go-bitfield is affected in releases prior to 1.1.0. Upgrade your dependency to 1.1.0 or later.
What is the CVSS score of CVE-2023-23626?
CVE-2023-23626 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2023-23626?
CVE-2023-23626 is classified under CWE-1284: Improper Validation of Specified Quantity in Input (The product receives input that is expected to specify a quantity (such as size or length), but it does not validate or incorrectly validates that the quantity has the required properties.).
How can I check Go dependencies for CVE-2023-23626?
Run the dependency tree command: 'inspect dependencies for github.com/ipfs/go-bitfield'. 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-2h6c-j3gf-xp9r",
  "modified" : "2023-02-10T19:52:45Z",
  "published" : "2023-02-10T19:52:45Z",
  "aliases" : [ "CVE-2023-23626" ],
  "summary" : "IPFS go-bitfield vulnerable to DoS via malformed size arguments",
  "details" : "### Impact\nWhen feeding untrusted user input into the size parameter of `NewBitfield` and `FromBytes` functions, an attacker can trigger `panic`s.\n\nThis happen when the `size` is a not a multiple of `8` or is negative.\nThere were already a note in the `NewBitfield` documentation:\n> ```\n> Panics if size is not a multiple of 8.\n> ````\n\nBut it incomplete and missing from `FromBytes`'s documentation.\n\nThis has been replaced by returning an `(Bitfield, error)` and returning a non nil error if the size is wrong.\n\n### Patches\n- https://github.com/ipfs/go-bitfield/commit/5e1d256fe043fc4163343ccca83862c69c52e579\n\n### Workarounds\n- Ensure `size%8 == 0 && size >= 0` yourself before calling `NewBitfield` or `FromBytes`\n\n### References\n- https://github.com/ipfs/go-unixfs/security/advisories/GHSA-q264-w97q-q778\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/ipfs/go-bitfield"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/go-bitfield/security/advisories/GHSA-2h6c-j3gf-xp9r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-23626"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipfs/go-bitfield/commit/5e1d256fe043fc4163343ccca83862c69c52e579"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ipfs/go-bitfield"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2023-1558"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1284", "CWE-754" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-02-10T19:52:45Z",
    "nvd_published_at" : "2023-02-09T21:15:00Z"
  }
}