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

Normalize ipfs gateway links to CIDs #83309

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

umar-ahmed
Copy link
Contributor

@umar-ahmed umar-ahmed commented Sep 17, 2024

  • Update clean:blocklist script to normalize and extract CIDs from IPFS subdomain gateway links
  • Run script to clean up existing config and remove some duplicates as a result
  • Add a test case to cover the IPFS normalization codepath

@umar-ahmed umar-ahmed marked this pull request as ready for review September 17, 2024 00:59
@umar-ahmed umar-ahmed changed the title chore: manually normalize ipfs links to CIDs chore: normalize ipfs links to CIDs Sep 17, 2024
@umar-ahmed umar-ahmed changed the title chore: normalize ipfs links to CIDs Normalize ipfs links to CIDs Sep 17, 2024
@umar-ahmed umar-ahmed changed the title Normalize ipfs links to CIDs Normalize ipfs gateway links to CIDs Sep 17, 2024
@mindofmar
Copy link
Contributor

Why do we want to only store the IPFS CIDs instead of the full URL? Will this break existing functionality?

@umar-ahmed
Copy link
Contributor Author

Why do we want to only store the IPFS CIDs instead of the full URL?

From my reading of the IPFS code merged into core, it looks like that's how they are expected to be stored in the blocklist.

We currently have duplicate entries in the blocklist as a result of not normalizing, and I'm frankly not even sure if the IPFS blocking is working as intended as a result.

Will this break existing functionality?

I think it will make the blocklist work more effectively for different gateways. So I'd consider this more of a bug fix than a breaking change.


Aside: One thing I didn't fix yet is normalizing the CIDs to a canonical version. It's probably best to normalize to CIDv1 because it has a case-insensitive base32 encoding (https://cid.ipfs.tech/#QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR). But to do this, the detector code in core will need to be updated as well to apply the same transformation from CIDv0 to CIDv1, so I've kept it out of scope for now

@mindofmar
Copy link
Contributor

@umar-ahmed ah I see. So the goal is to be able to block asdf as an IPFS CID regardless of whether a user navigates to it from ipfs.io/ipfs/asdf or asdf.ipfs.dweb.link?

@409H can you confirm that the Phishing Controller now supports just CID as input to block these as intended above?

@umar-ahmed
Copy link
Contributor Author

@umar-ahmed ah I see. So the goal is to be able to block asdf as an IPFS CID regardless of whether a user navigates to it from ipfs.io/ipfs/asdf or asdf.ipfs.dweb.link?

Yup 👍

Those should theoretically be the same content, just available at different gateways, so I think it makes most sense that EPD and PhishingController treat them as such for better coverage

Copy link
Collaborator

@409H 409H left a comment

Choose a reason for hiding this comment

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

lgtm

@409H
Copy link
Collaborator

409H commented Oct 16, 2024

@mindofmar yes looks like it was merged in https://github.com/MetaMask/core/blob/main/packages/phishing-controller/src/PhishingDetector.ts#L119 (MetaMask/phishing-controller@12.0.3)

@409H 409H self-requested a review October 16, 2024 17:59
Copy link
Collaborator

@409H 409H left a comment

Choose a reason for hiding this comment

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

We will wait to merge until rollout complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants