GHSA-fjx5-qpf4-xjf2: Borsh Parsing Borsh Messages With ZST Vulnerability

MODERATE
Published
Advisory Summary

GHSA-fjx5-qpf4-xjf2 is a MODERATE parsing borsh messages with zst vulnerability (General Security Weakness) affecting Borsh libraries in the crates.io ecosystem. The issue involves parsing borsh messages with zst which are not-copy/clone is unsound. Remediation is available by upgrading affected packages to version 1.0.0-alpha.1.

GHSA-fjx5-qpf4-xjf2 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-fjx5-qpf4-xjf2
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Borsh
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-fjx5-qpf4-xjf2

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

borsh fixed: 1.0.0-alpha.1
Upgrade borsh to 1.0.0-alpha.1
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 borsh

How to Check if You Are Affected

To determine whether your application is affected by GHSA-fjx5-qpf4-xjf2, inspect your project dependencies for Borsh:

inspect dependencies for borsh

Analyze the terminal output to locate any version of Borsh in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.0-alpha.1), 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 General Security Weakness. In Borsh, 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

Affected versions of borsh cause undefined behavior when zero-sized-types (ZST) are parsed and the Copy/Clone traits are not implemented/derived. For instance if 1000 instances of a ZST are deserialized, and the ZST is not copy (this can be achieved through a singleton), then accessing/writing to deserialized data will cause a segmentation fault. There is currently no way for borsh to read data without also providing a Rust type. Therefore, if you are not using ZST for serialization, then you are not affected by this issue.

GHSA-fjx5-qpf4-xjf2 Affected Borsh Versions

1 component(s)
Fixed Versions:
1.0.0-alpha.1
Product / Package Ecosystem Affected Versions Fixed Version
borsh
crates.io
< 1.0.0-alpha.1
1.0.0-alpha.1

References

Frequently Asked Questions

What is GHSA-fjx5-qpf4-xjf2?
GHSA-fjx5-qpf4-xjf2 is a security vulnerability in Borsh involving Parsing borsh messages with ZST which are not-copy/clone is unsound under General Security Weakness.
Which Borsh versions are affected?
Affected versions include releases prior to 1.0.0-alpha.1 across affected packages: borsh.
What version fixes GHSA-fjx5-qpf4-xjf2?
Upgrading to 1.0.0-alpha.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is borsh affected?
Yes, borsh is affected in releases prior to 1.0.0-alpha.1. Upgrade your dependency to 1.0.0-alpha.1 or later.
What CWE is associated with GHSA-fjx5-qpf4-xjf2?
GHSA-fjx5-qpf4-xjf2 is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-fjx5-qpf4-xjf2?
Run the dependency tree command: 'inspect dependencies for borsh'. 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-fjx5-qpf4-xjf2",
  "modified" : "2024-09-23T16:34:09Z",
  "published" : "2023-04-17T16:32:26Z",
  "aliases" : [ ],
  "summary" : "Parsing borsh messages with ZST which are not-copy/clone is unsound",
  "details" : "Affected versions of borsh cause undefined behavior when zero-sized-types (ZST) are parsed and the Copy/Clone traits are not implemented/derived. For instance if 1000 instances of a ZST are deserialized, and the ZST is not copy (this can be achieved through a singleton), then accessing/writing to deserialized data will cause a segmentation fault.\n\nThere is currently no way for borsh to read data without also providing a Rust type. Therefore, if you are not using ZST for serialization, then you are not affected by this issue. \n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "borsh"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.0-alpha.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.10.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/near/borsh-rs/issues/19"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/near/borsh-rs"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2023-0033.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-04-17T16:32:26Z",
    "nvd_published_at" : null
  }
}