# GHSA-v935-pqmr-g8v9: Unexpected panics in num-bigint

> Unexpected panics in num-bigint multiplication can cause denial of service in applications using the library.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 3 Nov 2021

## What is GHSA-v935-pqmr-g8v9?

GHSA-v935-pqmr-g8v9 is a denial of service vulnerability in num-bigint, published on 3 Nov 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact

Two scenarios were reported where `BigInt` and `BigUint` multiplication may unexpectedly panic.

- The internal `mac3` function did not expect the possibility of non-empty all-zero inputs, leading to an `unwrap()` panic.
- A buffer was allocated with less capacity than needed for an intermediate result, leading to an assertion panic.

Rust panics can either cause stack unwinding or program abort, depending on the application configuration. In some settings, an unexpected panic may constitute a denial-of-service vulnerability.

### Patches
Both problems were introduced in version 0.4.1, and are fixed in version 0.4.3.

### For more information
If you have any questions or comments about this advisory, please open an issue in the [num-bigint](https://github.com/rust-num/num-bigint) repo.

### Acknowledgements
Thanks to Guido Vranken and Arvid Norberg for privately reporting these issues to the author.

### References
* [GHSA-v935-pqmr-g8v9](https://github.com/rust-num/num-bigint/security/advisories/GHSA-v935-pqmr-g8v9)
* [num-bigint#228](https://github.com/rust-num/num-bigint/pull/228)

## Which versions are affected by GHSA-v935-pqmr-g8v9?

2 open source packages ship an affected version, including num-bigint.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `num-bigint` | crates.io | From 0.4.1 | 0.4.3 |
| `num-bigint` | crates.io | From 0.4.1 | 0.4.3 |

## How do I fix GHSA-v935-pqmr-g8v9?

Upgrade num-bigint to 0.4.3 or later.

## Is GHSA-v935-pqmr-g8v9 being exploited?

There is no known exploitation of GHSA-v935-pqmr-g8v9 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-v935-pqmr-g8v9 and fix it if it is affected.

What it is: GHSA-v935-pqmr-g8v9 is a denial of service vulnerability in num-bigint, published on 3 Nov 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-v935-pqmr-g8v9 in the wild and no public exploit code.

Affected packages and fixed versions:
- num-bigint (crates.io): affected from 0.4.1; fixed in 0.4.3
- num-bigint (crates.io): affected from 0.4.1; fixed in 0.4.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-v935-pqmr-g8v9/ (Markdown: https://insights.sbomify.com/GHSA-v935-pqmr-g8v9/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-v935-pqmr-g8v9

---
From sbomify Insights: https://insights.sbomify.com/GHSA-v935-pqmr-g8v9/
Summaries are generated and may contain mistakes; the official description above is the record.
