Inappropriate implementation in Site Isolation (CVE-2024-1671)
A flaw in Chrome's Site Isolation allowed an attacker to reuse a session history entry across cross-origin frames, enabling them to read a victim page's srcdoc content or inject a malicious CSP into a cross-origin srcdoc. This could leak sensitive information such as the base URI and CSP of the victim page, or bypass CSP protections.
Originally disclosed on Chrome VRP
- Fix shipped in 49 days
VULNERABILITY DETAILS
It's possible to have two cross-origin parents with insufficient framing protections use the same session history entry when navigating history by using location.replace(). By creating a history entry in a subframe, then replacing the parent frame's active history entry with a different one (but still with a document containing an iframe*), then calling history.back(), the history entry from the subframe of the previous page will be used to load into the iframe.
In particular, this means that if a victim page which is embeddable by an attacker page contains a srcdoc iframe, then it's possible for an attacker to load that history entry's document state into a subframe they control and, since an about:srcdoc URI inherits its origin from its embedder, read it as well. This could leak, e.g., document.baseURI (which is the unfiltered URL of the victim page embedding the srcdoc) and the CSP of the page.1
Similarly, the reverse is possible. An attacker origin could apply malicious policies (e.g. CSP) that would be stored in the policy container of the session history entry of an about:srcdoc URI, or provide their own about base URI, then load this session history entry into a cross-origin page with an <iframe srcdoc=...>. The attacker CSP would override the srcdoc's original CSP, which could lead to a CSP bypass if the srcdoc content could be controlled.2
Note that controlling the about base URI in a cross-origin srcdoc was already possible by navigating it to about:srcdoc, but applying a cross-origin CSP was not.3
VERSION
Chrome Version: 120.0.6099.130 + stable
Operating System: Windows 11 Version 10.0.22621 Build 22621
REPRODUCTION CASE
PoCs for each of the points above:
Please find all relevant files attached. Put all files into the same directory.
- In the 2nd PoC, the victim page inserts whatever is given in the "content" query parameter into the srcdoc. Note that usually any scripts would be unable to run, since the parent page has a strict CSP and the srcdoc inherits from the parent page.
- In the 3rd PoC, the victim page loads a script from a relative URL. If the victim expects this to load from their site, then an attacker can hijack the base URI to instead load from an attacker site, even with the base-uri CSP directive set. I'm not sure if this is expected behaviour. The same file
x.jsis used for both the attacker and victim sites for ease of reproducibility, but note that a victim would load their ownx.js, and an attacker would upload a malicious script at the same path on their server.
* A blob URI is used for this, but any same-origin page would work.
CREDIT INFORMATION
Reporter credit: Harry Chen
Context
Chrome's Site Isolation assigns cross-origin documents to separate renderer processes and keeps their session history entries apart, so that one origin cannot reach into another origin's document state. The session history entry is the record the browser keeps for each navigation: it holds the document, its policy container (including CSP) and its base URI. When history is traversed, the browser is supposed to restore the entry that belongs to the frame that created it.
This report, filed through the Chrome VRP by Harry Chen and disclosed on 20 February 2024 as CVE-2024-1671, describes an inappropriate implementation in Site Isolation where two cross-origin parents with insufficient framing protections can end up sharing the same session history entry during a history navigation triggered by location.replace(). The result is that a history entry created in a subframe of one page can be loaded into an iframe of a different, cross-origin page.
Setup
The researcher tested on:
- Chrome Version: 120.0.6099.130 + stable
- Operating System: Windows 11 Version 10.0.22621 Build 22621
Three proof-of-concept pages were published, one per scenario:
[1]: http://attacker-d6bc41.ddns.net:8080/exp1.html
[2]: http://attacker-d6bc41.ddns.net:8080/exp2.html
[3]: http://attacker-d6bc41.ddns.net:8080/exp3.html
All relevant files were attached to the report and were meant to be placed in the same directory. The attacker pages were served from a single host on port 8080; the victim pages are described only by their properties (embeddable, containing a srcdoc iframe, or loading a relative script), not by URL.
The precondition throughout is that the victim page is embeddable by the attacker page, that is, it has insufficient framing protections. The attacker also needs a way to create a history entry in a subframe of their own page and then replace the parent frame's active entry.
Finding it
The session history entry used during a history.back() traversal is not tied to the frame that created it. The sequence is:
- Create a history entry in a subframe.
- Replace the parent frame's active history entry with a different one, still containing a document with an iframe. A blob URI is used for this, but any same-origin page would work.
- Call
history.back().
The history entry from the subframe of the previous page is then used to load into the iframe. Because the two parents are cross-origin, this means a document state created under one origin is restored inside a frame controlled by another origin.
Two consequences stood out. First, a victim page that is embeddable and contains a srcdoc iframe can have that history entry's document state loaded into an attacker-controlled subframe. Since an about:srcdoc URI inherits its origin from its embedder, the attacker can then read it. Second, the reverse direction works: an attacker origin can store malicious policies, such as a CSP, in the policy container of the session history entry of an about:srcdoc URI, or supply its own about base URI, and then load that entry into a cross-origin page that has an <iframe srcdoc=...>.
Exploitation
Step 1: Leak the victim srcdoc document state (exp1)
The first PoC drives the history confusion so that the victim's srcdoc history entry is loaded into a subframe the attacker controls. Because about:srcdoc inherits the origin of its embedder, the attacker can read the restored document. The report gives the leakable data as, for example, document.baseURI, which is the unfiltered URL of the victim page embedding the srcdoc, and the CSP of the page.
The PoC is at:
http://attacker-d6bc41.ddns.net:8080/exp1.html
Step 2: Override the srcdoc CSP from a cross-origin parent (exp2)
The second PoC reverses the direction. The victim page inserts whatever is supplied in the content query parameter into the srcdoc. Normally any scripts in that content would be unable to run, because the parent page has a strict CSP and the srcdoc inherits from the parent page. The attacker instead stores their own CSP in the policy container of the session history entry of an about:srcdoc URI and loads that entry into the cross-origin victim page with an <iframe srcdoc=...>. The attacker CSP overrides the srcdoc's original CSP, which can lead to a CSP bypass if the srcdoc content can be controlled.
The PoC is at:
http://attacker-d6bc41.ddns.net:8080/exp2.html
Step 3: Hijack the about base URI (exp3)
The third PoC covers the base URI. The victim page loads a script from a relative URL. If the victim expects the script to load from their own site, an attacker can hijack the base URI so that the script loads from an attacker site instead, even with the base-uri CSP directive set. The researcher was not sure whether this is expected behaviour.
The PoC is at:
http://attacker-d6bc41.ddns.net:8080/exp3.html
The same file x.js was used for both the attacker and victim sites for ease of reproducibility. In a real attack the victim would load their own x.js, and the attacker would upload a malicious script at the same path on their server.
The report notes that controlling the about base URI in a cross-origin srcdoc was already possible by navigating it to about:srcdoc, but applying a cross-origin CSP was not.
Root cause
The session history entry is not correctly associated with the frame that created it when the parent's active entry is replaced with location.replace() and history is then traversed. Two cross-origin parents with insufficient framing protections can therefore end up using the same session history entry, and the entry created in a subframe of the previous page is restored into the iframe of the new page.
Because the policy container and base URI travel with the session history entry, restoring it across an origin boundary carries the wrong CSP and the wrong base URI into the srcdoc document. The about:srcdoc origin inheritance then turns the confusion into a readable cross-origin document in one direction and a policy override in the other.
Impact
Under the condition that the victim page is embeddable by the attacker page, an attacker can:
- Read the document state of a victim
srcdociframe restored into an attacker-controlled subframe, leaking data such asdocument.baseURI(the unfiltered URL of the victim page embedding the srcdoc) and the page's CSP. - Apply a cross-origin CSP to a victim
srcdocwhose content the attacker can influence through thecontentquery parameter, overriding the srcdoc's original CSP and potentially bypassing it. - Supply an attacker about base URI so that a relative script URL in the victim page resolves to an attacker site, even with the
base-uriCSP directive set.
The report hedges the CSP bypass on the srcdoc content being controllable, and the researcher was not sure whether the base URI behaviour is expected. The platform rated the issue medium severity, and the bounty was 8000.00 USD.
Fix
The report does not describe the change that was made.
Variants to test
- Replace the blob URI used for the parent's replacement document with any same-origin page, as the report notes is possible, and check whether the subframe's history entry is still restored into the iframe.
- Use a victim page whose
srcdoccontent is reflected from a query parameter, as in the second PoC, and check whether an attacker-stored CSP overrides the inherited one. - Use a victim page that loads a relative script and check whether an attacker-supplied about base URI redirects the load despite
base-uri. - Check whether the leaked
document.baseURIreveals unfiltered URLs that the victim page expected to keep private.
A positive result in any of these is a cross-origin document state, policy or base URI appearing in a frame that should not have access to it.
What happened, in plain words
A web browser does not show you one single program. It splits the work of displaying a page across several separate helper programs, called processes, so that a page from one website cannot easily reach into a page from another website. Chrome calls this arrangement Site Isolation. The idea is like giving each shop in a shopping centre its own locked stockroom: even if two shops are in the same building, neither can walk into the other's back room.
This report is about a hole in that separation. Harry Chen found that, in certain conditions, the browser could mix up the records it keeps about where a frame has been. A frame is a window inside a page, such as the box that shows an embedded video or an embedded map. The browser keeps a list of the pages each frame has visited, so the Back and Forward buttons work. That list is called the session history, and each item on it is a session history entry. Think of it as a receipt for each visit: it records which document was shown, which security rules applied to it, and which address relative links should be measured against.
The bug meant that a receipt created inside a frame of one website could be handed to a frame of a different website. Because the receipt carries security rules and address information with it, the wrong website could end up reading data it should not see, or imposing its own rules on someone else's page.
The issue was filed through the Chrome VRP, Google's Vulnerability Reward Program, which pays people for reporting security bugs in Chrome. It was disclosed on 20 February 2024 as CVE-2024-1671. A CVE is a public catalogue number given to a known security flaw so people can refer to it unambiguously. The platform rated it medium severity, and the bounty, the reward paid to the researcher, was 8000.00 USD.
The pieces you need to know
Before the details make sense, here are the building blocks the report relies on.
- Origin: the combination of protocol, host and port that a browser uses to decide whether two pages are allowed to talk to each other.
https://shop.exampleandhttps://bank.exampleare different origins. So arehttp://example.comandhttps://example.com. Pages from different origins are kept apart on purpose. - Cross-origin: simply means "from a different origin". Two cross-origin pages are pages that the browser treats as belonging to different websites.
- iframe: an HTML element that puts one web page inside another. The outer page is the parent, the inner one is the child. A parent can embed a page from another site, which is how adverts, videos and comment widgets appear inside pages.
- srcdoc iframe: an iframe whose content is written directly into the parent's HTML with the
srcdocattribute, instead of pointing at a separate URL. The inner document has no address of its own; it is described asabout:srcdoc. - Origin inheritance: an
about:srcdocdocument does not have its own origin. It borrows, or inherits, the origin of the page that embedded it. This is a deliberate design choice, so that a page can safely build small pieces of itself inline. - CSP (Content Security Policy): a set of rules a website sends to the browser saying what the page is allowed to load and run. A strict CSP might say "no scripts except from my own site". It is a defence against injected malicious code.
- Policy container: the browser's internal box for a document's security policies, including its CSP. It travels with the document.
- Base URI: the address that relative links and relative script paths are resolved against. If a page at
https://example.com/app/page.htmlloadsx.js, the browser combines the two to gethttps://example.com/app/x.js. Thebase-uriCSP directive restricts what that base address may be. - Session history entry: the browser's record of one visit to one document, including the document itself, its policy container and its base URI. The Back and Forward buttons move through these entries.
location.replace(): a JavaScript call that navigates the current frame to a new address and replaces the current history entry instead of adding a new one. It is like editing the last line of a diary rather than writing a new line.history.back(): a JavaScript call that performs the same action as pressing the Back button, moving to the previous session history entry.- Blob URI: an address of the form
blob:...that points at data created in memory by a page. It belongs to the same origin as the page that made it. - Framing protections: rules a website can set to stop other sites from embedding it in an iframe. If a page has insufficient framing protections, other sites can embed it.
- Query parameter: the part of a URL after a question mark, such as
?content=hello. Pages often read these values and use them in what they display.
The setup
The researcher tested on:
- Chrome Version: 120.0.6099.130 + stable
- Operating System: Windows 11 Version 10.0.22621 Build 22621
Three proof-of-concept pages were published, one for each scenario. A proof of concept, or PoC, is a small demonstration that shows a bug is real without causing harm.
[1]: http://attacker-d6bc41.ddns.net:8080/exp1.html
[2]: http://attacker-d6bc41.ddns.net:8080/exp2.html
[3]: http://attacker-d6bc41.ddns.net:8080/exp3.html
Line by line: each line is a URL for one demonstration page. The host attacker-d6bc41.ddns.net is the address the demonstration pages were served from, and :8080 is the network port the test web server listened on. exp1.html, exp2.html and exp3.html are the three files, one per scenario. The numbers in square brackets are labels the report uses later to refer back to each one.
All relevant files were attached to the report and were meant to be placed in the same directory, so the pages could load each other's helper files. The attacker pages were served from that single host on port 8080. The victim pages are described only by their properties, not by URL: one is embeddable and contains a srcdoc iframe, another inserts a query parameter into its srcdoc, and a third loads a relative script.
The precondition throughout is that the victim page is embeddable by the attacker page. In other words, the victim has insufficient framing protections, so the attacker is allowed to put it inside an iframe. The attacker also needs a way to create a history entry in a subframe of their own page and then replace the parent frame's active entry.
Finding it
The researcher noticed that the session history entry used during a history.back() traversal is not tied to the frame that created it. The sequence is:
- Create a history entry in a subframe.
- Replace the parent frame's active history entry with a different one, still containing a document with an iframe. A blob URI is used for this, but any same-origin page would work.
- Call
history.back().
The history entry from the subframe of the previous page is then used to load into the iframe. Because the two parents are cross-origin, this means a document state created under one origin is restored inside a frame controlled by another origin.
Why does this matter? Because the receipt is not just a page address. It carries the document, its security rules and its base address. Handing that receipt to a frame from a different website is like giving a stranger your shopping receipt along with the keys to the stockroom it describes.
Two consequences stood out. First, a victim page that is embeddable and contains a srcdoc iframe can have that history entry's document state loaded into an attacker-controlled subframe. Since an about:srcdoc URI inherits its origin from its embedder, the attacker can then read it. Second, the reverse direction works: an attacker origin can store malicious policies, such as a CSP, in the policy container of the session history entry of an about:srcdoc URI, or supply its own about base URI, and then load that entry into a cross-origin page that has an <iframe srcdoc=...>.
Exploitation
Step 1: Leak the victim srcdoc document state (exp1)
The first PoC drives the history confusion so that the victim's srcdoc history entry is loaded into a subframe the attacker controls. Because about:srcdoc inherits the origin of its embedder, the attacker can read the restored document. The report gives the leakable data as, for example, document.baseURI, which is the unfiltered URL of the victim page embedding the srcdoc, and the CSP of the page.
In plain terms: the attacker arranges for the browser to restore the victim's inline frame into a frame the attacker owns. Since that inline frame borrows the origin of whoever embeds it, and the attacker is now the embedder, the attacker's code is allowed to read it. The leaked document.baseURI can reveal the victim's real, unfiltered address, and the CSP reveals the victim's security rules.
The PoC is at:
http://attacker-d6bc41.ddns.net:8080/exp1.html
This single line is the address of the first demonstration page.
Step 2: Override the srcdoc CSP from a cross-origin parent (exp2)
The second PoC reverses the direction. The victim page inserts whatever is supplied in the content query parameter into the srcdoc. Normally any scripts in that content would be unable to run, because the parent page has a strict CSP and the srcdoc inherits from the parent page. The attacker instead stores their own CSP in the policy container of the session history entry of an about:srcdoc URI and loads that entry into the cross-origin victim page with an <iframe srcdoc=...>. The attacker CSP overrides the srcdoc's original CSP, which can lead to a CSP bypass if the srcdoc content can be controlled.
In plain terms: the victim page is helpful in a dangerous way. It takes whatever text arrives in the content part of its URL and puts it inside its inline frame. Normally the victim's strict CSP would stop any script in that text from running, because the inline frame inherits the victim's rules. But the attacker's stored receipt carries the attacker's own CSP, and that replaces the victim's rules. If the attacker can also control the content, the victim's protection is bypassed.
The PoC is at:
http://attacker-d6bc41.ddns.net:8080/exp2.html
This line is the address of the second demonstration page.
Step 3: Hijack the about base URI (exp3)
The third PoC covers the base URI. The victim page loads a script from a relative URL. If the victim expects the script to load from their own site, an attacker can hijack the base URI so that the script loads from an attacker site instead, even with the base-uri CSP directive set. The researcher was not sure whether this is expected behaviour.
In plain terms: the victim page says "load x.js" without giving a full address. The browser fills in the missing part from the base URI. If the attacker can change the base URI stored in the receipt, the browser fills in the attacker's address instead, and the victim's page runs the attacker's script. The base-uri CSP directive is set, yet the report says the hijack still worked.
The PoC is at:
http://attacker-d6bc41.ddns.net:8080/exp3.html
This line is the address of the third demonstration page.
The same file x.js was used for both the attacker and victim sites for ease of reproducibility. In a real attack the victim would load their own x.js, and the attacker would upload a malicious script at the same path on their server.
The report notes that controlling the about base URI in a cross-origin srcdoc was already possible by navigating it to about:srcdoc, but applying a cross-origin CSP was not. In other words, the base URI trick was known before; the new part is that a foreign CSP could be planted too.
Root cause
The session history entry is not correctly associated with the frame that created it when the parent's active entry is replaced with location.replace() and history is then traversed. Two cross-origin parents with insufficient framing protections can therefore end up using the same session history entry, and the entry created in a subframe of the previous page is restored into the iframe of the new page.
Because the policy container and base URI travel with the session history entry, restoring it across an origin boundary carries the wrong CSP and the wrong base URI into the srcdoc document. The about:srcdoc origin inheritance then turns the confusion into a readable cross-origin document in one direction and a policy override in the other. The existing protections that should have prevented this are the framing protections on the victim page, which the report describes as insufficient, and the CSP inherited by the srcdoc, which is overridden by the attacker's stored policy.
A simple comparison: the browser keeps a coat check. Each coat has a ticket, and the ticket says which shop the coat belongs to. The bug is that the attendant sometimes hands a coat to the wrong shop because the ticket was not checked against the person collecting it. The coat itself, the security rules and the address label all travel together, so the wrong shop gets all three.
Impact
Under the condition that the victim page is embeddable by the attacker page, an attacker can:
- Read the document state of a victim
srcdociframe restored into an attacker-controlled subframe, leaking data such asdocument.baseURI(the unfiltered URL of the victim page embedding the srcdoc) and the page's CSP. - Apply a cross-origin CSP to a victim
srcdocwhose content the attacker can influence through thecontentquery parameter, overriding the srcdoc's original CSP and potentially bypassing it. - Supply an attacker about base URI so that a relative script URL in the victim page resolves to an attacker site, even with the
base-uriCSP directive set.
The report hedges the CSP bypass on the srcdoc content being controllable, and the researcher was not sure whether the base URI behaviour is expected. The platform rated the issue medium severity, and the bounty was 8000.00 USD.
Fix
The report does not describe the change that was made.
Variants to test
These are follow-up experiments someone could run to see how far the bug reaches. Each one changes one ingredient and checks whether the same confusion still happens.
- Replace the blob URI used for the parent's replacement document with any same-origin page, as the report notes is possible, and check whether the subframe's history entry is still restored into the iframe. The report notes that a blob URI is used, but any same-origin page would work.
- Use a victim page whose
srcdoccontent is reflected from a query parameter, as in the second PoC, and check whether an attacker-stored CSP overrides the inherited one. This tests whether the policy override depends on the exact way the content is inserted. - Use a victim page that loads a relative script and check whether an attacker-supplied about base URI redirects the load despite
base-uri. This tests whether the base URI hijack is a general weakness or specific to the tested page. - The point is to map the boundary: which protections actually stop the mix-up and which do not.
- Check whether the leaked
document.baseURIreveals unfiltered URLs that the victim page expected to keep private. This measures how much information the first scenario really exposes.
A positive result in any of these is a cross-origin document state, policy or base URI appearing in a frame that should not have access to it.
Glossary
- API: a defined way for one piece of software to ask another to do something, like a menu of allowed requests.
- about:srcdoc: the internal address the browser gives to a document written inline with the
srcdocattribute; it has no address of its own and borrows its origin from the embedding page. - Base URI: the address that relative links and script paths are resolved against.
- Blob URI: an in-memory address (
blob:...) for data created by a page, belonging to that page's origin. - Bounty: a reward paid to someone who reports a security flaw.
- CSP (Content Security Policy): rules a site sends to the browser saying what the page may load and run.
- Cross-origin: belonging to a different origin.
- CVE: a public catalogue number for a known security flaw.
- Framing protections: rules that stop other sites from embedding a page in an iframe.
- history.back(): a JavaScript call that goes to the previous session history entry, like pressing Back.
- iframe: an HTML element that embeds one page inside another.
- location.replace(): a JavaScript call that navigates to a new address and replaces the current history entry instead of adding one.
- Origin: the protocol, host and port combination the browser uses to decide whether pages may interact.
- Origin inheritance: a document without its own origin taking the origin of the page that embedded it.
- Policy container: the browser's internal store for a document's security policies, including its CSP.
- Proof of concept (PoC): a small demonstration that a bug is real.
- Query parameter: a value in a URL after the question mark, often read by the page.
- Session history: the browser's list of visited entries that Back and Forward move through.
- Session history entry: one record in that list, holding the document, its policy container and its base URI.
- Site Isolation: Chrome's design of putting pages from different sites into separate processes so they cannot reach each other.
- srcdoc iframe: an iframe whose content is written inline in the parent's HTML.
- VRP (Vulnerability Reward Program): a programme that pays researchers for reporting security bugs.