Skip to content

Require required hash fields (security improvement)#1818

Merged
thealligatorking merged 7 commits intoopentensor:stagingfrom
backend-developers-ltd:require_required_hash_fields
May 22, 2024
Merged

Require required hash fields (security improvement)#1818
thealligatorking merged 7 commits intoopentensor:stagingfrom
backend-developers-ltd:require_required_hash_fields

Conversation

@mjurbanski-reef
Copy link
Contributor

Previous implementation allowed complete bypass of body_hash checks. This PR fixes it.

This is more-or-less breaking change.

I say more-or-less, since, for most it should work without any trouble. Even if they don't update their side of the network. It will just mean they will be still vulnerable, but their nodes will still be able to communicate with the updated nodes.

Fixed issues

  • required_hash_fields no longer can be overridden (enabling hash bypass) by the remote node
  • all required_hash_fields are now STRICTLY required, i.e. if subnet developer, like in filetao, made a typo and had weaker hash because of it, now the code will immediately explode instead of issue going unnoticed for a long time

Breaking changes

  • If someone expected a required_hash_fields pydantic field in bittensor.Synapse, they will no longer find it - IDK how much code out there uses it directly. Seeing the amount of copy&pasting going on in bittensor community, probably some does.
  • Unused axon.required_hash_fields mapping got removed (again, should not affect people in theory, but likely someone will be)

Otherwise, there is some support for legacy subclasses of Synapse, i.e. if they define required_hash_fields pydantic fields, we will use it as usual.

Upgrade steps

  • make sure you are not affected by breaking changes listed above
  • make sure when redefining required_hash_fields as Synapse ClassVar, to list your field names in order of their definition, as otherwise you will get different hash values than before i.e. break compatibility across updated/unupdated nodes. Also if you had a typo in a field name, just don't add it if you don't want to break compatiblity with unupdated nodes.

@thealligatorking
Copy link
Contributor

@mjurbanski-reef thank you for the contribution. Since this introduces breaking changes we will be reviewing and getting back to you.

@thealligatorking
Copy link
Contributor

@mjurbanski-reef we plan on getting this into 7.0.0

@mjurbanski-reef
Copy link
Contributor Author

@gus-opentensor did plan change? I see #1899 was opened without this

@mjurbanski-reef
Copy link
Contributor Author

@gus-opentensor @opendansor solved the conflicts caused by pydantic v2 PR, can we get this security fix merged so I don't have to keep redoing it?

@thealligatorking thealligatorking merged commit 87df079 into opentensor:staging May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants