Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Problem (WIP #1616): keypackage not verified in nodejointx / council node data #1668

Merged
merged 1 commit into from
May 27, 2020

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented May 26, 2020

Solution:

  • record most recent isv_svn, warn when a new version appears
  • add mock data and fix unit/integration tests temporarily.

TBD: generate real keypackage when construct node-join tx, or prepare genesis.

@yihuang yihuang force-pushed the issue1616 branch 6 times, most recently from c96f316 to cfca8dc Compare May 26, 2020 16:27
@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #1668 into master will increase coverage by 4.62%.
The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master    #1668      +/-   ##
==========================================
+ Coverage   67.23%   71.86%   +4.62%     
==========================================
  Files         191      184       -7     
  Lines       23516    21908    -1608     
==========================================
- Hits        15811    15744      -67     
+ Misses       7705     6164    -1541     
Impacted Files Coverage Δ
...in-tx-enclave-next/enclave-ra/ra-client/src/lib.rs 100.00% <ø> (ø)
chain-tx-enclave-next/mls/src/lib.rs 100.00% <ø> (ø)
client-rpc/src/rpc/staking_rpc.rs 0.00% <0.00%> (ø)
dev-utils/src/commands/init_command.rs 0.00% <0.00%> (ø)
chain-core/src/init/config.rs 78.89% <58.97%> (+0.80%) ⬆️
chain-abci/src/app/app_init.rs 81.96% <76.92%> (-0.40%) ⬇️
chain-abci/src/staking/tx.rs 90.98% <80.00%> (+0.30%) ⬆️
...-enclave-next/enclave-ra/ra-client/src/verifier.rs 44.20% <83.33%> (-1.19%) ⬇️
test-common/src/block_generator.rs 88.60% <88.88%> (+0.25%) ⬆️
chain-abci/src/app/mod.rs 83.92% <100.00%> (+0.07%) ⬆️
... and 27 more

Comment on lines 27 to 29
mut recent_isv_svn: u16,
tx: &NodeJoinRequestTx,
) -> Result<(), PublicTxError> {
) -> Result<u16, PublicTxError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it needs it mut when it also returns it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll get assigned if info.quote.report_body.isv_svn > recent_isv_svn, and returned at the end.

Copy link
Collaborator

@leejw51crypto leejw51crypto May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about
recent_isv_svn:&mut u16 ?
for readibility

changing recent_isv_svn inside this function can be error-prone,
can be refactored using tutple?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used a new variable to return now, it would be less confusing.

@@ -19,7 +19,8 @@ impl<'a> EnclaveCertVerifierConfig<'a> {
pub fn new() -> Self {
Self {
signing_ca_cert_pem: IAS_CERT.into(),
valid_enclave_quote_statuses: vec!["OK".into()].into(),
// FIXME remove SW_HARDENING_NEEDED after https://github.com/rust-lang/llvm-project/pull/58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SW_HARDENING_NEEDED will still appear as a response, so it may not be possible to remove it ("OK" or "UP-TO-DATE" will only appear on unaffected platforms which are only some very recent CPUs, i.e. mid-2019 and newer) -- it's more of a reminder that one should apply those software hardening measures: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#mitigationguidelines

Since it affects many platforms, applying the mitigations and releasing only one version with them for all platforms is ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, then OK, UP-TO-DATE, SW_HARDENING_NEEDED all should be considered as valid responses?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API docs (https://api.trustedservices.intel.com/documents/sgx-attestation-api-spec.pdf) don't mention "UP-TO-DATE" (it's only mentioned in that LVI mitigation article), so perhaps only "OK" and "SW_HARDENING_NEEDED"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -24,9 +24,9 @@ impl StakingTable {
heap: &mut impl StoreStaking,
block_time: Timespec,
max_evidence_age: Timespec,
ra_verifier: &EnclaveCertVerifier,
mut recent_isv_svn: u16,
Copy link
Collaborator

@leejw51crypto leejw51crypto May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some full-word comment about "isv_svn" would be useful,
or consider full word variable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeJoin {
address: StakedStateAddress,
council_node: CouncilNode,
/// most recent isv_svn
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this remark for documentation?
// ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@leejw51crypto leejw51crypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -2,85 +2,61 @@ use crate::common::Timespec;
use crate::init::address::RedeemAddress;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one note that genesis processing may need more thought / design: crypto-org-chain/chain-docs#141 (comment)

@yihuang yihuang force-pushed the issue1616 branch 2 times, most recently from 70c427e to 44d7a67 Compare May 27, 2020 03:01
@tomtau
Copy link
Contributor

tomtau commented May 27, 2020

bors r+

bors bot added a commit that referenced this pull request May 27, 2020
1668: Problem (WIP #1616): keypackage not verified in nodejointx / council node data r=tomtau a=yihuang

Solution:
- record most recent isv_svn, warn when a new version appears
- add mock data and fix unit/integration tests temporarily.

TBD: generate real keypackage when construct node-join tx, or prepare genesis.

Co-authored-by: yihuang <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 27, 2020

Build failed:

@tomtau tomtau self-requested a review May 27, 2020 03:58
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-docker-app-hash.sh related stuff + fuzzer may also need updating?

@yihuang yihuang force-pushed the issue1616 branch 2 times, most recently from 9e7c685 to 5f1020b Compare May 27, 2020 04:40
@tomtau
Copy link
Contributor

tomtau commented May 27, 2020

bors r+

bors bot added a commit that referenced this pull request May 27, 2020
1668: Problem (WIP #1616): keypackage not verified in nodejointx / council node data r=tomtau a=yihuang

Solution:
- record most recent isv_svn, warn when a new version appears
- add mock data and fix unit/integration tests temporarily.

TBD: generate real keypackage when construct node-join tx, or prepare genesis.

Co-authored-by: yihuang <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 27, 2020

Canceled.

@@ -0,0 +1,3908 @@
# This file is automatically @generated by Cargo.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed? or could this go to .gitignore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think general guideline is like libraries should ignore Cargo.lock but binaries/applications should check-in Cargo.lock, I guess fuzz can be considered as application?

Copy link
Collaborator Author

@yihuang yihuang May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can put the fuzz crate in workspace, it'll share the same Cargo.lock file?

EDIT: oh, fuzz itself is a workspace.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the lock file.

@tomtau
Copy link
Contributor

tomtau commented May 27, 2020

@yihuang
Copy link
Collaborator Author

yihuang commented May 27, 2020

A few clippy suggestions: https://travis-ci.org/github/crypto-com/chain/jobs/691601119#L1686

Done

@yihuang yihuang requested a review from tomtau May 27, 2020 07:14
…/ council node data

Solution:
- record most recent isv_svn in chain state, warn when a new version appears
- use mock keypackage and make unit/integration tests running
  tempararily
@tomtau
Copy link
Contributor

tomtau commented May 27, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented May 27, 2020

Build succeeded:

@bors bors bot merged commit 9018951 into crypto-com:master May 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants