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

Bump deps (signatory/stdtx/k256/tendermint/yubihsm) #162

Merged
merged 1 commit into from
Oct 13, 2020

Conversation

tony-iqlusion
Copy link
Member

@tony-iqlusion tony-iqlusion commented Oct 13, 2020

Upgrades the following dependencies to the latest versions:

  • signatory v0.22.0
  • stdtx v0.3.0
  • k256 v0.5.9
  • tendermint v0.16.0
  • yubihsm v0.35.0-rc

This commit also moves away from Signatory-based abstractions in several places, leaning more directly on ed25519-dalek and the k256 crate, the latter of which now contains full ECDSA/secp256k1 support. Additionally, it completely removes use of signatory-dalek and rust-secp256k1/signatory-secp256k1.

The rationale is that ed25519-dalek has natively adopted the Signer and Verifier traits which Signatory originally provided, which eliminates the need to use it through an abstraction layer/wrapper. The signatory-dalek crate has also since been retired.

@tarcieri tarcieri force-pushed the update-signatory-stdtx-k256-yubihsm branch from 1f5ed87 to ad7abd0 Compare October 13, 2020 00:21
@tony-iqlusion
Copy link
Member Author

tony-iqlusion commented Oct 13, 2020

Getting some Secret Connection-related failures in the test suite:

error: client 'test_chain_id@tcp://127.0.0.1:62538' exited with error: cryptographic error

failures:
    test_handle_and_sign_ping_pong
    test_handle_and_sign_proposal
    test_handle_and_sign_vote

Will investigate (or would appreciate any help)

@tony-iqlusion
Copy link
Member Author

tony-iqlusion commented Oct 13, 2020

I've found the cause of the Secret Connection failures, and it appears to be a somewhat confusing (non-critical) bug in the original code which previously didn't cause a breakage due to lack of Ed25519 point decompression:

https://github.com/iqlusioninc/tmkms/blob/d48c961/src/connection/secret_connection.rs#L131-L134

These lines are attempting to parse an ephemeral X25519 public key as an Ed25519 one. This just simply appears to be the wrong key: the remote_pubkey for SecretConnection intended to be the Ed25519 identity key, not the remote X22519 ECDHE ephemeral public key.

When the handshake completes, it's overwritten with the correct key here:

https://github.com/iqlusioninc/tmkms/blob/d48c961/src/connection/secret_connection.rs#L170-L171

This succeeded before because it was using Signatory's ed25519::PublicKey type, which does not decompress points and therefore silently ignored the invalid point. Switching to ed25519_dalek::PublicKey, the problem now surfaces, as the point is failing to decompress.

I'll open a branch that attempts to fix just this issue.

Edit: opened #164 which appears to address the issue, and rebased this PR on it.

tarcieri pushed a commit that referenced this pull request Oct 13, 2020
The `SecretConnection { remote_pubkey }` field is intended to store the
remote peer's static Ed25519 identity key.

However, during the AKE verification process, it was previously
temporarily initialized to the remote peer's ephemeral X25519 key.
This only worked because previously it's using Signatory's
`ed25519::PublicKey` type, which does not apply point decompression
(as that involves solving the curve equation, which requires a basic
curve arithmetic backend).

However, this did cause sporadic failures in the Secret Connection AKE
after attempting to switch this key type out for ed25519-dalek's
`PublicKey` type, which does decompress points (#162). This caused
sporadic failures whever the X25519 ephemeral key failed to decompress
as an Ed25519 public key (which is mere coincidence, as attempting to do
so makes no sense mathematically).

This commit changes `remote_pubkey` to an `Option` and doesn't attempt
to store any key until validated. This is perhaps needlessly fallible,
but at least addresses the immediate problem.

There doesn't appear to be any immediate security impact from this:
while in combination with other bugs it could potentially be used to
forge an identity key, the keys are cryptographically validated by
subsequent steps, and any failure to validate them aborts the handshake.
Upon success, the identity key is always overwritten with the correct
one. A security vulnerability would require some way to successfully
complete the handshake in spite of the cryptographic errors and without
the key being overwritten.
@tarcieri tarcieri force-pushed the update-signatory-stdtx-k256-yubihsm branch from ad7abd0 to 4f692dd Compare October 13, 2020 14:32
@tony-iqlusion tony-iqlusion changed the title [WIP] Bump deps (signatory/stdtx/k256/yubihsm) Bump deps (signatory/stdtx/k256/tendermint/yubihsm) Oct 13, 2020
@tony-iqlusion tony-iqlusion marked this pull request as ready for review October 13, 2020 14:34
@tarcieri tarcieri force-pushed the update-signatory-stdtx-k256-yubihsm branch 2 times, most recently from b486ffd to 1cfc62e Compare October 13, 2020 15:16
@codecov-io
Copy link

Codecov Report

Merging #162 into develop will increase coverage by 0.32%.
The diff coverage is 29.20%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #162      +/-   ##
===========================================
+ Coverage    22.64%   22.97%   +0.32%     
===========================================
  Files           60       61       +1     
  Lines         2446     2429      -17     
===========================================
+ Hits           554      558       +4     
+ Misses        1892     1871      -21     
Impacted Files Coverage Δ
src/commands/softsign/import.rs 0.00% <0.00%> (ø)
src/commands/softsign/keygen.rs 0.00% <0.00%> (ø)
src/commands/yubihsm/keys/import.rs 0.00% <0.00%> (ø)
src/commands/yubihsm/keys/list.rs 0.00% <0.00%> (ø)
src/config/validator.rs 0.00% <ø> (ø)
src/connection/tcp.rs 0.00% <0.00%> (ø)
src/keyring/ecdsa.rs 0.00% <ø> (ø)
src/keyring/providers/ledgertm.rs 0.00% <0.00%> (ø)
src/keyring/providers/softsign.rs 0.00% <0.00%> (ø)
src/keyring/providers/yubihsm.rs 0.00% <0.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14edb4e...1cfc62e. Read the comment docs.

@tarcieri tarcieri force-pushed the update-signatory-stdtx-k256-yubihsm branch 2 times, most recently from 919cdf1 to 4fe5186 Compare October 13, 2020 15:57
Upgrades the following dependencies to the latest versions:

- `signatory` v0.22.0
- `stdtx` v0.3.0
- `k256` v0.5.9
- `tendermint` v0.16.0
- `yubihsm` v0.35.0-rc

This commit also moves away from Signatory-based abstractions in several
places, leaning more directly on `ed25519-dalek` and the `k256` crate,
the latter of which now contains full ECDSA/secp256k1 support.
Additionally, it completely removes use of `signatory-dalek` and
`rust-secp256k1`/`signatory-secp256k1`.

The rationale is that ed25519-dalek has natively adopted the `Signer`
and `Verifier` traits which Signatory originally provided, which
eliminates the need to use it through an abstraction layer/wrapper.
The `signatory-dalek` crate has also since been retired.
@tarcieri tarcieri force-pushed the update-signatory-stdtx-k256-yubihsm branch from 4fe5186 to a603499 Compare October 13, 2020 16:17
@tony-iqlusion tony-iqlusion merged commit 94d2c26 into develop Oct 13, 2020
@tony-iqlusion tony-iqlusion deleted the update-signatory-stdtx-k256-yubihsm branch October 13, 2020 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants