GHSA-9v25-r5q2-2p6w: Mpl candy machine Candy Machine Set Collection During Vulnerability

MODERATE
Published
Advisory Summary

GHSA-9v25-r5q2-2p6w is a MODERATE candy machine set collection during vulnerability (General Security Weakness) affecting Mpl candy machine libraries in the crates.io ecosystem. The issue involves candy machine set collection during mint missing check. Remediation is available by upgrading affected packages to version 4.5.1.

GHSA-9v25-r5q2-2p6w at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-9v25-r5q2-2p6w
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Mpl candy machine
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-9v25-r5q2-2p6w

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

mpl-candy-machine fixed: 4.5.1
Upgrade mpl-candy-machine to 4.5.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 mpl-candy-machine

How to Check if You Are Affected

To determine whether your application is affected by GHSA-9v25-r5q2-2p6w, inspect your project dependencies for Mpl candy machine:

inspect dependencies for mpl-candy-machine

Analyze the terminal output to locate any version of Mpl candy machine in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.5.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 Mpl candy machine, 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

A problem with Candy Machine V2 allow minting NFTs to an arbitrary collection due to a missing check. Here is a description of the exploit: Details: Here is the tx/ix to exploit: Transaction: Ix 1: candy_machine v2, mint_nft, passing in empty metadata -1 Ix 2: custom handler, 0 cpi A --> token_metadata create_metadata_account, creates NFT cpi B --> candy_machine v2, set_collection_during_mint Ix 1 passes our first check for empty metadata, but eventually will hit a bot tax and return Ok. We do have a CPI check in this function but even if we hit that or moved it to the top, it returns Ok as a bot tax and still enables the issue. Ix 2, cpi A is Ok and mints an arbitrary NFT. Ix 2, cpi B checks the previous instruction using index_relative_to_current-1. This turns out to be Ix 1 which was Ok, so then your newly minted arbitrary NFT is successfully added to the collection. Conclusion: Candy machine could be out of NFTs and it still works. If the CM is closed, (we think?) it doesn't get to the check. The fix needs to be in set_collection_during_mint that current program ID id candy_machine_v2. It checks previous program ID but doesn't check current. NOTE: THIS DOES NOT AFFECT Cmv3

GHSA-9v25-r5q2-2p6w Affected Mpl candy machine Versions

1 component(s)
Fixed Versions:
4.5.1
Product / Package Ecosystem Affected Versions Fixed Version
mpl-candy-machine
crates.io
≥ 4.5.0
< 4.5.1
All 1 versions
4.5.0
4.5.1

References

Frequently Asked Questions

What is GHSA-9v25-r5q2-2p6w?
GHSA-9v25-r5q2-2p6w is a security vulnerability in Mpl candy machine involving Candy Machine Set Collection During Mint Missing Check under General Security Weakness.
Which Mpl candy machine versions are affected?
Affected versions include releases prior to 4.5.1 across affected packages: mpl-candy-machine.
What version fixes GHSA-9v25-r5q2-2p6w?
Upgrading to 4.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mpl-candy-machine affected?
Yes, mpl-candy-machine is affected in releases prior to 4.5.1. Upgrade your dependency to 4.5.1 or later.
What CWE is associated with GHSA-9v25-r5q2-2p6w?
GHSA-9v25-r5q2-2p6w is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-9v25-r5q2-2p6w?
Run the dependency tree command: 'inspect dependencies for mpl-candy-machine'. 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-9v25-r5q2-2p6w",
  "modified" : "2022-12-12T22:03:19Z",
  "published" : "2022-12-12T22:03:19Z",
  "aliases" : [ ],
  "summary" : "Candy Machine Set Collection During Mint Missing Check",
  "details" : "A problem with Candy Machine V2 allow minting NFTs to an arbitrary collection due to a missing check.\n\nHere is a description of the exploit:\nDetails:\nHere is the tx/ix to exploit:\nTransaction:\nIx 1: candy_machine v2, mint_nft, passing in empty metadata -1\nIx 2: custom handler, 0\n\t\tcpi A --> token_metadata create_metadata_account, creates NFT\n\t\tcpi B --> candy_machine v2, set_collection_during_mint\nIx 1 passes our first check for empty metadata, but eventually will hit a bot tax and return Ok.  We do have a CPI check in this function but even if we hit that or moved it to the top, it returns Ok as a bot tax and still enables the issue.\nIx 2, cpi A is Ok and mints an arbitrary NFT.\nIx 2, cpi B checks the previous instruction using index_relative_to_current-1.  This turns out to be Ix 1 which was Ok, so then your newly minted arbitrary NFT is successfully added to the collection.\nConclusion:\nCandy machine could be out of NFTs and it still works.  If the CM is closed, (we think?) it doesn't get to the check.\nThe fix needs to be in set_collection_during_mint that current program ID id candy_machine_v2.  It checks previous program ID but doesn't check current.\n\nNOTE: THIS DOES NOT AFFECT Cmv3\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "mpl-candy-machine"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.5.0"
      }, {
        "fixed" : "4.5.1"
      } ]
    } ],
    "versions" : [ "4.5.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/metaplex-foundation/metaplex-program-library/security/advisories/GHSA-9v25-r5q2-2p6w"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/metaplex-foundation/metaplex-program-library/commit/e6b3aff603ac06236bf77c2ec21ead93c6836dce"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/metaplex-foundation/metaplex-program-library"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-12-12T22:03:19Z",
    "nvd_published_at" : null
  }
}