Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1jOXZ2LWZoZ3YtY2pjM84AA5aA

agent-js: Insecure Key Generation in `Ed25519KeyIdentity.generate`

Impact

The library offers a function to generate an ed25519 key pair via Ed25519KeyIdentity.generate with an optional param to provide a 32 byte seed value, which will then be used as the secret key. When no seed value is provided, it is expected that the library generates the secret key using secure randomness. However, a recent change broke this guarantee and uses an insecure seed for key pair generation.

Since the private key of this identity (535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe) is compromised, one could lose funds associated with the principal on ledgers or lose access to a canister where this principal is the controller. Users are asked to take proactive measures mentioned below in Workarounds:Users to protect their assets.

Patches

Patch for the vulnerability is available in v1.0.1 for all the packages listed in the advisory. Please upgrade and deploy your canisters immediately.

Workarounds

Developers

The recommended fix is to upgrade the package to the patched version. If that is not possible, there are couple of workarounds to handle the insecure key generation.

  1. Invoking the function as Ed25519KeyIdentity.generate(null) would fix the broken conditional evaluation and force the function to generate a securely random seed. However, this is not guaranteed to work for future upgrades.
  2. Passing a securely generated randomness as a seed to Ed25519KeyIdentity.generate would force the library to use it as the seed to generate the key pair.

Users

Removing a controller of a canister if it's the affected principal

For all canisters you control, fetch the controllers of the canisters using

dfx canister info --ic <CANISTER>

If you see the principal 535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe as one of the controllers, follow the steps below

dfx identity whoami # record CURRENT_IDENTITY

dfx identity new <NEW_IDENTITY_NAME> 
dfx identity use <NEW_IDENTITY_NAME> 
dfx identity get-principal <NEW_IDENTITY_NAME> # record NEW_IDENTITY_PRINCIPAL

dfx identity use <CURRENT_IDENTITY>
dfx canister update-settings --ic <CANISTER> --add-controller <NEW_IDENTITY_PRINCIPAL>
dfx canister update-settings --ic <CANISTER> --remove-controller `535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe`

For more details on canister management, please visit here

Checking funds on wallets / ledgers

If you have funds on ledgers using a browser wallet, please check if the account principal matches 535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe. If it does, please create a new account and transfer the funds to the new account immediately.

References

  1. fix PR link
  2. NPM patched version
  3. agent-js Github repo
  4. agent-js docs
Permalink: https://github.com/advisories/GHSA-c9vv-fhgv-cjc3
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1jOXZ2LWZoZ3YtY2pjM84AA5aA
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: 2 months ago
Updated: 2 months ago


CVSS Score: 9.1
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

Identifiers: GHSA-c9vv-fhgv-cjc3, CVE-2024-1631
References: Repository: https://github.com/dfinity/agent-js
Blast Radius: 22.9

Affected Packages

npm:@dfinity/auth-client
Dependent packages: 53
Dependent repositories: 251
Downloads: 29,518 last month
Affected Version Ranges: >= 0.20.0-beta.0, < 1.0.1
Fixed in: 1.0.1
All affected versions: 0.20.0, 0.20.0-beta.0, 0.20.1, 0.20.2, 0.21.1, 0.21.2, 0.21.3, 0.21.4, 1.0.0
All unaffected versions: 0.8.5, 0.8.6, 0.8.7, 0.8.8, 0.8.9, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7, 0.16.0, 0.17.0, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.19.3, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0
npm:@dfinity/identity
Dependent packages: 102
Dependent repositories: 326
Downloads: 39,005 last month
Affected Version Ranges: >= 0.20.0-beta.0, < 1.0.1
Fixed in: 1.0.1
All affected versions: 0.20.0, 0.20.0-beta.0, 0.20.1, 0.20.2, 0.21.1, 0.21.2, 0.21.3, 0.21.4, 1.0.0
All unaffected versions: 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.8.7, 0.8.8, 0.8.9, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7, 0.16.0, 0.17.0, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.19.3, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0