# GHSA-84c3-j8r2-mcm8: @nfid/embed has compromised private key due to @dfinity/auth-client producing insecure session keys

> Insecure key generation in DFINITY auth-client allows attackers to compromise user sessions and access funds or canisters.

- **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:** 26 Feb 2024

## What is GHSA-84c3-j8r2-mcm8?

GHSA-84c3-j8r2-mcm8 is a vulnerability in @nfid/embed, published on 26 Feb 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Problem
User sessions in the @nfid/embed SDK with Ed25519 keys are vulnerable due to a compromised private key `535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe`. This exposes users to potential loss of funds on ledgers and unauthorized access to canisters they control.

### Solution
Using version >1.0.1 of @dfinity/auth-client and @dfinity/identity packages, or @nfid/embed >0.10.1-alpha.6 includes patched versions of the issue.

User sessions will be automatically fixed when they re-authenticate.

### Why this happened
The DFINITY auth client library provides a function, `Ed25519KeyIdentity.generate`, for generating an Ed25519 key pair. This function includes an optional parameter to supply a 32-byte seed value, which will be utilized as the secret key. In cases where no seed value is provided, the library is expected to generate the secret key using secure randomness. However, a recent update of DFINITY libraries has compromised this assurance by employing an insecure seed for key pair generation.

### References
[AgentJS CVE ](https://github.com/dfinity/agent-js/security/advisories/GHSA-c9vv-fhgv-cjc3)

## Which versions are affected by GHSA-84c3-j8r2-mcm8?

2 open source packages ship an affected version, including @nfid/embed.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@nfid/embed` | npm | From 0.10.0 | 0.10.1-alpha.6 |
| `@nfid/embed` | npm | From 0.10.0 | 0.10.1-alpha.6 |

## How do I fix GHSA-84c3-j8r2-mcm8?

Upgrade @nfid/embed to 0.10.1-alpha.6 or later.

## Is GHSA-84c3-j8r2-mcm8 being exploited?

There is no known exploitation of GHSA-84c3-j8r2-mcm8 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-84c3-j8r2-mcm8 and fix it if it is affected.

What it is: GHSA-84c3-j8r2-mcm8 is a vulnerability in @nfid/embed, published on 26 Feb 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-84c3-j8r2-mcm8 in the wild and no public exploit code.

Affected packages and fixed versions:
- @nfid/embed (npm): affected from 0.10.0; fixed in 0.10.1-alpha.6
- @nfid/embed (npm): affected from 0.10.0; fixed in 0.10.1-alpha.6

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-84c3-j8r2-mcm8/ (Markdown: https://insights.sbomify.com/GHSA-84c3-j8r2-mcm8/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-84c3-j8r2-mcm8

---
From sbomify Insights: https://insights.sbomify.com/GHSA-84c3-j8r2-mcm8/
Summaries are generated and may contain mistakes; the official description above is the record.
