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

cid-sec: fix bitswap strom caused by insecure CIDs #4946

Merged
merged 3 commits into from
Apr 20, 2018

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Apr 18, 2018

When we introduced CID security we didn't take into account that bitswap
might repeatedly try getting the objects from the network if it fails
putting them into the blockstore.

A solution from this is not requesting those objects from bitswap.
The proper solution of failing at CID creation will make it much more
cleaner in future.

License: MIT
Signed-off-by: Jakub Sztandera kubuxu@protonmail.ch

@ghost ghost assigned Kubuxu Apr 18, 2018
@ghost ghost added the status/in-progress In progress label Apr 18, 2018
@Kubuxu Kubuxu added need/review Needs a review and removed status/in-progress In progress labels Apr 18, 2018
@Kubuxu Kubuxu requested a review from Stebalien April 18, 2018 14:47
for _, c := range ks {
// hash security
if err := verifcid.ValidateCid(c); err != nil {
log.Errorf("unsafe CID (%s) passed to blockService.GetBlocks: %s", c, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the right solution to this might be to just add a return of a closed block channel after the error here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, a file might have an unsafe block near the end of a file, most of the file should be OK to read. Just the end might be bad.

That is why I sort out the unsafe CIDs and fetch and/or read only the good ones.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a sharness test be possible?

@Kubuxu
Copy link
Member Author

Kubuxu commented Apr 19, 2018

@Stebalien I will try.

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
@ghost ghost added the status/in-progress In progress label Apr 20, 2018
When we introduced CID security we didn't take into account that bitswap
might repeatly try getting the objects from the network if it fails
putting them into the blockstore.

Solution from this is not requesting those objects from bitswap.
The proper solution of failing at CID creation will make in much more
cleaner in future.

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@Kubuxu Kubuxu added RFM and removed status/in-progress In progress need/review Needs a review labels Apr 20, 2018
@whyrusleeping whyrusleeping merged commit 8b383da into master Apr 20, 2018
@whyrusleeping whyrusleeping deleted the fix/cidsec-bitswapstorm branch April 20, 2018 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants