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

Fix audit feedback on committee creation #16909

Merged
merged 2 commits into from
Mar 28, 2024
Merged

Conversation

dariorussi
Copy link
Contributor

Description

As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee.
Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem.
This should prevent the problem from happeing.

Test Plan

Added unit test


If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 9:16pm
multisig-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 9:16pm
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 9:16pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 9:16pm
sui-kiosk ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 9:16pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 9:16pm

// `try_create_next_committee` will abort if bridge_pubkey_bytes are not unique and
// that will fail the end of epoch transaction (possibly "forever", well, we
// need to deploy proper validator changes to stop end of epoch from failing).
assert!(check_uniqueness_bridge_keys(self, bridge_pubkey_bytes), EDuplicatePubkey);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could just call the API here and have the assert inside check_uniqueness_bridge_keys
if anybody feels strongly about it let me know

Copy link
Contributor

Choose a reason for hiding this comment

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

assert inside check_uniqueness_bridge_keys is slightly preferential to me, but not a strong opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

test_utils::destroy(committee);
test_scenario::return_shared(system_state);
test_scenario::end(scenario);
Copy link
Contributor

@manolisliolios manolisliolios Mar 28, 2024

Choose a reason for hiding this comment

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

nit: You could avoid non-needed code on failure-expecting tests by aborting (abort 1337)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could, just leaving that in line with the other tests.
Having said so and given I need to review tests and code coverage I may apply that story to all existing tests in that future PR.
Thanks for the hint, I keep forgetting that and go trough tricks every time I write tests :)

Copy link
Contributor

Choose a reason for hiding this comment

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

til

Comment on lines 187 to 191
if (registration.bridge_pubkey_bytes == bridge_pubkey_bytes) {
if (found) {
return false
};
found = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd probably pass down the sender's address too and check as the "found" thing messed with my brain (but could be me malfunctioning)

if (registration.bridge_pubkey_bytes == bridge_pubkey_bytes && registration.sui_address != sender ) { return false }

Copy link
Contributor Author

@dariorussi dariorussi Mar 28, 2024

Choose a reason for hiding this comment

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

not sure I follow, the found is to make sure that bridge_pubkey_bytes is unique in the list of proposed committee upgrade.
I may be missing something here

Copy link
Contributor

Choose a reason for hiding this comment

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

it messed with my brain as well and could be me malfunctioning too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed the field and added comments that should hopefully help fix the confusion

Copy link
Contributor

@manolisliolios manolisliolios left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -164,9 +165,35 @@ module bridge::committee {
registration
};

// check uniqeuness of the bridge pubkey.
Copy link
Contributor

Choose a reason for hiding this comment

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

uniqueness

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

// `try_create_next_committee` will abort if bridge_pubkey_bytes are not unique and
// that will fail the end of epoch transaction (possibly "forever", well, we
// need to deploy proper validator changes to stop end of epoch from failing).
assert!(check_uniqueness_bridge_keys(self, bridge_pubkey_bytes), EDuplicatePubkey);
Copy link
Contributor

Choose a reason for hiding this comment

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

assert inside check_uniqueness_bridge_keys is slightly preferential to me, but not a strong opinion

Comment on lines 187 to 191
if (registration.bridge_pubkey_bytes == bridge_pubkey_bytes) {
if (found) {
return false
};
found = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

it messed with my brain as well and could be me malfunctioning too.

test_utils::destroy(committee);
test_scenario::return_shared(system_state);
test_scenario::end(scenario);
Copy link
Contributor

Choose a reason for hiding this comment

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

til

@dariorussi dariorussi merged commit d5346e7 into feature/native-bridge Mar 28, 2024
45 checks passed
@dariorussi dariorussi deleted the bridge_reg branch March 28, 2024 21:51
patrickkuo pushed a commit that referenced this pull request May 2, 2024
## Description

As reported by audit if a validator registers with an already used
pubkey for the bridge (whether maliciously or not) the creation of the
committee will fail and as such an end of epoch would fail attempting to
create the committee.
Moreover there is no way at the moment to flush the proposed committee
(in that respect, should we have an API for it?) and it would require an
emergency release to take care of the problem.
This should prevent the problem from happeing.

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
patrickkuo pushed a commit that referenced this pull request May 8, 2024
## Description

As reported by audit if a validator registers with an already used
pubkey for the bridge (whether maliciously or not) the creation of the
committee will fail and as such an end of epoch would fail attempting to
create the committee.
Moreover there is no way at the moment to flush the proposed committee
(in that respect, should we have an API for it?) and it would require an
emergency release to take care of the problem.
This should prevent the problem from happeing.

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
patrickkuo pushed a commit that referenced this pull request May 9, 2024
## Description

As reported by audit if a validator registers with an already used
pubkey for the bridge (whether maliciously or not) the creation of the
committee will fail and as such an end of epoch would fail attempting to
create the committee.
Moreover there is no way at the moment to flush the proposed committee
(in that respect, should we have an API for it?) and it would require an
emergency release to take care of the problem.
This should prevent the problem from happeing.

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
patrickkuo pushed a commit that referenced this pull request May 9, 2024
## Description

As reported by audit if a validator registers with an already used
pubkey for the bridge (whether maliciously or not) the creation of the
committee will fail and as such an end of epoch would fail attempting to
create the committee.
Moreover there is no way at the moment to flush the proposed committee
(in that respect, should we have an API for it?) and it would require an
emergency release to take care of the problem.
This should prevent the problem from happeing.

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
patrickkuo pushed a commit that referenced this pull request May 9, 2024
## Description

As reported by audit if a validator registers with an already used
pubkey for the bridge (whether maliciously or not) the creation of the
committee will fail and as such an end of epoch would fail attempting to
create the committee.
Moreover there is no way at the moment to flush the proposed committee
(in that respect, should we have an API for it?) and it would require an
emergency release to take care of the problem.
This should prevent the problem from happeing.

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
patrickkuo pushed a commit that referenced this pull request May 9, 2024
## Description

As reported by audit if a validator registers with an already used
pubkey for the bridge (whether maliciously or not) the creation of the
committee will fail and as such an end of epoch would fail attempting to
create the committee.
Moreover there is no way at the moment to flush the proposed committee
(in that respect, should we have an API for it?) and it would require an
emergency release to take care of the problem.
This should prevent the problem from happeing.

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
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.

3 participants