CVE-2026-117992
Overview
Background
- SVG used as an image
- When an SVG is loaded via
<img>,background-image, etc., it is rendered in a restricted “image document” mode. To preserve privacy/security it must not behave like a full document; in particular it is heavily restricted in what external content it may load. - `Document::IsBeingUsedAsImage()` / `mIsBeingUsedAsImage`
- Flag marking a
Documentas an image document. - Display document (`GetDisplayDocument` / `SetDisplayDocument`)
- Some resource documents (e.g. an SVG resource) have an associated “display document” they are presented within.
mHasDisplayDocument/mDisplayDocumenttrack this relationship. - `nsDataDocumentContentPolicy::ShouldLoad`
- A content-policy hook that decides whether a load is allowed. For SVG-as-image it enforces that content may only come from URIs that are local and inherit the security context (data URIs, etc.).
Root Cause Analysis
The “used as an image” restriction in nsDataDocumentContentPolicy::ShouldLoad (dom/base/nsDataDocumentContentPolicy.cpp) was keyed off the wrong document. The old code computed docToCheckForImage = doc->GetDisplayDocument() and fell back to doc only when there was no display document, then applied the SVG-as-image URI restrictions to that chosen document. The flaw is that the image-document status was not reliably reflected on the document the policy actually consulted: when a document had a display document, the policy checked the display document’s IsBeingUsedAsImage(), which was not set to mirror the underlying image-resource document. As a result the restrictive branch could be skipped, letting an SVG-as-image load external content it should not — the privacy/info-disclosure leak the advisory describes.
The patch fixes this on two sides. Document::SetDisplayDocument (dom/base/Document.h) now propagates the flag: mIsBeingUsedAsImage |= aDisplayDocument->mIsBeingUsedAsImage;, so a document whose display document is an image document is itself marked as used-as-image. With the flag reliably present on the document, ShouldLoad is simplified to test doc->IsBeingUsedAsImage() directly, dropping the GetDisplayDocument() indirection that previously selected the wrong document to check. This classifies as a content-policy bypass (the diff shows the restriction being applied to the right document); the advisory labels it information disclosure, which is the impact of letting a restricted SVG-as-image reach external resources.
Attack Path
- Serve a malicious SVG
Attacker provides an SVG that a victim loads as an image (
<img>, CSSbackground-image, etc.). (reachability inferred) - Display-document relationship
The SVG’s resource/display-document arrangement is such that the pre-patch
ShouldLoadconsulted a document whoseIsBeingUsedAsImage()was not set. - Restriction skipped
Because the checked document was not flagged as an image document,
ShouldLoaddid not enforce the “local + inherits security context” URI restriction for the SVG. - External load The SVG triggers a load to an external URI that should have been blocked for an image document.
- Primitive The external request leaks information (resource existence/timing, and disallowed cross-context content retrieval) from the image-rendering context — an information-disclosure/privacy bypass.
Impact Assessment
Changed Functions
| Function | Change | Notes |
|---|---|---|
ifdom/base/nsDataDocumentContentPolicy.cpp |
modified |
Files Changed
dom/base/Document.hdom/base/nsDataDocumentContentPolicy.cpp
Audit Directions
- Image-document flag propagationAudit other places that read
IsBeingUsedAsImage()to confirm they see the flag on documents linked via display/resource-document relationships, now that propagation is centralized inSetDisplayDocument. - Display-document indirection in security checksSearch for other security/content-policy checks that use
GetDisplayDocument()(or similar indirection) to pick which document to evaluate, which can select a document lacking the relevant restriction flags. - SVG-as-image load restrictionsReview all enforcement points of the “SVG used as image may only load local/inheriting URIs” rule for other paths that could reach them with the wrong document or an unset flag.
Patch
diff --git a/dom/base/Document.h b/dom/base/Document.h
index 9d8b51a1625..b088fe37269 100644
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -2862,6 +2862,7 @@ class Document : public nsINode,
"Display documents should not nest");
mDisplayDocument = aDisplayDocument;
mHasDisplayDocument = !!aDisplayDocument;
+ mIsBeingUsedAsImage |= aDisplayDocument->mIsBeingUsedAsImage;
}
/**
diff --git a/dom/base/nsDataDocumentContentPolicy.cpp b/dom/base/nsDataDocumentContentPolicy.cpp
index 7b421192a21..0bae94ab7ca 100644
--- a/dom/base/nsDataDocumentContentPolicy.cpp
+++ b/dom/base/nsDataDocumentContentPolicy.cpp
@@ -97,12 +97,7 @@ nsDataDocumentContentPolicy::ShouldLoad(nsIURI* aContentLocation,
}
}
- mozilla::dom::Document* docToCheckForImage = doc->GetDisplayDocument();
- if (!docToCheckForImage) {
- docToCheckForImage = doc;
- }
-
- if (docToCheckForImage->IsBeingUsedAsImage()) {
+ if (doc->IsBeingUsedAsImage()) {
// We only allow SVG images to load content from URIs that are local and
// also satisfy one of the following conditions:
// - URI inherits security context, e.g. data URIs