CESSProject / cess

An implementation of the distributed storage network supported by CESS LAB.

Home Page:https://www.cess.cloud/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SBP: Review all your hashers in storage

NachoPal opened this issue · comments

I noticed that you are using Twox64Concat by default for all your StorageMap keys. Be aware of the potential issues of choosing the incorrect hasher.

From: https://docs.substrate.io/v3/advanced/cryptography/#xxhash

Because xxHash is not cryptographically secure, it is possible that the output of the hash algorithm can be reasonably controlled by modifying the input. This can allow a user to attack this algorithm by creating key collisions, hash collisions, and imbalanced storage tries.
xxHash is used in places where outside parties cannot manipulate the input of the hash function. For example, it is used to generate the key for runtime storage values, whose inputs are controlled by the runtime developer.

For those keys that are under the user's control, Blake2 should be used instead.

E.g: File name is under user's control
https://github.com/CESSProject/cess/blob/main/c-pallets/file-bank/src/lib.rs#L258

Thank you for your suggestion. We have now modified hasher to change twox64concat to blake2: (#58)