solana icon indicating copy to clipboard operation
solana copied to clipboard

curve25519-dalek zeroize dependency not compatible with other libraries

Open samuelvanderwaal opened this issue 3 years ago • 65 comments

Problem

Solana v1.8.x relied on curve25519-dalek ^v2.1.0 which itself has a zeroize dependency of ^1.

However, Solana v1.9+ rely on curve25519-dalek ^v3.2.1 which limits zeroize to a range of >=1, <1.4 which is not compatible with many other cryptography libraries (or libraries which depend on cryptography libraries) which use ^1.4 or ^1.5. E.g.s:

It's unclear why curve25519-dalek hasn't bumped yet but there is an open PR to do so. Most other cryptography libraries seem to have bumped to v1.4+

Are there any known workarounds for this? If curve25519-dalek doesn't bump, is it possible for Solana to drop back down to ^v2.1?

Proposed Solution

samuelvanderwaal avatar Jul 20 '22 01:07 samuelvanderwaal

I'm currently running into the same issue with dependencies being incompatible with the outdated zeroize on curve25519-dalek.

anthontaylor avatar Aug 22 '22 20:08 anthontaylor

this was blocking for me when i tried using RustCrypto/RSA

however, at least for rsa, i found sfackler/rust-openssl that binds to openssl OS package.

this seems to be a viable alternative in the meantime.

whymidnight avatar Oct 10 '22 10:10 whymidnight

can confirm that i was able to implement RSA key generation and decryption using sfackler/rust-openssl without dependency issues.

whymidnight avatar Oct 10 '22 12:10 whymidnight

can confirm that i was able to implement RSA key generation and decryption using sfackler/rust-openssl without dependency issues.

Thanks for sharing this!

samuelvanderwaal avatar Oct 10 '22 17:10 samuelvanderwaal

Any update on this ? Majority of packages already bumped zeroize.

NorbertBodziony avatar May 08 '23 15:05 NorbertBodziony

curve25519-dalek 3.2.1 seems to be a blocker here, a 4.0.0 release is imminent (rc.2 was published on March 26)

mschneider avatar May 09 '23 14:05 mschneider

4.0.0 is released

juchiast avatar Jul 24 '23 00:07 juchiast

Upgrading curve25519-dalek to version 4 will not solve the problem Because there is also ed25519-dalek-bip32 (v0.2.0), which depends on ed25519-dalek (v1.0.1), which also depends on curve25519-dalek (version = "3") There is an ed25519-dalek v2.0.0-rc.3 that uses curve25519-dalek "=4.0.0-rc.3", but there is no stable version yet, so ed25519-dalek-bip32 is still on ed25519-dalek 1.0.1 So the way out of this situation may be:

  1. Wait for the release of the stable version of ed25519-dalek -> and then update ed25519-dalek-bip32 -> and then update deps in solana core
  2. Replace the ed25519-dalek-bip32 crate - as far as I understand it is used only for generating a keypair using Bip32 Hierarchical Derivation

hlgltvnnk avatar Jul 31 '23 12:07 hlgltvnnk

  1. Replace the ed25519-dalek-bip32 crate - as far as I understand it is used only for generating a keypair using Bip32 Hierarchical Derivation

solana also uses ed25519-dalek 1.01, so I don't think this is an option.

https://github.com/solana-labs/solana/blob/3dcb3827314517eeec6018cbe28e1ae535437f76/Cargo.toml#L182

juchiast avatar Aug 01 '23 08:08 juchiast

  1. Replace the ed25519-dalek-bip32 crate - as far as I understand it is used only for generating a keypair using Bip32 Hierarchical Derivation

solana also uses ed25519-dalek 1.01, so I don't think this is an option.

https://github.com/solana-labs/solana/blob/3dcb3827314517eeec6018cbe28e1ae535437f76/Cargo.toml#L182

This is a temporary workaround (if you want solana to be compatible with other crates that use zeroize) to use the raw version of ed25519-dalek (Im using "2.0.0-rc.3" in my fork) and then replace the ed25519-dalek-bip32 (because I don't want to fork it as well). This is not stable and should only be used if it blocks development (for example, I need to use the async solana cli in my project, which is implemented in the latest versions of solana, so incompatibility with other packages is a big issue for me). The best option would be to wait until ed25519-dalek releases v2 and then 1) wait for ed25519-dalek-bip32 to update or 2) replace ed25519-dalek-bip32 (spl also needs to be updated)

hlgltvnnk avatar Aug 01 '23 08:08 hlgltvnnk

ed25519-dalek v2.0.0 is released!

hlgltvnnk avatar Aug 14 '23 09:08 hlgltvnnk

There is another dependency that needs to be updated to eliminate the awkward zeroize <1.4 dependency problem: aes-gcm-siv needs to be updated to v0.11.1.

jbuckmccready avatar Sep 19 '23 17:09 jbuckmccready

can someone post a public example project for reproduction? hbu @samuelvanderwaal @whymidnight @hlgltvnnk @jbuckmccready?

mschneider avatar Sep 20 '23 00:09 mschneider

https://github.com/tomlinton/solana-ed25519-conflict

tomlinton avatar Sep 20 '23 02:09 tomlinton

@mschneider https://github.com/jbuckmccready/solana_zeroize_dep_example

jbuckmccready avatar Sep 20 '23 03:09 jbuckmccready

hey @mschneider, thank you for tackling this issue. Do you have any idea when this is going to be fixed? Currently we can't support Solana because of this issue. In our case, the conflict occurs with the last version of sqlx (0.7.2 at this time).

You can find a demo of the issue here (which is basically the same as the two above): https://github.com/klefevre/solana_zeroize_dep_example/

klefevre avatar Sep 27 '23 12:09 klefevre

hey @mschneider, thank you for tackling this issue. Do you have any idea when this is going to be fixed? Currently we can't support Solana because of this issue. In our case, the conflict occurs with the last version of sqlx (0.7.2 at this time).

You can find a demo of the issue here (which is basically the same as the two above): https://github.com/klefevre/solana_zeroize_dep_example/

Here's a branch with a fix for just solana-program https://github.com/dbcfd/solana/tree/fix/deps. Still have to work through the other parts of solana.

dbcfd avatar Sep 29 '23 18:09 dbcfd

I am also unable to use several sqlx features because of the zeroize version. Bumping aes-gcm-siv would be appreciated!

ronanyeah avatar Dec 04 '23 04:12 ronanyeah

In the meanwhile, here’s a workaround:

[patch.crates-io]
# aes-gcm-siv 0.10.3 and curve25519-dalek 3.x pin zeroize to <1.4
# which conflicts with other dependencies requiring zeroize ^1.5.
# We’re patching both crates to unpin zeroize.
#
# For aes-gcm-siv we’re using the same revision Solana uses in
# an (as of now) unreleased commit, see
# https://github.com/solana-labs/solana/commit/01f1bf27994d9813fadfcd134befd3a449aaa0bd
#
# For curve25519-dalek we’re using commit from a PR, see
# https://github.com/dalek-cryptography/curve25519-dalek/pull/606
aes-gcm-siv = { git = "https://github.com/RustCrypto/AEADs", rev = "6105d7a5591aefa646a95d12b5e8d3f55a9214ef" }
curve25519-dalek = { git = "https://github.com/dalek-cryptography/curve25519-dalek", rev = "8274d5cbb6fc3f38cdc742b4798173895cd2a290" }

The second entry points at a commit in a PR. I’m not sure how GitHub treats those and if it’s going to remain available. If not, change repository to "https://github.com/mina86/curve25519-dalek/".

The aes-gcm-siv patch should be unnecessary as soon as new solana crates release happens.

mina86 avatar Dec 05 '23 21:12 mina86

@mina86 Works for me, thank you.

ronanyeah avatar Dec 05 '23 22:12 ronanyeah

If anyone got subtle dep conflict:

aes-gcm-siv = { git = "https://github.com/RustCrypto/AEADs", rev = "555ae1d82d000f01899498f969e6dc1d0a4fe467" }

juchiast avatar Dec 13 '23 12:12 juchiast

It is a blocker to import ethers-rs and solana-sdk in the same binary.

All workarounds above are fragile.

error: failed to select a version for `zeroize`.
    ... required by package `curve25519-dalek v3.2.1`
    ... which satisfies dependency `curve25519-dalek = "^3.2.1"` of package `solana-program v1.17.11`
    ... which satisfies dependency `solana-program = "=1.17.11"` of package `solana-sdk v1.17.11`
    ... which satisfies dependency `solana-sdk = "^1.17.11"` of package `solana v0.1.0 (~/myproject/solana)`
versions that meet the requirements `>=1, <1.4` are: 1.3.0, 1.2.0, 1.1.1, 1.1.0, 1.0.0
all possible versions conflict with previously selected packages.
  previously selected package `zeroize v1.5.3`
    ... which satisfies dependency `zeroize = "^1.5"` of package `elliptic-curve v0.13.5`
    ... which satisfies dependency `elliptic-curve = "^0.13.5"` of package `ethers-core v2.0.11`
    ... which satisfies dependency `ethers-core = "^2.0.11"` of package `ethers v2.0.11`
    ... which satisfies dependency `ethers = "^2.0.11"` of package `ethereum v0.1.0 (~/myproject/ethereum)`
    ... which satisfies path dependency `ethereum` (locked to 0.1.0) of package `main v0.1.0 (~/myproject/main)`
failed to select a version for `zeroize` which could resolve this conflict

serejke avatar Dec 16 '23 18:12 serejke

@mschneider May I assist with solving this issue ?

dougEfresh avatar Jan 14 '24 11:01 dougEfresh

from my pov resolution of this issue is still blocked by a zeroize upgrade. if you have a patch that resolves the issues feel free to send a PR, but I can’t guarantee it’ll get merged quickly because there’s a couple of downstream projects that need to be upgraded as well. not gonna lie the way rust crypto 4 has been rolled out is very painful. the current workaround is to prevent conflicts by pinning the old version and only using packages compatible with it.

mschneider avatar Jan 14 '24 11:01 mschneider

@mschneider I have done a similar upgrade before for hyperledger ursa.

@dougEfresh if you have any intermediate work on this, let me know, otherwise I'm opening a draft PR with the patches.

appetrosyan avatar Feb 07 '24 07:02 appetrosyan

OK. So at present the patch uis using a Solana vendored curve25519-dalek that removed the explicit pin on zeroize. However, the upgrade to the curve25519-dalek of version 4.0.0 wasn't made, and I think I should just do it.

appetrosyan avatar Feb 09 '24 13:02 appetrosyan

Not quite sure why my PR with this patch to this repo was autoclosed. I've raised another one into agave. LMK.

35359595 avatar Mar 20 '24 18:03 35359595

I'm still experiencing the same issue while using solana-client, solana-sdk and ethers-rs @mschneider

Cargo.toml Screenshot 2024-04-06 at 00 32 49

Error Screenshot 2024-04-06 at 00 33 50

iamnotstatic avatar Apr 05 '24 17:04 iamnotstatic

solana crates are incompatible with libp2p due to this issue.

mattxyzeth avatar May 14 '24 01:05 mattxyzeth

How can I fix it?

IntelCore0607 avatar May 28 '24 19:05 IntelCore0607