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

Add KMS functionality #417

Merged
merged 20 commits into from
Jun 14, 2022
Merged

Add KMS functionality #417

merged 20 commits into from
Jun 14, 2022

Conversation

torao
Copy link
Contributor

@torao torao commented May 20, 2022

Description

This PR enables the use of a secure KMS (Key Management System) from Ostracon.

Currently, the key pairs used by Ostracon for agreements are stored locally. But Ostracon nodes are at risk of having their private keys stolen when a malicious attacker breaks into the system since they must accept inbound connections from the Internet.

For more mission-critical applications, such as finance, the node storing the private key must be independent of the Ostracon agreement node, placed behind a firewall, and able to connect to solutions using an HSM (Hardware Security Module) or our SGX solution.

Tendermint, a fork of Ostracon, has the ability to connect to KMS using tmkms communication protocol. Note, however, that the init and unsafe-reset-priv-validator subcommands of the Tendermint CLI are not designed to configure KMS, and this PR still requires copying the public key stored in the KMS to a local key file. Thus, you should be set up as follows if you use your KMS:

  1. Create an initial configuration with the ostracon init command.
  2. In ~/.ostracon/config/priv_validator_key.json, replace pubkey/value field with the Base64 representation of the public key stored in KMS.
  3. In ~/.ostracon/config/genesis.json, replace the validators/address and validators/pubkey/value fields with the values from the KSM public key in the same way if the node is the initial validator.

This PR contains the following changes:

  • Connection test with KSM at the library level. This is a program that starts with main() instead of a unit test.
  • ostracon run: Removed the behavior of referencing local key pair when priv_validator_laddr is set.
  • ostracon show-validator: Changed to get and display KSM public key when priv_validator_laddr is set.

@codecov
Copy link

codecov bot commented May 20, 2022

Codecov Report

Merging #417 (dd07f9b) into main (f19316f) will increase coverage by 0.19%.
The diff coverage is 93.47%.

@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
+ Coverage   65.28%   65.48%   +0.19%     
==========================================
  Files         277      278       +1     
  Lines       37842    37926      +84     
==========================================
+ Hits        24707    24835     +128     
+ Misses      11321    11285      -36     
+ Partials     1814     1806       -8     
Impacted Files Coverage Δ
cmd/ostracon/commands/show_validator.go 72.72% <82.35%> (+72.72%) ⬆️
config/toml.go 74.19% <100.00%> (+0.86%) ⬆️
node/node.go 60.12% <100.00%> (+0.87%) ⬆️
privval/test_util.go 100.00% <100.00%> (ø)
statesync/snapshots.go 93.71% <0.00%> (-1.26%) ⬇️
mempool/reactor.go 78.57% <0.00%> (-1.10%) ⬇️
p2p/switch.go 65.90% <0.00%> (-0.62%) ⬇️
light/client.go 61.61% <0.00%> (-0.45%) ⬇️
consensus/reactor.go 75.02% <0.00%> (+0.08%) ⬆️
consensus/state.go 73.96% <0.00%> (+0.29%) ⬆️
... and 7 more

@torao torao force-pushed the feature/apply-kms branch 3 times, most recently from 3dc95c0 to 1da6733 Compare May 20, 2022 06:47
@Kynea0b Kynea0b added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label May 20, 2022
@torao torao force-pushed the feature/apply-kms branch 5 times, most recently from 080b18a to c3c36c5 Compare May 20, 2022 12:55
@torao torao changed the title Add Test for KMS Add KMS functionality May 20, 2022
@torao torao force-pushed the feature/apply-kms branch 8 times, most recently from 0d90d4c to ab25481 Compare May 24, 2022 05:07
@torao torao marked this pull request as ready for review May 24, 2022 06:47
@torao torao requested review from Kynea0b and tnasu as code owners May 24, 2022 06:47
node/node_test.go Outdated Show resolved Hide resolved
cmd/ostracon/commands/init.go Outdated Show resolved Hide resolved
cmd/ostracon/commands/run_node_test.go Outdated Show resolved Hide resolved
cmd/ostracon/commands/run_node_test.go Outdated Show resolved Hide resolved
cmd/ostracon/commands/show_validator.go Show resolved Hide resolved
cmd/ostracon/commands/show_validator.go Show resolved Hide resolved
cmd/ostracon/commands/show_validator.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/toml.go Show resolved Hide resolved
cmd/ostracon/commands/kms_test.go Outdated Show resolved Hide resolved
@torao torao force-pushed the feature/apply-kms branch 4 times, most recently from 62f29d2 to f898e61 Compare June 9, 2022 09:20
node/node_test.go Outdated Show resolved Hide resolved
node/node_test.go Outdated Show resolved Hide resolved
cmd/ostracon/commands/show_validator_test.go Show resolved Hide resolved
cmd/ostracon/commands/show_validator_test.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants