GHSA-h6xm-c6r4-vmwf: Spl token swap Unsound Usages Of `u8` Type Vulnerability

MODERATE
Published
Advisory Summary

GHSA-h6xm-c6r4-vmwf is a MODERATE unsound usages of `u8` type vulnerability (General Security Weakness) affecting Spl token swap libraries in the crates.io ecosystem. The issue involves unsound usages of `u8` type casting in spl-token-swap. Remediation is available in the latest vendor maintenance releases.

GHSA-h6xm-c6r4-vmwf at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-h6xm-c6r4-vmwf
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Spl token swap
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-h6xm-c6r4-vmwf

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

spl-token-swap fixed: Latest secure release
Upgrade spl-token-swap 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 spl-token-swap

How to Check if You Are Affected

To determine whether your application is affected by GHSA-h6xm-c6r4-vmwf, inspect your project dependencies for Spl token swap:

inspect dependencies for spl-token-swap

Analyze the terminal output to locate any version of Spl token swap in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), 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 Spl token swap, 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

The library provides a safe public API `unpack` to cast `u8` array to arbitrary types, which can cause to undefined behaviors. The length check of array can only prevent out-of-bound access on the return type. However, it can't prevent misaligned pointer when casting `u8` pointer to a type aligned to larger bytes. For example, if we assign `u16` to `T`, **misaligned raw pointer dereference** could happen and cause to panic. Even if we pass the type aligned to same byte as `u8` (e.g., `bool`), it could construct a illegal type since `bool` can only have 0 or 1 as bit patterns, which is also an undefined behavior. The further exploits of the bug here are still not clear, so we would report this issue as unsound. The details of PoC to reproduce undefined behavior are provided in the [issue](https://github.com/solana-labs/solana-program-library/issues/5243).

GHSA-h6xm-c6r4-vmwf Affected Spl token swap Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
spl-token-swap
crates.io
≤ 3.0.0

References

Frequently Asked Questions

What is GHSA-h6xm-c6r4-vmwf?
GHSA-h6xm-c6r4-vmwf is a security vulnerability in Spl token swap involving Unsound usages of `u8` type casting in spl-token-swap under General Security Weakness.
Which Spl token swap versions are affected?
Affected versions include releases prior to current release patches across affected packages: spl-token-swap.
What version fixes GHSA-h6xm-c6r4-vmwf?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is spl-token-swap affected?
Yes, spl-token-swap is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with GHSA-h6xm-c6r4-vmwf?
GHSA-h6xm-c6r4-vmwf is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-h6xm-c6r4-vmwf?
Run the dependency tree command: 'inspect dependencies for spl-token-swap'. 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-h6xm-c6r4-vmwf",
  "modified" : "2024-12-23T19:29:44Z",
  "published" : "2024-12-23T19:29:44Z",
  "aliases" : [ ],
  "summary" : "Unsound usages of `u8` type casting in spl-token-swap",
  "details" : "The library provides a safe public API `unpack` to cast `u8` array to arbitrary types, which can cause to undefined behaviors. The length check of array can only prevent out-of-bound access on the return type. However, it can't prevent misaligned pointer when casting `u8` pointer to a type aligned to larger bytes. For example, if we assign `u16` to `T`, **misaligned raw pointer dereference** could happen and cause to panic. Even if we pass the type aligned to same byte as `u8` (e.g., `bool`), it could construct a illegal type since `bool` can only have 0 or 1 as bit patterns, which is also an undefined behavior. The further exploits of the bug here are still not clear, so we would report this issue as unsound.  \n\nThe details of PoC to reproduce undefined behavior are provided in the [issue](https://github.com/solana-labs/solana-program-library/issues/5243).  \n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "spl-token-swap"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/solana-labs/solana-program-library/issues/5243"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/solana-labs/solana-program-library"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0426.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-23T19:29:44Z",
    "nvd_published_at" : null
  }
}