-
Notifications
You must be signed in to change notification settings - Fork 977
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
Replay protection wrong hash #1530
Comments
@grarco @Fraccaman Nice catch! My bad, I hadn't thought enough about the interaction between replay protection and the new transaction structure. You're solution seems to be the most straightforward, but I guess we need to account for an attacker maliciously replaying |
@murisi we could do that for sure, but I'm concern about the fact that we would include too many data into storage (replay protection is already taking a lot of space). Maybe some of those section dont need to be replay protected? For example, the |
@Fraccaman @grarco Agreed. We discussed elsewhere that maybe the What if we instead generate a single nonce for each transaction and include it in each transaction section? Network nodes would then put that nonce as a key into replay protection storage. This way: transaction sections are unreplayable, at most 2 entries are put into replay protection storage for a single transaction, and there would be no way for an attacker to make a transaction by recombining sections from other transactions (which may not have been played yet). This approach would bind all the sections of a transaction together and prevent even the signer of the wrapper transaction from, say, changing the code whilst leaving the data (signed by someone else) unchanged. |
So, this could actually work. My concerns are:
I was thinking that we might save the current hash-based replay protection mechanism by adding another Since we also save in storage the hash of the header, we'll be back at two hashes in storage which is what we used to have and seems to be fine in terms of space occupation. When we receive the tx we can check whether any of these hashes is already in storage and reject the tx as a replay attempt. If instead it's valid, we then decrypt the sections in the following block. Here we must check (in VP) that the signature over this "cumulated" hash is valid and that the hash itself is correct given the sections of the transaction. We also need to check that the signature on the hash comes from the same public key that signed the |
Actually, the commitment hash could be better place inside the |
Thanks to @Fraccaman, we found out that the new implementation of replay protection implemented in #1280 manages the wrapper tx correctly but fails to safely protect the inner tx. This is because we are currently taking the hash of the header which could be easily changed by modifying some less important fields (like the timestamp) to force multiple applications of the same wasm code and the associated data.
To fix it we should simply save in storage the hash of the data (which is already available in the header) together with the hash of the entire header (to protect the wrapper).
The text was updated successfully, but these errors were encountered: