Cloudflare opens up IPFS Safemode to help keep the distributed web safer
Cloudflare has released new secure filtering capabilities for its IPFS infrastructure, and is open-sourcing the underlying software so other node operators can deploy the same protections. The code is available on github.com/cloudflare/go-ipfs.
The InterPlanetary FileSystem (IPFS) is a peer-to-peer network for storing and relaying content across a distributed file system. Anyone can operate a node using modest hardware, from a Raspberry Pi to a browser session. The network's resilience comes from this decentralization — no single node is a point of failure. But it also means that infrastructure providers have had to figure out how to keep users safe from malicious content that may circulate on the network.
The challenge of filtering a content-addressed network
An IPFS node serves content through two distinct interfaces. Through the P2P network, it responds to peers using libp2p protocols. Through an HTTP gateway — like Cloudflare's cloudflare-ipfs.com — it serves content to regular web users. When retrieving content from the network, a node that doesn't have what a peer requests can relay information about which other peers might have it, rather than serving the content itself.
Public gateways like Cloudflare's operate under a different model: they allow any internet user to retrieve arbitrary content from IPFS. Filtering requests for known malicious content at this HTTP layer works like any existing web protection. But the P2P layer doesn't use URLs. IPFS is content-addressed, meaning peers request content by its Content Identifier (CID) rather than a location, like the hash QmXnnyufdzAWL5CqZ2RnSNgPbvCc1ALT73s6epPrRnZ1Xy. A CID is a cryptographically verifiable reference to a specific piece of content.
This addressing scheme has an additional property: content can be reused across directories and composite objects without duplication. A file may be referenced by many different directories, each with its own CID. That creates a subtle filtering challenge. If malicious content is embedded within a larger collection, the whole collection becomes suspect. The filtering logic must handle the case where a directory contains a mix of safe and dangerous content, since the MerkleDAG structure means a node might be asked to serve a structure that links to something it should not.
Filtering by CID is effective because it blocks serving the malicious content itself — whether requested directly by peers over the P2P layer or indirectly through the HTTP gateway.
Building and running IPFS Safemode
Cloudflare implemented this filtering as a protection layer on top of go-ipfs, which it calls IPFS Safemode. Each node operator is responsible for defining which CIDs to block based on their own policy.
To use it, clone the cloudflare/go-ipfs repository, check out the commit where IPFS Safemode is implemented (based on go-ipfs v0.9.1), and build from source:
- Clone the git repository and check out the
v0.9.1-safemodetag. - Build the IPFS client from the source code.
- Run the resulting binary with Safemode enabled.
The resulting node is ready to serve content with Safemode filtering active.
Why open sourcing Safemode matters
IPFS nodes run in a wide range of environments — some are accessed by a single user, others serve thousands of participants. If the goal is for a P2P node to be embedded in every computer, operators need a way to give consent about the content they're willing to serve. Content filtering is an essential part of that consent mechanism, and by releasing IPFS Safemode as open source, Cloudflare aims to let the wider community build on the same protections rather than leaving them as a proprietary feature of a single gateway.



