-
Notifications
You must be signed in to change notification settings - Fork 29
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
network/marshal: fix ServerIdentity unmarshalling #607
network/marshal: fix ServerIdentity unmarshalling #607
Conversation
The server identity ID is deterministic so instead of including the value in the serialization/deserialization, it should be gotten through a getter that generates the value on the fly. The field shouldn't exist but backward compatibility reason, it shall remain there. |
So, what do we do? Do we break compatibility for the sake of security (which I'm all for)? I don't see a golang way to add a getter on a value that would allow this kind of checking. |
I guess for the moment, a deprecation notice on the ID field and add a Breaking compatibility is not an option for sure even if it's clearly not an ideal situation. The field should still be filled with the actual ID value unfortunately. |
Hum, I'm looking at how to check for So, I'm proposing the following:
|
This PR should only include the second point of your list:
For the other two, please open two issues |
Adding the staticcheck pass is followed in dedis/Coding#5 |
So yeah, github crashed and that's probably why the tests ran again and failed. Also, I've rebase it on master. |
PR failing on purpose (for now).
ServerIdentity
is not checked for consistency when unmarshaling. As such, one can create an invalid one, send it accross network and it won't be checked when deserializing it, which can yield security issues (unchecked attacker-controlled input).To fix that, one would implement
encoding.BinaryUnmarshaler
, which I'm trying to do now, but I need some help coding it, if someone has the time :)So, I'm adding
func (si *ServerIdentity) UnmarshalBinary(data []byte) error
; as I just want to fix ID after most deserialisation is done, I'm trying first toUnmarshal
orprotobuf.Decode{,WithConstructors}
, which in turn callsUnmarshalBinary
as it can now be casted toencoding.BinaryUnmarshaler
:/And I don't want to redo protobuf decoding by hand, so, is there a way I'm missing?
A workaround that might work is to have a
ServerIdentityWrapper
which is also registered in onet and is trivialy always correct (removed the ID field), but that still allow people to send brokenServerIdentity
and is quite an API-breaking change.