MetaMask / MetaMask/metamask-extension

Fully prevent the use of path-based IPFS gateways

Open
#7,698 0 comments 1 reaction 0 assignees View on GitHub
area-name-systems type-enhancement type-security
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

Currently, we allow users to set whatever IPFS gateway they want except `gateway.ipfs.io`. We should prevent all path-based gateways by implementing the fix suggested below.

_[Original comment](https://github.com/MetaMask/metamask-extension/pull/7362#discussion_r357377132) by @lidel:_

To make this more bullet proof, you could add a quick validation, to ensure provided hostname is a real [subdomain gateway](https://docs.ipfs.io/guides/guides/addressing/#subdomain-gateway), and refuse to save invalid ones.

Try fetching a small, well-known hash (for example: string `hello` is `bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am`) and see if returned value matches expectations:

https://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link
https://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.cf-ipfs.com
This would also protect you from users setting [path-based gateways](https://docs.ipfs.io/guides/guides/addressing/#path-gateway) (which do not provide Origin-based isolation.)

Contributor guide

Open the contributing guide

Research direction

The issue does not name a file or test. Start at the setting and save path for custom IPFS gateways; validate the hostname as a subdomain gateway and use the provided CID to confirm the expected “hello” response. Done means path-based gateways are rejected while valid subdomain gateways remain usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.