Blocks Integrity


I was wondering if IPFS implemented some kind of security regarding blocks integrity when they are received from a peer.

It is possible that someone send me a “wrong block” and if that happens can my node detect it ?


Yes, IPFS’s CID contain cryptographic hashes of the block.
you can put it in to decode them and the see the hash.

When you download a block, IPFS will hash the data, ensure it’s matching the expected CID.
If it’s not I belive the node is “punished” (you will try to download less data from it maybe even ban it) but this part of the code probably isn’t very well tested.

The worst that can happen is someone send you bad blocks and you keep refusing them.
The best that can happen is you ban them and wont talk to them anymore.

Thank you for your time @Jorropo :smiley: