# GHSA-x279-68rr-jp4p: Blst vulnerable to incorrect results for some inputs in blst_fp_eucl_inverse function

> The blst library may produce incorrect results in modular inversion, potentially leading to invalid signatures, though no production impact has been observed.

- **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:** 7 Oct 2022
- **Also known as:** GO-2022-1053

## What is GHSA-x279-68rr-jp4p?

GHSA-x279-68rr-jp4p is a vulnerability in github.com/supranational/blst, published on 7 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact
Blst versions v0.3.0 to v0.3.2 can produce the incorrect outputs for some inputs to the blst_fp_eucl_inverse function. This could theoretically result in the creation of an invalid signature from correct inputs. However, fuzzing of higher level functions such as sign and verify were unable to produce incorrect results and there has been no reported occurrences of this issue being encountered in production use.

### Description
During the course of differential fuzzing of the blst library by @guidovranken it was discovered that blst would produce the incorrect result for some input values in the inverse function. This was the result of the introduction of a new inversion formula in version v0.3.0. This source of these incorrect outputs was due to two issues:

1. The amount of inner loop iterations was not sufficient for the algorithm to converge.
2. It was erroneously assumed that the absolute value of the intermediate result would be capped at 767-bits. As a result, some output values were truncated by one bit or the most significant bit was misinterpreted as the sign.

### Patches
This issue has been resolved in the v0.3.3 release and users are recommended to upgrade immediately.

### References
The software used to uncover this issue can be found [here](https://github.com/guidovranken/cryptofuzz).

### Credits
A special thanks to Guido Vranken (@guidovranken) for his discovery and disclosure of this vulnerability.

### For more information
If you have any questions or comments about this advisory please email us at [hello@supranational.net](mailto:hello@supranational.net)

## Which versions are affected by GHSA-x279-68rr-jp4p?

3 open source packages ship an affected version, including github.com/supranational/blst.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/supranational/blst` | Go | From 0.3.0 | 0.3.3 |
| `github.com/supranational/blst` | Go | From 0.3.0 | 0.3.3 |
| `github.com/supranational/blst` | Go | From 0.3.0 | 0.3.3 |

## How do I fix GHSA-x279-68rr-jp4p?

Upgrade github.com/supranational/blst to 0.3.3 or later.

## Is GHSA-x279-68rr-jp4p being exploited?

There is no known exploitation of GHSA-x279-68rr-jp4p in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-x279-68rr-jp4p and fix it if it is affected.

What it is: GHSA-x279-68rr-jp4p is a vulnerability in github.com/supranational/blst, published on 7 Oct 2022. 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-x279-68rr-jp4p in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/supranational/blst (Go): affected from 0.3.0; fixed in 0.3.3
- github.com/supranational/blst (Go): affected from 0.3.0; fixed in 0.3.3
- github.com/supranational/blst (Go): affected from 0.3.0; fixed in 0.3.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-x279-68rr-jp4p/ (Markdown: https://insights.sbomify.com/GHSA-x279-68rr-jp4p/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-x279-68rr-jp4p

---
From sbomify Insights: https://insights.sbomify.com/GHSA-x279-68rr-jp4p/
Summaries are generated and may contain mistakes; the official description above is the record.
