GHSA-v432-7f47-9g94: PostQuantum Feldman VSS PostQuantum-Feldman-VSS'S Dependency Vulnerability Vulnerability

HIGH
CWE-400
Published
Advisory Summary

GHSA-v432-7f47-9g94 is a HIGH postquantum-feldman-vss's dependency vulnerability vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting PostQuantum Feldman VSS libraries in the PyPI ecosystem. The issue involves postquantum-feldman-vss's dependency vulnerability in gmpy2 leading to interpreter crash. Remediation is available by upgrading affected packages to version 0.7.7b0.

GHSA-v432-7f47-9g94 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-v432-7f47-9g94
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product PostQuantum Feldman VSS
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix GHSA-v432-7f47-9g94

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

PostQuantum-Feldman-VSS fixed: 0.7.7b0
pip install PostQuantum-Feldman-VSS>=0.7.7b0
Verify Direct and Transitive Dependencies

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

pip show PostQuantum-Feldman-VSS

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-v432-7f47-9g94, inspect your installed packages using pip:

pip show PostQuantum-Feldman-VSS

Analyze the terminal output to locate any version of PostQuantum Feldman VSS in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.7.7b0), your application is affected.

Note: The pip show PostQuantum-Feldman-VSS command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In PostQuantum Feldman VSS, 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

**Description:** PostQuantum-Feldman-VSS, a Python library implementing Feldman's Verifiable Secret Sharing scheme with post-quantum security, was vulnerable to denial-of-service attacks in versions up to and including 0.7.6b0. This vulnerability stems from the library's reliance on the `gmpy2` library for arbitrary-precision arithmetic. `gmpy2`, in turn, depends on the GNU Multiple Precision Arithmetic Library (GMP). GMP, by design, terminates the process when it cannot allocate memory. An attacker could exploit this by providing carefully crafted inputs that cause `gmpy2` to attempt to allocate extremely large amounts of memory, leading to a crash of the Python interpreter and thus a denial of service. **Vulnerability Details:** The core issue lies in the behavior of GMP (and thus, `gmpy2`) when memory allocation fails. Instead of raising a standard Python exception that could be caught and handled, GMP terminates the entire process. This behavior is documented in the GMP and gmpy2 documentation: * **GMP Memory Management:** [https://gmplib.org/manual/Memory-Management](https://gmplib.org/manual/Memory-Management) (States that the default behavior is to terminate the program.) * **gmpy2 Overview:** [https://gmpy2.readthedocs.io/en/latest/overview.html](https://gmpy2.readthedocs.io/en/latest/overview.html) (Warns that `gmpy2` can crash the interpreter on memory allocation failure.) Specific operations within the PostQuantum-Feldman-VSS library that were particularly vulnerable include: * **Large Exponentiation (`exp`, `secure_exp`):** Exponentiation with very large bases or exponents can lead to extremely large results, consuming excessive memory. * **Multi-exponentiation (`efficient_multi_exp`):** Similar to exponentiation, but with multiple bases and exponents, increasing the risk. * **Matrix Operations (`_secure_matrix_solve`):** Large matrices used in polynomial reconstruction could lead to significant memory usage. * **Polynomial Evaluation (`_evaluate_polynomial`):** Evaluating polynomials with large coefficients or at large values of `x` could trigger excessive memory allocation. **Mitigations in 0.8.0b2:** Version 0.8.0b2 implements *significant mitigations* to greatly reduce the risk of this denial-of-service vulnerability. These mitigations **do not** completely eliminate the underlying issue (as that would require changes to GMP itself), but they make successful exploitation *far* more difficult. The mitigations include: 1. **Memory Monitoring (`MemoryMonitor` class):** * A new `MemoryMonitor` class is introduced to track estimated memory usage throughout the library's operations. * This class allows setting a maximum memory limit (defaulting to 1024MB, but configurable). * It provides methods to `check_allocation`, `allocate`, and `release` memory, raising a `MemoryError` if an operation would exceed the configured limit. 2. **Memory Safety Checks (`check_memory_safety` function):** * A new `check_memory_safety` function is used to estimate the memory requirements of various `gmpy2` operations *before* they are executed. * This function considers the operation type (`exp`, `mul`, `pow`, `mod`, `polynomial`, `matrix`, `polynomial_eval`) and the bit lengths of the operands. * It uses conservative estimates and scaling factors to account for `gmpy2`'s internal overhead. * If the estimated memory usage exceeds the limit set by the `MemoryMonitor`, the operation is rejected *before* calling `gmpy2`, preventing the crash. 3. **Integration into Core Classes:** * The `CyclicGroup` and `FeldmanVSS` classes now use the `check_memory_safety` function before performing potentially memory-intensive operations like `exp`, `mul`, `efficient_multi_exp`, `_evaluate_polynomial`, and `_secure_matrix_solve`. 4. **Enhanced Input Validation and Error Handling:** * Added improved input validation in functions. * Raises custom exceptions like `SecurityError`, `SerializationError`, `VerificationError`, and `ParameterError` that include detailed information for forensics and debugging. 5. **Safer Defaults and Configuration:** * The library is configured to use safe primes and large bit lengths by default, reducing the likelihood of accidental misconfiguration leading to excessively large numbers. * The `VSSConfig` class allows users to customize the `prime_bits` and `cache_size`, enabling them to tailor the library to their specific memory constraints. **Limitations of Mitigations:** * **Estimation Inaccuracy:** The `check_memory_safety` function relies on *estimations* of memory usage. While these estimations are conservative, they are not perfect. It is still theoretically possible (though much less likely) for an operation to consume more memory than estimated, leading to a crash. * **GMP Behavior:** The fundamental issue of GMP terminating the process on memory allocation failure remains. The mitigations prevent most common cases, but a sufficiently determined attacker with knowledge of the estimation algorithm *might* still be able to craft an input that triggers a crash. * **Not a Complete Fix:** Version 0.8.0b2 is a *mitigation*, not a complete *elimination* of the vulnerability. **Workarounds (for versions <= 0.7.6b0):** If upgrading to version 0.8.0b2 (or later) is not immediately possible, the following workarounds can help reduce the risk: * **Limit Input Sizes:** Carefully restrict the size of inputs to the library, particularly the bit lengths of secrets, shares, and coefficients, and the threshold value (t). Avoid using excessively large values. Use the `check_memory_safety` function (available in 0.8.0b2) to manually check the memory usage. * **Resource Monitoring:** Implement external monitoring of your application's memory usage. If memory usage approaches dangerous levels, take action to prevent a crash (e.g., terminate the process, reject new requests, etc.). * **Input Validation:** Thoroughly validate all inputs to the library, ensuring they are within expected ranges and of the correct types. * **Rate Limiting:** Implement rate limiting to prevent an attacker from flooding your system with requests designed to consume excessive memory. * **Custom Memory Allocation**: *Advanced users* could potentially modify the GMP library to use custom allocation functions that raise Python exceptions instead of terminating the process. This is a complex and potentially risky approach, and is **not recommended** for most users. (See [GMP Custom Allocation Documentation](https://gmplib.org/manual/Custom-Allocation)). **Recommendations:** * **Upgrade to 0.8.0b2 (or later) as soon as possible.** This is the *most important* step you can take. * **Configure Memory Limits:** Use the `MemoryMonitor` in 0.8.0b2 (or later) to set appropriate memory limits for your application. Consider your system's available memory and the expected workload. * **Monitor Memory Usage:** Even with the mitigations, continue to monitor your application's memory usage and be prepared to handle potential memory exhaustion events. * **Follow Security Best Practices:** Implement robust input validation, rate limiting, and other security measures to protect your application from various attacks, not just this specific vulnerability. **Future Work:** * **Rust Integration:** The long-term solution is to implement the most memory-intensive and security-critical operations in a lower-level language like Rust, which provides more control over memory management and can avoid the problematic GMP behavior. This is planned for future versions. * **More Precise Memory Estimation:** Research and improve the accuracy of the memory estimation algorithms used in `check_memory_safety`. * **Fuzz Testing:** Conduct extensive fuzz testing to identify any remaining edge cases that could trigger excessive memory allocation.

GHSA-v432-7f47-9g94 Affected PostQuantum Feldman VSS Versions

1 component(s)
Fixed Versions:
0.7.7b0
Product / Package Ecosystem Affected Versions Fixed Version
PostQuantum-Feldman-VSS
PyPI
< 0.7.7b0
0.7.7b0

References

Frequently Asked Questions

What is GHSA-v432-7f47-9g94?
GHSA-v432-7f47-9g94 is a security vulnerability in PostQuantum Feldman VSS involving PostQuantum-Feldman-VSS'S Dependency Vulnerability in gmpy2 Leading to Interpreter Crash under CWE-400: Uncontrolled Resource Consumption.
Which PostQuantum Feldman VSS versions are affected?
Affected versions include releases prior to 0.7.7b0 across affected packages: PostQuantum-Feldman-VSS.
What version fixes GHSA-v432-7f47-9g94?
Upgrading to 0.7.7b0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is PostQuantum-Feldman-VSS affected?
Yes, PostQuantum-Feldman-VSS is affected in releases prior to 0.7.7b0. Upgrade your dependency to 0.7.7b0 or later.
What CWE is associated with GHSA-v432-7f47-9g94?
GHSA-v432-7f47-9g94 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check PyPI dependencies for GHSA-v432-7f47-9g94?
Run the dependency tree command: 'pip show PostQuantum-Feldman-VSS'. 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-v432-7f47-9g94",
  "modified" : "2025-03-19T15:24:59Z",
  "published" : "2025-03-17T14:48:07Z",
  "aliases" : [ ],
  "summary" : "PostQuantum-Feldman-VSS'S Dependency Vulnerability in gmpy2 Leading to Interpreter Crash",
  "details" : "**Description:**\n\nPostQuantum-Feldman-VSS, a Python library implementing Feldman's Verifiable Secret Sharing scheme with post-quantum security, was vulnerable to denial-of-service attacks in versions up to and including 0.7.6b0.  This vulnerability stems from the library's reliance on the `gmpy2` library for arbitrary-precision arithmetic.  `gmpy2`, in turn, depends on the GNU Multiple Precision Arithmetic Library (GMP). GMP, by design, terminates the process when it cannot allocate memory.  An attacker could exploit this by providing carefully crafted inputs that cause `gmpy2` to attempt to allocate extremely large amounts of memory, leading to a crash of the Python interpreter and thus a denial of service.\n\n**Vulnerability Details:**\n\nThe core issue lies in the behavior of GMP (and thus, `gmpy2`) when memory allocation fails.  Instead of raising a standard Python exception that could be caught and handled, GMP terminates the entire process. This behavior is documented in the GMP and gmpy2 documentation:\n\n*   **GMP Memory Management:** [https://gmplib.org/manual/Memory-Management](https://gmplib.org/manual/Memory-Management) (States that the default behavior is to terminate the program.)\n*   **gmpy2 Overview:** [https://gmpy2.readthedocs.io/en/latest/overview.html](https://gmpy2.readthedocs.io/en/latest/overview.html) (Warns that `gmpy2` can crash the interpreter on memory allocation failure.)\n\nSpecific operations within the PostQuantum-Feldman-VSS library that were particularly vulnerable include:\n\n*   **Large Exponentiation (`exp`, `secure_exp`):**  Exponentiation with very large bases or exponents can lead to extremely large results, consuming excessive memory.\n*   **Multi-exponentiation (`efficient_multi_exp`):**  Similar to exponentiation, but with multiple bases and exponents, increasing the risk.\n*   **Matrix Operations (`_secure_matrix_solve`):**  Large matrices used in polynomial reconstruction could lead to significant memory usage.\n*   **Polynomial Evaluation (`_evaluate_polynomial`):** Evaluating polynomials with large coefficients or at large values of `x` could trigger excessive memory allocation.\n\n**Mitigations in 0.8.0b2:**\n\nVersion 0.8.0b2 implements *significant mitigations* to greatly reduce the risk of this denial-of-service vulnerability.  These mitigations **do not** completely eliminate the underlying issue (as that would require changes to GMP itself), but they make successful exploitation *far* more difficult.  The mitigations include:\n\n1.  **Memory Monitoring (`MemoryMonitor` class):**\n    *   A new `MemoryMonitor` class is introduced to track estimated memory usage throughout the library's operations.\n    *   This class allows setting a maximum memory limit (defaulting to 1024MB, but configurable).\n    *   It provides methods to `check_allocation`, `allocate`, and `release` memory, raising a `MemoryError` if an operation would exceed the configured limit.\n\n2.  **Memory Safety Checks (`check_memory_safety` function):**\n    *   A new `check_memory_safety` function is used to estimate the memory requirements of various `gmpy2` operations *before* they are executed.\n    *   This function considers the operation type (`exp`, `mul`, `pow`, `mod`, `polynomial`, `matrix`, `polynomial_eval`) and the bit lengths of the operands.\n    *   It uses conservative estimates and scaling factors to account for `gmpy2`'s internal overhead.\n    *   If the estimated memory usage exceeds the limit set by the `MemoryMonitor`, the operation is rejected *before* calling `gmpy2`, preventing the crash.\n\n3.  **Integration into Core Classes:**\n    *   The `CyclicGroup` and `FeldmanVSS` classes now use the `check_memory_safety` function before performing potentially memory-intensive operations like `exp`, `mul`, `efficient_multi_exp`, `_evaluate_polynomial`, and `_secure_matrix_solve`.\n\n4.  **Enhanced Input Validation and Error Handling:**\n    *  Added improved input validation in functions.\n    *  Raises custom exceptions like `SecurityError`, `SerializationError`, `VerificationError`, and `ParameterError` that include detailed information for forensics and debugging.\n\n5.  **Safer Defaults and Configuration:**\n    *   The library is configured to use safe primes and large bit lengths by default, reducing the likelihood of accidental misconfiguration leading to excessively large numbers.\n    *   The `VSSConfig` class allows users to customize the `prime_bits` and `cache_size`, enabling them to tailor the library to their specific memory constraints.\n\n**Limitations of Mitigations:**\n\n*   **Estimation Inaccuracy:** The `check_memory_safety` function relies on *estimations* of memory usage. While these estimations are conservative, they are not perfect.  It is still theoretically possible (though much less likely) for an operation to consume more memory than estimated, leading to a crash.\n*   **GMP Behavior:** The fundamental issue of GMP terminating the process on memory allocation failure remains.  The mitigations prevent most common cases, but a sufficiently determined attacker with knowledge of the estimation algorithm *might* still be able to craft an input that triggers a crash.\n*   **Not a Complete Fix:** Version 0.8.0b2 is a *mitigation*, not a complete *elimination* of the vulnerability.\n\n**Workarounds (for versions <= 0.7.6b0):**\n\nIf upgrading to version 0.8.0b2 (or later) is not immediately possible, the following workarounds can help reduce the risk:\n\n*   **Limit Input Sizes:**  Carefully restrict the size of inputs to the library, particularly the bit lengths of secrets, shares, and coefficients, and the threshold value (t).  Avoid using excessively large values.  Use the `check_memory_safety` function (available in 0.8.0b2) to manually check the memory usage.\n*   **Resource Monitoring:** Implement external monitoring of your application's memory usage.  If memory usage approaches dangerous levels, take action to prevent a crash (e.g., terminate the process, reject new requests, etc.).\n*   **Input Validation:** Thoroughly validate all inputs to the library, ensuring they are within expected ranges and of the correct types.\n*   **Rate Limiting:** Implement rate limiting to prevent an attacker from flooding your system with requests designed to consume excessive memory.\n*  **Custom Memory Allocation**:  *Advanced users* could potentially modify the GMP library to use custom allocation functions that raise Python exceptions instead of terminating the process.  This is a complex and potentially risky approach, and is **not recommended** for most users.  (See [GMP Custom Allocation Documentation](https://gmplib.org/manual/Custom-Allocation)).\n\n**Recommendations:**\n\n*   **Upgrade to 0.8.0b2 (or later) as soon as possible.** This is the *most important* step you can take.\n*   **Configure Memory Limits:**  Use the `MemoryMonitor` in 0.8.0b2 (or later) to set appropriate memory limits for your application.  Consider your system's available memory and the expected workload.\n*   **Monitor Memory Usage:**  Even with the mitigations, continue to monitor your application's memory usage and be prepared to handle potential memory exhaustion events.\n*   **Follow Security Best Practices:**  Implement robust input validation, rate limiting, and other security measures to protect your application from various attacks, not just this specific vulnerability.\n\n**Future Work:**\n\n*   **Rust Integration:**  The long-term solution is to implement the most memory-intensive and security-critical operations in a lower-level language like Rust, which provides more control over memory management and can avoid the problematic GMP behavior. This is planned for future versions.\n*   **More Precise Memory Estimation:**  Research and improve the accuracy of the memory estimation algorithms used in `check_memory_safety`.\n*   **Fuzz Testing:**  Conduct extensive fuzz testing to identify any remaining edge cases that could trigger excessive memory allocation.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "PostQuantum-Feldman-VSS"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.7.7b0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.7.6b0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/DavidOsipov/PostQuantum-Feldman-VSS/security/advisories/GHSA-v432-7f47-9g94"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/DavidOsipov/PostQuantum-Feldman-VSS"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-03-17T14:48:07Z",
    "nvd_published_at" : null
  }
}