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

Require required hash fields (security improvement) #1818

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.

@gus-opentensor
Copy link
Collaborator

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

@gus-opentensor
Copy link
Collaborator

@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

bittensor/synapse.py Outdated Show resolved Hide resolved
@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?

@gus-opentensor gus-opentensor merged commit 87df079 into opentensor:staging May 22, 2024
11 checks passed
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.

None yet

3 participants