Property accessors trust cross-origin embedded objects of an object without an id when it repeats a property under its full IRI
Description
The generated property accessors in @fedify/vocab, such as Create.getObject() and Collection.getItems(), do not return an embedded object whose id is on another origin than the id of the object that embeds it. By default (crossOrigin: "ignore") they fetch it by its id instead, as [FEP-fe34] requires. When the embedding object has no id of its own, this works on the decoded value, but a second code path that re-decodes the embedded object from the cached JSON-LD skips the origin check entirely.
An attacker can reach that path by sending an object without an id that has the same property twice: once under its compact name with the forged object, and once under its full IRI with an ID-less placeholder. The accessor then returns the forged object, which claims to live on the victim's origin, without fetching anything.
This reaches inbox listeners: Fedify's inbox accepts signed activities without an id, and the inbox origin check added for [GHSA-4qhx-hhwf-8685] only applies to activities that have one. That advisory states that an activity without an id is not affected; with this payload, it is. It also reaches @fedify/backfill, whose fix for [GHSA-x58x-xx7h-7rh4] relies on the default accessor behavior.
Suggested severity: Moderate, [CVSS 3.1] AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N (5.3).
[FEP-fe34]: w3id.org/
Details
Line references are to packages/vocab-tools/src/property.ts on 2.3-maintenance at [ce471cc].
A singular accessor such as getObject() takes the decoded value and checks it first ([L277-L291]). This check compares against this.id?.origin, so for an owner without an id any embedded object with an id counts as cross-origin and is fetched by that id:
~~~~ typescript if (options.crossOrigin !== "trust" && !(v instanceof URL) && v.id != null && v.id.origin !== this.id?.origin && !this.#_trust.has(0)) { v = v.id; } ~~~~
If the value is still embedded, and the cached JSON-LD has the property under its compact name with its own @context, the accessor decodes that document again and replaces v with the result ([L293-L321]). The result is then checked once more ([L323-L346]), but this check requires the owner to have an id:
~~~~ typescript if (options.crossOrigin !== "trust" && v?.id != null && this.id != null && v.id.origin !== this.id.origin && !this.#_trust.has(0)) { // refuse the object } return v; ~~~~
So the object returned for an owner without an id is never origin-checked if it came from the cached JSON-LD.
The two paths normally see the same object. They can be made to see different ones because JSON-LD expansion merges a property written under its compact name with the same property written under its full IRI. In the payload below, the expanded object has two values, and the decoded value at index 0 is the ID-less placeholder, which passes the first check. The re-decoding path reads only the compact object key, which holds the forged Note.
The affected code is generated for every object-valued property with a compact name; the accessors listed in the advisory metadata are representative examples. The plural accessors (getObjects(), getItems(), and so on) have the same structure ([L385-L402], [L404-L434], [L436-L459]). The second check there also tests #_trust.has(0) where it means has(i). No way to exploit that on its own was found: the trust set is filled only by the constructor and by fetches, fetches clear the cached JSON-LD, and fromJsonLd() does not fill it. It is fixed on 2.4-maintenance and should be fixed on older branches along with this.
On 2.4-maintenance ([2a78382]), the checks call isTrustedIriOrigin() instead of comparing URL.origin, but the second check is still guarded by this.id != null ([L477-L546]), and the published 2.4.5 release behaves the same as 2.3.
On main, the re-decoding path was removed in [6e344ff] (#1356, “Decode embedded objects with the whole document”), which is not in a release yet. Accessors now decode embedded objects once, from the whole document, so the placeholder trick has no second path to use. The this.id != null condition is still in the second check on main, but the value it sees has already passed the first check.
The cross-origin check was introduced in 1.9.0 ([45b856c]). The re-decoding path is older (1.3.0, 23a96c0), but 1.8.x and earlier trust every embedded object, so they have no check to bypass.
[ce471cc]: github.com/
Where attacker-supplied objects without an id come from
Inbox delivery is the most direct path. handleInbox() requires an actor and an HTTP signature (or other proof) from a key the actor owns, but not an id. The same-origin check between the activity and its actors is skipped when the id is missing. An attacker with an actor on their own server can therefore deliver a signed Create or Announce without an id, and the listener's getObject() returns the forged object. This is the case shown in the proof of concept.
In @fedify/backfill, a collection page embedded without an id in a context collection, or a context collection without an id, makes getItems() yield a forged item. This was reproduced from source on the private fix branch for [GHSA-h3jv-px69-2gpj], which is based on 2.3-maintenance and also contains the fix for [GHSA-x58x-xx7h-7rh4].
Any other application code that calls fromJsonLd() on remote JSON and then uses the accessors, or uses the accessors on a fetched document that has no id, is affected in the same way. This was not tested for lookupObject() specifically.
[GHSA-h3jv-px69-2gpj]: github.com/
Affected versions
The vocabulary-level script below was run with Deno 2.8.3 against the latest release of each line, from both npm and JSR where noted. On 1.x, it imports @fedify/fedify/vocab instead of @fedify/vocab. The inbox script was run against 1.9.13, 2.0.35, and 2.4.5.
| Version | Result |
|---|---|
| 1.8.15 | Predates the origin check; still returns forged embedded content |
| 1.9.0, 1.9.13, 1.10.0, 1.10.12 (npm; JSR 1.10.12) | Affected |
| 2.0.0, 2.0.35, 2.1.31, 2.2.20, 2.3.0, 2.3.15 | Affected |
| 2.4.2, 2.4.5 (npm and JSR) | Affected |
2.5.0-dev.2835 (main, after 6e344ff) | Not affected (returns the placeholder) |
The affected ranges describe a bypass of the origin policy introduced in 1.9.0. Earlier releases lack that protection altogether and are not a safe downgrade.
The 2.4-maintenance branch has not been run from source; the conclusion that it is still affected comes from the 2.4.5 release and from reading the branch.
Proof of concept
The first script needs no configuration file and only the npm registry. Run it with deno run -A poc.ts:
~~~~ typescript import { Create } from "npm:@fedify/vocab@2.4.5";
const AS = "w3.org/
for (const id of [null, "evil.example/${AS}#object] = [{ type: "Note" }]; const create = await Create.fromJsonLd(json); const fetched: string[] = []; const object = await create.getObject({ documentLoader: (url: string) => { fetched.push(url); throw new Error(refused to fetch ${url}); }, }).catch((e: Error) => e.message); console.log(JSON.stringify({ id, placeholder, fetched, result: typeof object === "string" ? object : object && [object.id?.href, object.content?.toString()], })); } } ~~~~
Output:
~~~~ {"id":null,"placeholder":true,"fetched":[],"result":["victim.example/
Only the first case is wrong. Without the placeholder, the accessor fetches the Note from its origin, as it should. With an id on the activity, the second check refuses the re-decoded object and returns null. Expected output for the first case: a fetch of https://victim.example/notes/1, or null.
The second script sends the same payload through the inbox of a federation built with @fedify/fedify 2.4.5, which already includes the fix for GHSA-4qhx-hhwf-8685. Save it as poc-inbox.ts and run deno run -A poc-inbox.ts:
~~~~ typescript import { createFederation, generateCryptoKeyPair, MemoryKvStore, signRequest, } from "npm:@fedify/fedify@2.4.5"; import { Create, CryptographicKey, Note, Person, } from "npm:@fedify/vocab@2.4.5"; import { getDocumentLoader } from "npm:@fedify/vocab-runtime@2.4.5";
const AS = "w3.org/${mallory.href}#main-key); const { privateKey, publicKey } = await generateCryptoKeyPair( "RSASSA-PKCS1-v1_5", );
// Only Mallory's own documents can be fetched. Any other fetch throws, so a // listener that dereferences an object makes the inbox answer 500. const documentLoader = async (url: string) => { if (url !== mallory.href && url !== keyId.href) { throw new Error(refused to fetch ${url}); } const document = await new Person({ id: mallory, inbox: new URL(${mallory.href}/inbox), publicKey: new CryptographicKey({ id: keyId, owner: mallory, publicKey }), }).toJsonLd(); return { documentUrl: url, contextUrl: null, document }; };
const federation = createFederation<void>({ kv: new MemoryKvStore(), contextLoaderFactory: () => getDocumentLoader(), documentLoaderFactory: () => documentLoader, authenticatedDocumentLoaderFactory: () => documentLoader, }); federation.setActorDispatcher("/users/{identifier}", () => null); const seen: unknown[] = []; federation .setInboxListeners("/users/{identifier}/inbox", "/inbox") .on(Create, async (_ctx, create) => { const object = await create.getObject(); seen.push(object == null ? null : { objectId: object?.id?.href, attributedTo: object?.attributionId?.href, content: object instanceof Note ? object.content?.toString() : null, }); });
async function send(label: string, id: string | null, placeholder: boolean) { seen.length = 0; const activity: Record<string, unknown> = { "@context": AS, type: "Create", actor: mallory.href, object: { "@context": AS, id: "victim.example/${AS}#object] = [{ type: "Note" }]; const request = await signRequest( new Request("local.example/
// No id, with the placeholder: getObject() returns the embedded copy. await send("no id, placeholder:", null, true); // Controls: getObject() tries to fetch the Note, which is refused here, or // refuses the embedded copy. await send("no id, no placeholder:", null, false); await send("own id, placeholder:", "evil.example/
Output:
~~~~ no id, placeholder: 202 [{"objectId":"victim.example/
The same happens with Announce instead of Create (checked from source on the private fix branch for GHSA-h3jv-px69-2gpj, based on 2.3-maintenance).
Impact
This is an origin validation error ([CWE-346]) of the same kind as GHSA-4qhx-hhwf-8685, reached through a different payload: an application receives an object that claims to live on another server, and Fedify does not fetch it from there.
- An application that stores or displays the objects returned by
getObject()and the other accessors can be made to show content attributed to a user on another server who never wrote it. If the application checks the attribution against the activity's actor, as the [microblog tutorial] does, the attacker can attribute the object to themselves and still place it under an IRI of the victim's server, where it can collide with or stand in for the genuine object. AnAnnounceusually has no such attribution check, so it can present a forged copy of a victim's post as a boost. - Applications that persist backfilled items by
idare exposed to the content-spoofing case described in GHSA-x58x-xx7h-7rh4, even after that fix.
The attacker needs an actor with a key on a server they control for the inbox path, or control of a document that backfill or the application fetches. No interaction from the victim is needed. Fedify itself does not persist objects; the actual damage depends on what the application does with them.
[CWE-346]: cwe.mitre.org/
Workarounds
Before storing or displaying an object with an id that an accessor returned from an object without an id, fetch it again by its id with lookupObject() under the default origin policy, and use only the fetched copy. Apply this to nested objects and backfilled items too. Passing crossOrigin: "throw" does not help, because the skipped check is the one that would throw.
Rejecting inbox activities without an id blocks the direct Create and Announce payloads shown above, but not every inbox path: an anonymous object nested inside an activity that has an id works the same way. This was reproduced on 2.4.5 with a signed Create that has an attacker-origin id and embeds an anonymous Create; a listener that calls getObject() on both receives the forged Note.
Suggested fix
On the maintenance branches, make the second check treat an owner without an id the way the first check already does, by dropping the this.id != null condition from both the singular and the plural template:
- On 2.0 to 2.3, compare
v.id.origin !== this.id?.origin, and usethis.id?.href ?? nullin the error message and log, which currently dereferencethis.id.href. - On 2.4, drop the
this.id != null &&prefix that is emitted whentrustEmbeddedObjectsis notfalse. For an embedded value with anid,isTrustedIriOrigin()already returnsfalsewhen the owneridisnullunder the default policy andcrossOrigin: "throw"(it returnstrueforcrossOrigin: "trust", as intended), and the messages already usethis.id?.href ?? null. - On 2.0 to 2.3, change
#_trust.has(0)to#_trust.has(i)in the plural template, as on 2.4.
This keeps the current behavior of the second check, which refuses the object (or throws with crossOrigin: "throw") instead of fetching it. Fetching by id, as the first check does, would be more consistent but changes what callers get in the case where the owner has an id.
The same changes apply to 1.9 and 1.10 in packages/fedify/src/codegen/property.ts, but those lines are unmaintained and no patched 1.x release is planned; users of 1.x should move to a maintained release that contains the fix.
An additional safeguard could keep the first decoded value when re-decoding changes its id. Such mismatches also occur with ordinary inherited JSON-LD contexts (for example, a parent context that aliases @id), so that change would need compatibility tests. Removing the exemption for owners without an id from the second check addresses this bypass directly, without relying on an ID-mismatch heuristic. Backporting 6e344ff itself would be a much larger change.
Each fix needs the distributed vocabulary and the generator snapshots regenerated, and regression tests with the placeholder payload for a singular and a plural accessor, covering owners with and without an id, under both the default policy and crossOrigin: "throw", while keeping the explicit crossOrigin: "trust" behavior. Applications that generated their own vocabulary classes with an affected @fedify/vocab-tools must regenerate and rebuild them after upgrading.