Skip to main content
Menu
Advisories

Backfill trusts cross-origin embedded objects and allows content spoofing

GHSA-X58X-XX7H-7RH4Published Updated GitHub

Description

@fedify/backfill calls every vocabulary accessor with crossOrigin: "trust". That option bypasses the [FEP-fe34] origin check for embedded objects and for fetched documents whose @id differs from the document URL. A remote document can therefore embed an object that claims another origin's @id, and backfill yields that embedded copy without dereferencing it.

Impact

An application that stores backfilled items by id can overwrite a post from another origin with attacker-controlled content. This is the content-spoofing and cache-poisoning case FEP-fe34 is meant to prevent. Backfill does not verify HTTP signatures or integrity proofs, so the caller cannot tell that the yielded copy is unverified.

Affected versions

@fedify/backfill 2.3.0 through 2.4.5. The fix is planned for 2.3.16 and 2.4.6, and will be included in the 2.5.0 release from main.

Details

On the 2.3 and 2.4 maintenance branches, backfill passes crossOrigin: "trust" at five sites in packages/backfill/src/backfill.ts: reply targets, the replies collection, collection items, collection pages, and Create objects. The default "ignore" behavior would dereference an embedded object by its @id instead of trusting the embedded copy. "trust" is documented in the vocabulary manual as a content-spoofing risk that must be paired with additional validation.

Reproduction

The following program parses a seed Note from JSON-LD, as backfill would receive it from a remote server. Its replies collection embeds a Note with another origin's @id. The loader returns null for every URL, so the only possible source of the yielded object is the embedded copy. The document has to be parsed with fromJsonLd(): objects passed to a vocabulary constructor are treated as trusted local data and are not rechecked.

import { Note } from "@fedify/vocab";
import { backfill } from "@fedify/backfill";

const seed = await Note.fromJsonLd({
  "@context": "https://www.w3.org/ns/activitystreams",
  type: "Note",
  id: "https://attacker.example/seed",
  replies: {
    type: "Collection",
    items: [{
      type: "Note",
      id: "https://victim.example/posts/1",
      content: "spoofed by attacker",
    }],
  },
});

const results = await Array.fromAsync(
  backfill(
    { documentLoader: () => Promise.resolve(null) },
    seed,
    { strategies: ["reply-tree"] },
  ),
);

console.log(results.map((item) => [item.id?.href, item.object.content]));

Observed output on affected versions:

[["https://victim.example/posts/1", "spoofed by attacker"]]

On fixed versions the program prints [], because backfill dereferences https://victim.example/posts/1 instead of using the embedded copy and the loader returns nothing.

Workarounds

Before persisting a backfilled item, fetch it again from its @id with lookupObject() or another loader that enforces the default origin check, and use that object instead of the yielded copy. Applications that only display backfilled content without storing it by id are not affected by the overwrite case.

Fix

The maintenance fix replaces crossOrigin: "trust" with the default "ignore" behavior at all five sites and documents that backfill returns unverified remote data. A follow-up on main adds a BackfillOptions.crossOrigin option so callers with their own validation can opt into "trust" explicitly.

[FEP-fe34]: w3id.org/fep/fe34

Affected versions

References

GitHub · fedify-dev/fedify