Insufficient policy enforcement in Site Isolation (CVE-2024-3840)
A cross-origin iframe could redirect the top-level page without user interaction by setting a Content-Security-Policy sandbox header with allow-top-navigation. This bypassed a previous fix and allowed an attacker to force navigation to an arbitrary site.
Originally disclosed on Chrome VRP
- Fix shipped in 3 months
VULNERABILITY DETAILS
After Fixing https://crbug.com/chromium/1251790 , i've found that this bug come back in Chrome for Android, Regression of https://crbug.com/chromium/1251790 .
Top-level redirect possible from cross-origin iframe without user-interaction by setting this header Content-Security-Policy: sandbox allow-top-navigation in the response.
This bypasses the patch for https://crbug.com/1145553
VERSION
Chrome Version: 122.0.6256.0
Channel:Canary
OS: Android 14; Pixel6 Device
Bisection Fix of main Issue:
[1] https://chromium-review.googlesource.com/c/chromium/src/+/3842458
[2] https://chromium-review.googlesource.com/c/chromium/src/+/2688360
REPRODUCTION CASE :
app.py
#!/usr/bin/env python3
from flask import Flask, Response
app = Flask(__name__)
@app.route("/test")
def test():
resp = Response("""
<script>
top.location = "https://google.com";
</script>
""", mimetype="text/html")
resp.headers["Content-Security-Policy"] = "sandbox allow-top-navigation allow-scripts"
return resp
app.run(host="0.0.0.0", debug=True)
once the flask app is started any page that embeds http://localhost:5000/test should be redirected to https://google.com , which have LIVE URL "
https://painted-dandelion-juravenator.glitch.me/demo?sandbox_header=1" .
Simple Reproduction with Live Poc
in Android make sure before repro make sure of these points
1- open chrome canary in android and press three vertical dots to open dropdown menu
2- Select Settings , then Under Advanced part select Site Settings
3- Scroll down under Content >> Popups and redirects should be blocked just check this .
Repro Steps:
1-Navigate to https://foggy-malleable-land.glitch.me/demo or https://vrphunt.com/chrome/android/csp-par.html
2-Click on button Iframe site showing intended behavior you will see redirection happens
3-Click on button Iframe site showing bypass you will see redirection also happens
Hints:
in the url https://painted-dandelion-juravenator.glitch.me/demo?sandbox_header=1 embedded inside live poc which redirects to google.com , this url has header Content-Security-Policy: sandbox allow-top-navigation in the response , and this embedded file content is
<script>
top.location = "https://google.com";
</script>
============
What is wrong and what is intended ?
In Chrome for Desktop the fix has landed and Stop iframes from allowing themselves to navigate top without gesture , and showing "Redirect blocked" message , But in Android this bug is found again and redirection happens.
++You Can Also Repro in Chrome for Desktop and see the difference in Action , which will help.
====================
CREDIT INFORMATION
Reporter credit: Ahmed ElMasry
Context
Site Isolation is the Chrome feature that keeps content from different origins in separate processes and enforces rules about what one frame is allowed to do to the rest of the page. One of those rules concerns top-level navigation: a cross-origin iframe should not be able to navigate the top-level document without a user gesture. This report is about that rule being bypassed on Chrome for Android, allowing a cross-origin iframe to redirect the whole page to an attacker-chosen URL without any interaction.
The researcher frames it as a regression. The behaviour had been addressed before, in crbug.com/chromium/1251790, and the report says the bug came back in Chrome for Android. It also states that the technique bypasses the patch for crbug.com/1145553.
Setup
The testing environment described in the report:
| Item | Value |
|---|---|
| Chrome version | 122.0.6256.0 |
| Channel | Canary |
| OS | Android 14 |
| Device | Pixel 6 |
Two bisection references are given for the fix of the main issue:
- https://chromium-review.googlesource.com/c/chromium/src/+/3842458
- https://chromium-review.googlesource.com/c/chromium/src/+/2688360
Before reproducing on Android, the researcher asks that one precondition be checked in the browser settings:
- Open Chrome Canary on Android and press the three vertical dots to open the dropdown menu.
- Select Settings, then under
AdvancedselectSite Settings. - Scroll down to
Content >> Popups and redirectsand confirm that it is set to blocked.
With popups and redirects blocked, the redirection still happens, which is the point of the finding.
Finding it
The researcher noticed that a cross-origin iframe could perform a top-level redirect without user interaction by having the server set a particular response header:
Content-Security-Policy: sandbox allow-top-navigation
The sandbox directive restricts what a document may do, and allow-top-navigation re-enables navigation of the top-level browsing context for that sandboxed document. The report's claim is that on Android this combination lets a cross-origin iframe navigate the top without a gesture, which is exactly what the earlier fix was supposed to prevent. On Chrome for Desktop the fix has landed: iframes are stopped from allowing themselves to navigate the top without a gesture, and a "Redirect blocked" message is shown. On Android the researcher found the redirection happening again.
Exploitation
Step 1: serve a page that redirects the top
The researcher provides a small Flask application that returns a page whose script sets top.location, together with the sandbox header:
#!/usr/bin/env python3
from flask import Flask, Response
app = Flask(__name__)
@app.route("/test")
def test():
resp = Response("""
<script>
top.location = "https://google.com";
</script>
""", mimetype="text/html")
resp.headers["Content-Security-Policy"] = "sandbox allow-top-navigation allow-scripts"
return resp
app.run(host="[redacted]", debug=True)
The response body is an inline script that assigns https://google.com to top.location. The response header is Content-Security-Policy: sandbox allow-top-navigation allow-scripts, so the document is sandboxed but is granted both top navigation and script execution. Once the Flask app is running, any page that embeds http://localhost:5000/test should be redirected to https://google.com.
Step 2: use the live proof of concept
The report gives a live URL for the same behaviour:
https://painted-dandelion-juravenator.glitch.me/demo?sandbox_header=1
This URL is embedded inside the live proof of concept and redirects to google.com. The report explains that the response for this URL carries the header Content-Security-Policy: sandbox allow-top-navigation, and that the embedded file content is:
<script>
top.location = "https://google.com";
</script>
Step 3: reproduce on Android
With the popups and redirects setting confirmed as blocked (see Setup), the researcher gives these steps:
- Navigate to
https://foggy-malleable-land.glitch.me/demoorhttps://vrphunt.com/chrome/android/csp-par.html. - Click the button
Iframe site showing intended behavior; redirection happens. - Click the button
Iframe site showing bypass; redirection also happens.
Clicking the button Iframe site showing intended behavior results in redirection, and clicking Iframe site showing bypass also results in redirection.
Step 4: compare with desktop
The researcher adds that the same reproduction can be run in Chrome for Desktop to see the difference in behaviour. On desktop the fix is present: the iframe is stopped from navigating the top without a gesture and a "Redirect blocked" message is shown, whereas on Android the redirection goes through.
Root cause
The platform record classifies this as insufficient policy enforcement in Site Isolation on Android. The report itself does not explain the code-level cause. so a document served with Content-Security-Policy: sandbox allow-top-navigation can still set top.location. The researcher describes this as a regression of the earlier issue and states that it bypasses the patch for crbug.com/1145553. The report does not go into the code-level detail of why the Android path differs from desktop; it presents the header, the payload and the observed difference between platforms.
Impact
A cross-origin iframe embedded in a page can redirect the top-level document to a URL of the attacker's choosing without any user interaction, even when popups and redirects are blocked in Site Settings. The redirect target in the proof of concept is https://google.com, but the mechanism is generic: whatever URL the script assigns to top.location is where the top-level page goes. The affected platform in the report is Chrome for Android; on desktop the redirect is blocked. The report does not describe any further consequences beyond the redirect itself.
Fix
The report does not describe a fix. It documents the regression and the platform difference, and points to the earlier fixes (crbug.com/chromium/1251790 and the patch for crbug.com/1145553) as the changes that the Android behaviour bypasses. The platform record lists this as CVE-2024-3840, an insufficient policy enforcement issue in Site Isolation, rated medium severity, disclosed on 2024-04-16, with a bounty of 3000.00 USD under the Chrome VRP.
Variants to test
- Serve a page with
Content-Security-Policy: sandbox allow-top-navigation allow-scriptsand a script that setstop.location, then embed it cross-origin in a test page. A positive result is the top-level page navigating without any click. - Try the same with only
sandbox allow-top-navigationwhere the script is loaded from a separate file rather than inline, to see whether the redirect still occurs. - Repeat the test on different Chrome channels and Android versions to see whether the behaviour is limited to Canary or present more widely.
- Run the same page on desktop Chrome as a control. A positive result on Android alongside a "Redirect blocked" message on desktop confirms the platform difference described here.
- Check the popups and redirects setting in Site Settings before each run, since the report treats it as a precondition and the bypass is meaningful precisely because the redirect happens while it is blocked.
What happened, in plain words
Chrome has a safety feature called Site Isolation. To understand it, imagine a large office building where every company gets its own locked floor. If one company's floor catches fire, the others are not affected. In a browser, each website you open is like one of those companies, and Site Isolation keeps each site in its own separate part of the browser so that one site cannot reach into another. It also enforces rules about what one part of a page is allowed to do to the rest of the page.
One of those rules is about top-level navigation. A web page can contain an iframe, which is a small window inside the page that shows another website. Think of a picture frame hanging on a wall: the wall is the main page, and the frame holds a different picture. The main page is called the top-level document, and the iframe is a separate document embedded inside it. The rule says that an iframe from a different website (a cross-origin iframe) should not be able to change what the whole page shows unless the user actually clicked something. In other words, the small frame should not be allowed to grab the wall and replace the picture hanging on it.
This report is about that rule being bypassed on Chrome for Android. A cross-origin iframe was able to redirect the whole page to a URL chosen by the attacker, without the user clicking anything at all.
The researcher describes this as a regression, which means a bug that was fixed before has come back. The behaviour had been dealt with earlier, in a Chromium bug report numbered 1251790, and the report says the bug returned in Chrome for Android. It also says the technique gets around the patch for another bug, numbered 1145553.
Setup
The testing environment described in the report:
| Item | Value |
|---|---|
| Chrome version | 122.0.6256.0 |
| Channel | Canary |
| OS | Android 14 |
| Device | Pixel 6 |
A few of those terms need explaining. Chrome Canary is an experimental edition of Chrome that receives new changes before the normal edition does. It is like a test kitchen where dishes are tried before they reach the main restaurant menu. Android 14 is the version of the Android operating system, and Pixel 6 is the phone model used for testing.
Two bisection references are given for the fix of the main issue:
- https://chromium-review.googlesource.com/c/chromium/src/+/3842458
- https://chromium-review.googlesource.com/c/chromium/src/+/2688360
Bisection is a way of finding which change caused a problem. Imagine a long row of dominoes and you want to know which one started the chain: you check the middle, then the middle of the half that matters, and so on until you find the exact domino. In software, bisection means testing versions in the middle of a range to narrow down which code change introduced a bug. The two links above point to code review pages for the changes that fixed the main issue.
Before reproducing on Android, the researcher asks that one precondition be checked in the browser settings:
- Open Chrome Canary on Android and press the three vertical dots to open the dropdown menu.
- Select Settings, then under
AdvancedselectSite Settings. - Scroll down to
Content >> Popups and redirectsand confirm that it is set to blocked.
Why check this first? Because Chrome has a setting that is supposed to stop websites from opening popups and redirecting you without permission. If that setting is on and the redirect still happens, then the browser's own protection has been defeated. That is the whole point of the finding: the redirect works even though the user has asked Chrome to block redirects.
Finding it
The researcher noticed that a cross-origin iframe could perform a top-level redirect without user interaction by having the server set a particular response header:
Content-Security-Policy: sandbox allow-top-navigation
Let us unpack that line. A header is extra information that a web server sends along with a page, a bit like the label on a parcel that tells the delivery service how to handle it. Content-Security-Policy (often shortened to CSP) is a header that lets a website tell the browser which things the page is allowed to do. The sandbox directive puts the page in a restricted box, like putting a document in a playpen: it can do less than a normal page. The allow-top-navigation part is a permission slip inside that sandbox: it says the sandboxed page is allowed to navigate the top-level page.
The report's claim is that on Android this combination lets a cross-origin iframe navigate the top without a gesture, which is exactly what the earlier fix was supposed to prevent. On Chrome for Desktop the fix has landed: iframes are stopped from allowing themselves to navigate the top without a gesture, and a "Redirect blocked" message is shown. On Android the researcher found the redirection happening again.
Exploitation
Step 1: serve a page that redirects the top
The researcher provides a small Flask application that returns a page whose script sets top.location, together with the sandbox header:
#!/usr/bin/env python3
from flask import Flask, Response
app = Flask(__name__)
@app.route("/test")
def test():
resp = Response("""
<script>
top.location = "https://google.com";
</script>
""", mimetype="text/html")
resp.headers["Content-Security-Policy"] = "sandbox allow-top-navigation allow-scripts"
return resp
app.run(host="[redacted]", debug=True)
Flask is a small toolkit for building websites in the Python programming language. Think of it as a set of building blocks for making a web server without writing everything from scratch. Here is what each part does:
#!/usr/bin/env python3tells the computer to run this file with Python 3.from flask import Flask, Responsebrings in two tools:Flask, which creates the web application, andResponse, which represents a reply sent back to the browser.app = Flask(__name__)creates the application itself.@app.route("/test")says: when someone asks for the address/test, run the function below it.def test():defines that function.resp = Response(""" ... """, mimetype="text/html")builds the reply. The text between the triple quotes is the page content, andmimetype="text/html"says the content is an HTML web page.- Inside that content,
<script> top.location = "https://google.com"; </script>is a small program the browser will run.top.locationmeans the address of the top-level page, the outermost window. Assigning a new address to it tells the browser to go there. So this script tells the browser to send the whole page tohttps://google.com. resp.headers["Content-Security-Policy"] = "sandbox allow-top-navigation allow-scripts"adds the CSP header to the reply. This time it grants two permissions:allow-top-navigation(may navigate the top page) andallow-scripts(may run scripts). The header grants bothallow-top-navigationandallow-scripts, so the sandboxed document may navigate the top page and run scripts.return respsends the reply back.app.run(host="[redacted]", debug=True)starts the server, listening on all network interfaces, with debug mode on.
The response body is an inline script that assigns https://google.com to top.location. The response header is Content-Security-Policy: sandbox allow-top-navigation allow-scripts, so the document is sandboxed but is granted both top navigation and script execution. Once the Flask app is running, any page that embeds http://localhost:5000/test should be redirected to https://google.com.
Why build this at all? Because it gives a controlled, local example. You run the server on your own machine, embed its page in another page, and watch whether the outer page gets redirected. If it does, you have reproduced the behaviour without depending on anyone else's website.
Step 2: use the live proof of concept
The report gives a live URL for the same behaviour:
https://painted-dandelion-juravenator.glitch.me/demo?sandbox_header=1
A proof of concept (PoC) is a small demonstration that shows a problem is real, like a model built to prove a design works. This URL is hosted on Glitch, a service for putting small web apps online. The ?sandbox_header=1 part is a query string, extra information appended to the address that the server can read and act on; The ?sandbox_header=1 part is a query string appended to the address..
This URL is embedded inside the live proof of concept and redirects to google.com. The report explains that the response for this URL carries the header Content-Security-Policy: sandbox allow-top-navigation, and that the embedded file content is:
<script>
top.location = "https://google.com";
</script>
Line by line: <script> opens a block of browser code. top.location = "https://google.com"; sets the address of the outermost page to Google, which makes the browser navigate there. </script> closes the block. The report gives this header for the live URL and this script as the embedded file content.
Step 3: reproduce on Android
With the popups and redirects setting confirmed as blocked (see Setup), the researcher gives these steps:
- Navigate to
https://foggy-malleable-land.glitch.me/demoorhttps://vrphunt.com/chrome/android/csp-par.html. - Click the button
Iframe site showing intended behavior; redirection happens. - Click the button
Iframe site showing bypass; redirection also happens.
Clicking the button Iframe site showing intended behavior results in redirection, and clicking Iframe site showing bypass also results in redirection. On Android, both go through.
Step 4: compare with desktop
The researcher adds that the same reproduction can be run in Chrome for Desktop to see the difference in behaviour. On desktop the fix is present: the iframe is stopped from navigating the top without a gesture and a "Redirect blocked" message is shown, whereas on Android the redirection goes through. Running the same test on two platforms is a common way to show that a problem is specific to one of them, rather than a mistake in the test itself.
Root cause
The platform record classifies this as insufficient policy enforcement in Site Isolation on Android. The report itself does not explain the code-level cause. so a document served with Content-Security-Policy: sandbox allow-top-navigation can still set top.location. "Insufficient policy enforcement" simply means the browser has a rule but does not apply it fully in this situation, like a security guard who is at the door but lets some people through without checking.
The researcher describes this as a regression of the earlier issue and states that it bypasses the patch for crbug.com/1145553. The report does not go into the code-level detail of why the Android path differs from desktop; it presents the header, the payload and the observed difference between platforms.
Impact
A cross-origin iframe embedded in a page can redirect the top-level document to a URL of the attacker's choosing without any user interaction, even when popups and redirects are blocked in Site Settings. The redirect target in the proof of concept is https://google.com, but the mechanism is generic: whatever URL the script assigns to top.location is where the top-level page goes. The affected platform in the report is Chrome for Android; on desktop the redirect is blocked. The report does not describe any further consequences beyond the redirect itself.
Why does a redirect matter? Because a page you trust can suddenly send you somewhere else without warning. That is the first step in many scams, such as fake login pages. The report only documents the redirect, not what an attacker might do after it.
Fix
The report does not describe a fix. It documents the regression and the platform difference, and points to the earlier fixes (crbug.com/chromium/1251790 and the patch for crbug.com/1145553) as the changes that the Android behaviour bypasses. The platform record lists this as CVE-2024-3840, an insufficient policy enforcement issue in Site Isolation, rated medium severity, disclosed on 2024-04-16, with a bounty of 3000.00 USD under the Chrome VRP.
A CVE is a public identifier for a known security flaw, like a case number for a police report, so that people can refer to the same issue unambiguously. Severity is a rough measure of how serious the flaw is; medium sits in the middle of the usual scale. A bounty is a payment made to a researcher who reports a valid security problem. The Chrome VRP (Vulnerability Reward Program) is Google's scheme for paying researchers who find and report flaws in Chrome.
Variants to test
- Serve a page with
Content-Security-Policy: sandbox allow-top-navigation allow-scriptsand a script that setstop.location, then embed it cross-origin in a test page. A positive result is the top-level page navigating without any click. - Try the same with only
sandbox allow-top-navigationwhere the script is loaded from a separate file rather than inline, to see whether the redirect still occurs. - Repeat the test on different Chrome channels and Android versions to see whether the behaviour is limited to Canary or present more widely.
- Run the same page on desktop Chrome as a control. A positive result on Android alongside a "Redirect blocked" message on desktop confirms the platform difference described here.
- Check the popups and redirects setting in Site Settings before each run, since the report treats it as a precondition and the bypass is meaningful precisely because the redirect happens while it is blocked.
A control in testing is a comparison case where you expect a known result, so you can tell whether a difference is real. Here, desktop Chrome is the control: it should block the redirect, and if it does, the Android result stands out.
Glossary
- Site Isolation: a Chrome feature that keeps content from different websites in separate processes and enforces rules about what one part of a page may do to the rest.
- Top-level navigation: changing the address of the outermost page, the one shown in the browser tab.
- Top-level document: the main page in the browser tab, as opposed to a page embedded inside it.
- Iframe: a small window inside a web page that displays another document.
- Cross-origin: coming from a different website address than the page that contains it.
- Regression: a bug that was fixed before and has come back.
- Bisection: a method of narrowing down which code change caused a problem by testing versions in the middle of a range.
- Chrome Canary: an experimental edition of Chrome that receives changes earlier than the normal edition.
- Header: extra information a web server sends with a page, telling the browser how to handle it.
- Content-Security-Policy (CSP): a header that tells the browser what a page is allowed to do.
- Sandbox: a restricted mode for a page that limits what it can do.
- allow-top-navigation: a CSP permission that lets a sandboxed page navigate the top-level page.
- allow-scripts: a CSP permission that lets a sandboxed page run scripts.
- Flask: a small Python toolkit for building web applications.
- Response: the reply a web server sends back to the browser.
- Script: a small program that the browser runs inside a page.
- top.location: the address of the outermost page; assigning to it makes the browser navigate there.
- Proof of concept (PoC): a small demonstration showing that a problem is real.
- Query string: extra information appended to a URL after a question mark, which the server can read.
- Payload: the part of an attack that actually does the work, here the script that sets
top.location. - Insufficient policy enforcement: a situation where a browser has a rule but does not apply it fully.
- CVE: a public identifier for a known security flaw.
- Severity: a rough measure of how serious a flaw is.
- Bounty: a payment to a researcher who reports a valid security problem.
- Chrome VRP: Google's Vulnerability Reward Program for Chrome.
- Control: a comparison case in testing where the expected result is known.