Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security: ed25519 verification accepts forged signatures #1199

Closed
paulmillr opened this issue Nov 9, 2023 · 2 comments · Fixed by LimeChain/near-api-js#5 or #1209
Closed

Security: ed25519 verification accepts forged signatures #1199

paulmillr opened this issue Nov 9, 2023 · 2 comments · Fixed by LimeChain/near-api-js#5 or #1209
Labels
bug Something isn't working

Comments

@paulmillr
Copy link

paulmillr commented Nov 9, 2023

Your implementation of ed25519 accepts forged signatures, it's malleable.

To check this, LE-add curve order to a signature $S$ component. Verification would still pass.

It's pretty bad. To fix, switch to a better ed25519 library.

This issue was first reported 6 months ago.

@paulmillr paulmillr added the bug Something isn't working label Nov 9, 2023
@vikinatora
Copy link
Collaborator

Hey @paulmillr, we're looking for an alternative library that would resolve this issue. We tried using your library@1.7.0 but it didn't work out as NEAR uses 64 byte keys(private key + public key concatenated) f.e E8rptqS9XcQ8RL5EHYCYRTFUXfqTasbseQa7CYPoNEBc7gJQoGkaPAe7cLg4doKkZPqbD6tBhFbBLxE1jv3rwek.
You can create your own key pair by:

NEAR_ENV=mainnet near generate-key your-account-name

This creates a json keypair at ~/.near-credentials/mainnet/your-account-name.json. Consequently, when we invoke

const { getPublicKey, sign, verify, getExtendedPublicKey } = ed.sync;
getPublicKey(privKey);

We get the following error: Expected 32 bytes. We're open to suggestions for resolving the issue and migrating to a safer library.

@paulmillr
Copy link
Author

paulmillr commented Nov 23, 2023

paulmillr/noble-curves#33

write your own wrapper than converts into 64 byte keys. it takes 1 line of code. they are invalid and are NOT supported by FIPS 186-5 or relevant RFC.

also use noble-curves, not noble-ed25519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants