# GHSA-hvh4-5qr6-3v7r: Observable Timing Discrepancy in pypqc

> An attacker can recover private keys from pypqc Kyber implementations on macOS or clang-compiled systems by analyzing timing discrepancies during decapsulation requests.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** No
- **Published:** 5 Jun 2024

## What is GHSA-hvh4-5qr6-3v7r?

GHSA-hvh4-5qr6-3v7r is a vulnerability in pypqc, published on 5 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact
`kyber512`, `kyber768`, and `kyber1024` on Mac OS \(or when compiled with clang\) only: An attacker able to submit many decapsulation requests against a single private key, and to gain timing information about the decapsulation, could recover the private key. Proof-of-concept exploit exists for a local attacker.

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N/E:P/RL:U/RC:C  

### Patches
No patch is currently available / pending upstream [PQClean#556](https://github.com/PQClean/PQClean/issues/556).

### Workarounds
No workarounds have been reported. The 0.0.7 -> 0.0.7.1 upgrade, when available, should be a drop-in replacement<!--; it has no known breaking changes-->.

### References

https://pqshield.com/pqshield-plugs-timing-leaks-in-kyber-ml-kem-to-improve-pqc-implementation-maturity/

https://github.com/antoonpurnal/clangover

https://www.github.com/PQClean/PQClean/issues/556

https://www.github.com/pq-crystals/kyber/commit/9b8d30698a3e7449aeb34e62339d4176f11e3c6c

## Which versions are affected by GHSA-hvh4-5qr6-3v7r?

2 open source packages ship an affected version, including pypqc.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pypqc` | PyPI | From 0.0.4 to 0.0.6.2 | None |
| `pypqc` | PyPI | From 0.0.4 to 0.0.6.2 | None |

## How do I fix GHSA-hvh4-5qr6-3v7r?

No fix has been published for GHSA-hvh4-5qr6-3v7r yet. Limit exposure of the affected software until one is available.

## Is GHSA-hvh4-5qr6-3v7r being exploited?

There is no known exploitation of GHSA-hvh4-5qr6-3v7r in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-hvh4-5qr6-3v7r and fix it if it is affected.

What it is: GHSA-hvh4-5qr6-3v7r is a vulnerability in pypqc, published on 5 Jun 2024. 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-hvh4-5qr6-3v7r in the wild and no public exploit code.

Affected packages and fixed versions:
- pypqc (PyPI): affected from 0.0.4 up to 0.0.6.2; no fix listed
- pypqc (PyPI): affected from 0.0.4 up to 0.0.6.2; no fix listed

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-hvh4-5qr6-3v7r/ (Markdown: https://insights.sbomify.com/GHSA-hvh4-5qr6-3v7r/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-hvh4-5qr6-3v7r

---
From sbomify Insights: https://insights.sbomify.com/GHSA-hvh4-5qr6-3v7r/
Summaries are generated and may contain mistakes; the official description above is the record.
