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

less permissive VPs #2213

Merged
merged 10 commits into from
Dec 29, 2023
Merged

less permissive VPs #2213

merged 10 commits into from
Dec 29, 2023

Conversation

tzemanovic
Copy link
Member

@tzemanovic tzemanovic commented Nov 23, 2023

Describe your changes

fixes #408

Unknown changes in vp_user and vp_implicit now require valid signature(s).

For PoS changes, we have to check against all possible storage changes that can be applied from a tx and require signature(s) for those that have to be authorized by the source (for vp_user it can be both delegator and validator actions, for vp_implicit only delegator actions). If the change within PoS account subspace is not recognized we default to require sig(s).

To ease debugging in vp_user and vp_implicit, I changed the logging of rejected keys to also be be emitted in release build.

Indicate on which release or other PRs this topic is based on

v0.28.0

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

tzemanovic added a commit that referenced this pull request Nov 23, 2023
@tzemanovic tzemanovic force-pushed the tomas/vp-less-permissive branch from 4df9a92 to cfee2cd Compare November 23, 2023 14:47
@tzemanovic tzemanovic marked this pull request as ready for review November 23, 2023 14:47
@tzemanovic tzemanovic marked this pull request as draft November 23, 2023 15:09
@tzemanovic
Copy link
Member Author

looks like lots of e2e tests are affected, looking into it

@tzemanovic tzemanovic force-pushed the tomas/vp-less-permissive branch from 31c3779 to e4bcccc Compare November 26, 2023 09:57
@tzemanovic tzemanovic marked this pull request as ready for review November 27, 2023 09:12
@tzemanovic tzemanovic marked this pull request as draft November 27, 2023 10:11
@tzemanovic
Copy link
Member Author

there are some more changes needed for IBC

@tzemanovic tzemanovic marked this pull request as ready for review November 27, 2023 16:14
});
if let Some(bond_id) = bond_id {
// Bonds and unbonds changes for this address must be signed
return &bond_id.source != owner || **valid_sig;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the &bond_id.source != owner still be here now? How do we enforce that a delegation is signed / truly submitted by the delegator?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe that’s what this does - if the source is eq to the owner then the sig is required

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah yes ok, forgot that this is now the VP for normal users and validators. So in the delegator's VP, the sig will be required, but in the validator's VP it won't be, as expected

Comment on lines 249 to 251
(None, Some(_post)) => {
// Becoming a validator must be authorized
**valid_sig
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe unnecessary, but should we have a address == owner && *valid_sig here too?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be better yes, though it won’t be an issue with our existing tx where it’s a single action

Comment on lines 271 to 282
let is_valid_reward_claim = || {
if let Some(bond_id) = storage::is_last_pos_reward_claim_epoch_key(key)
{
// Claims for this address must be signed
return &bond_id.source != owner || **valid_sig;
}
false
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to consider the rewards counter key?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes! Otherwise a claim might get rejected

Comment on lines +295 to +312
let is_valid_become_validator = || {
if storage::is_validator_addresses_key(key)
|| storage::is_consensus_keys_key(key)
|| storage::is_validator_eth_cold_key_key(key).is_some()
|| storage::is_validator_eth_hot_key_key(key).is_some()
|| storage::is_validator_max_commission_rate_change_key(key)
.is_some()
|| storage::is_validator_address_raw_hash_key(key).is_some()
{
// A signature is required to become validator
return **valid_sig;
}
false
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this look at the data in these keys from pre and post and be valid if the pres are None and posts are Some?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we don’t need to go that deep in here. The detailed PoS validation should happen in PoS VP and this VP should only be concerned with authorization

protocol_key,
commission_rate,
max_commission_rate_change,
email: "[email protected]".to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed

@brentstone brentstone mentioned this pull request Dec 6, 2023
@tzemanovic tzemanovic mentioned this pull request Dec 7, 2023
@tzemanovic tzemanovic force-pushed the tomas/vp-less-permissive branch from 8788f52 to 763ea16 Compare December 8, 2023 09:19
tzemanovic added a commit that referenced this pull request Dec 8, 2023
* tomas/vp-less-permissive:
  additions from comments
  wasm/vp_user+vp_implicit: update for IBC actions
  benches: fix foreign key write tx sigs
  wasm/vp_user+vp_implicit: always print rejected keys
  wasm/vp_user+vp_implicit: impl PoS key checks
  changelog: add #2213
  wasm/vp_implicit: require valid sig for unknown changes
  wasm/vp_user: require valid sig for unknown changes
  wasm/vp_implicit: port Masp and PgfSteward key handling from vp_user
  wasm/vp_user: fix a typo
brentstone added a commit that referenced this pull request Dec 29, 2023
* origin/tomas/vp-less-permissive:
  additions from comments
  wasm/vp_user+vp_implicit: update for IBC actions
  benches: fix foreign key write tx sigs
  wasm/vp_user+vp_implicit: always print rejected keys
  wasm/vp_user+vp_implicit: impl PoS key checks
  changelog: add #2213
  wasm/vp_implicit: require valid sig for unknown changes
  wasm/vp_user: require valid sig for unknown changes
  wasm/vp_implicit: port Masp and PgfSteward key handling from vp_user
  wasm/vp_user: fix a typo
@brentstone brentstone merged commit c6b3f39 into main Dec 29, 2023
@brentstone brentstone deleted the tomas/vp-less-permissive branch December 29, 2023 19:37
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.

vp_user: consider being less permissive on unknown keys
2 participants