ExpressVPN Browser Extension: HTML5 Geolocation Spoof Bypass - Client Physical Location Leak
The ExpressVPN browser extension's HTML5 geolocation spoofing could be disabled by any web page that sent a crafted postMessage, because the content script only checked that the message came from the same window. An attacker could then read the victim's real physical location instead of the spoofed one.
Originally disclosed on Bugcrowd
- Accepted in 6 months
- Fixed in 7 months
- Disclosed after 8 months
Summary by ExpressVPN
Bitspinner identified a vulnerability in the way we validated the source for geolocation updates, which allowed a malicious website or an attacker who could exploit an XSS vulnerability, to disable our geolocation spoofing feature and thus leak their actual geolocation. This issue has been resolved.
We are grateful to Bitspinner for disclosing this to us responsibly, and for his professionalism throughout the process.
Summary by Bitspinner
Overview of the Vulnerability
ExpressVPN's browser extensions (both Firefox + Chrome + Edge + others?) have an HTML5 geolocation spoof feature. This feature can be bypassed since the gps.js content script injects an event listener that validates only that event.source == window (source: validation logic).
The vulnerable code will set the hookedObj.fakeGeo property (source) to false which controls spoofing conditional logic code flow at lines 19 and 42 within a JavaScript closure that is injected into every page the user browses: source: extension manifest.json.
Thus, it is possible for an attacker to phish a target using either an attacker owned malicious site (user would have to approve location usage for the browser), or weaponize XSS on a site the victim user has already trusted (.e.g.: maps.google.com) and potentially leak their current physical location.
To execute this, a web page need only execute these commands
setInterval(()=>{
// bypass spoofing by posting a message to update 'hookedObj' in gps.js
let info = {
fakeIt: false,
coords: {
lat: 99.9999,
lon: 99.9999,
}
window.postMessage({ method: 'updateLocation', info: info }, "*")
}
}, 1000)
Business Impact
The ExpressVPN Browser Extension HTML5 spoofing feature gives users a false sense of safety when allowing location settings for webpages. There may be a portion of ExpressVPN users (e.g.: investigative journalists in dangerous countries, politicians, confidential informants, undercover personnel, deployed military personnel etc.) that rely on geolocation spoofing to not give away their location for physical safety reasons - as such, a successful attacker may have enough information to pose an immediate physical threat to the ExpressVPN user and those around them.
In addition, with the combined timestamp + physical location + VPNServer IP data, an advanced threat actor could potentially correlate (with additional data - e.g.: access to ISP data for the local geographic region) the Private IP of the ExpressVPN user.
Note that the physical location feature ranges in accuracy and may or may not be accurate when spoofing is disabled.
Report details
-
Submitted
07 Jan 2023 03:11:28 UTC
-
Target Location
ExpressVPN Chrome extension -
Target category
Other
-
VRT
Sensitive Data Exposure > Disclosure of Secrets
-
Priority
P2
-
Bug URL
https://github.com/expressvpn/expressvpn_browser_extension/blob/3d018234c3cab61f34568a81311c84a38f128294/source/scripts/content/gps.js#L130 -
Description
Disclosure of Secrets
Overview of the Vulnerability
ExpressVPN's browser extensions (both Firefox + Chrome + Edge + others?) have an HTML5 geolocation spoof feature. This feature can be bypassed since the
gps.jscontent script injects an event listener that validates only thatevent.source == window(source: validation logic).The vulnerable code will set the
hookedObj.fakeGeoproperty (source) tofalsewhich controls spoofing conditional logic code flow at lines 19 and 42 within a JavaScript closure that is injected into every page the user browses: source: extension manifest.json.Thus, it is possible for an attacker to phish a target using either an attacker owned malicious site (user would have to approve location usage for the browser), or weaponize XSS on a site the victim user has already trusted (.e.g.: maps.google.com) and potentially leak their current physical location.
To execute this, a web page need only execute these commands
setInterval(()=>{ // bypass spoofing by posting a message to update 'hookedObj' in gps.js let info = { fakeIt: false, coords: { lat: 99.9999, lon: 99.9999, } window.postMessage({ method: 'updateLocation', info: info }, "*") } }, 1000)Business Impact
The ExpressVPN Browser Extension HTML5 spoofing feature gives users a false sense of safety when allowing location settings for webpages. There may be a portion of ExpressVPN users (e.g.: investigative journalists in dangerous countries, politicians, confidential informants, undercover personnel, deployed military personnel etc.) that rely on geolocation spoofing to not give away their location for physical safety reasons - as such, a successful attacker may have enough information to pose an immediate physical threat to the ExpressVPN user and those around them.
In addition, with the combined timestamp + physical location + VPNServer IP data, an advanced threat actor could potentially correlate (with additional data - e.g.: access to ISP data for the local geographic region) the Private IP of the ExpressVPN user.
Note that the physical location feature ranges in accuracy and may or may not be accurate when spoofing is disabled.
Steps to Reproduce
- Download + Install + Connect ExpressVPN Extension + enable HTML5 location spoofing
- Use a browser to navigate to spoofed location: https://do6.us/ca20a9ef-0390-438b-b83d-1826595d22ef/ExpressVPNPhysicalLocationLeakPOC + allow location services
- Add parameter
?bypass=1: https://do6.us/ca20a9ef-0390-438b-b83d-1826595d22ef/ExpressVPNPhysicalLocationLeakPOC?bypass=1
Note that the physical location should be more accurate despite the ExpressVPN spoofing setting in the Browser Extension still being enabled. The location should be the same as if you were to disable the HTML5 "Privacy & Security > Spoof your location" feature in the ExpressVPN extension.
Proof of Concept (PoC)
Screenshot:
Video POC: unlisted YouTube
Attached is the source for the POC
ExpressVPNGetPhysicalLocationLeakPOC.htmlwhich can be self hosted for further testing.
Context
ExpressVPN's browser extensions ship an HTML5 geolocation spoofing feature. When the user enables it, pages that ask the browser for their location receive coordinates chosen by the extension rather than the machine's real position. The report covers the ExpressVPN Chrome extension, and the researcher notes that the same feature exists in the Firefox and Edge builds (the report phrases this as "both Firefox + Chrome + Edge + others?", so the full list is not confirmed).
The mechanism is a content script, gps.js, that is injected into every page the user browses. The injection is declared in the extension's manifest.json. Inside that script a JavaScript closure hooks the geolocation API and decides, per call, whether to return the spoofed coordinates or the real ones. The decision is held in a property called hookedObj.fakeGeo, and the conditional logic that reads it sits at lines 19 and 42 of gps.js. The listener that can change that property is registered at line 130, and the assignment that clears it is at line 139.
Setup
No account, role or special tooling is needed beyond a normal install of the extension. The preconditions are:
- The ExpressVPN browser extension is installed and connected.
- The HTML5 location spoofing option is enabled in the extension.
- The victim visits a page that asks for location permission and grants it, either on an attacker-controlled site or on a trusted site where the attacker can run script through XSS.
The researcher's proof of concept is a self-hosted HTML file, ExpressVPNGetPhysicalLocationLeakPOC.html, plus a hosted copy on do6.us used in the reproduction steps.
Finding it
The content script listens for postMessage events on the page's window. The validation on that listener only checks that event.source == window. That check confirms the message came from the same window object, but any script running in the page shares that window, so the check does not distinguish the extension's own messages from a page's messages.
Because the message handler accepts input from page script, a page can send the same kind of message the extension sends and overwrite the state that controls spoofing. Setting hookedObj.fakeGeo to false flips the conditional logic at lines 19 and 42, and subsequent geolocation calls return the real position instead of the spoofed one. The feature that is supposed to hide the user's location can therefore be switched off from inside the page it is meant to protect.
Exploitation
Step 1: Prepare the target browser
Download, install and connect the ExpressVPN extension, then enable HTML5 location spoofing. This is the state a normal user of the feature is in.
Step 2: Visit the spoofed-location page and allow location
Navigate to the researcher's page and allow location services when the browser prompts:
https://do6.us/ca20a9ef-0390-438b-b83d-1826595d22ef/ExpressVPNPhysicalLocationLeakPOC
At this point the page should be receiving the spoofed coordinates, which is the expected behaviour of the feature.
Step 3: Add the bypass parameter
Load the same page with ?bypass=1 appended:
https://do6.us/ca20a9ef-0390-438b-b83d-1826595d22ef/ExpressVPNPhysicalLocationLeakPOC?bypass=1
The page now runs the bypass. The location reported should be noticeably more accurate even though the ExpressVPN spoofing setting in the extension is still enabled. The researcher states it should match what you would see if you disabled the HTML5 "Privacy & Security > Spoof your location" feature in the extension.
The bypass itself is a small script that repeatedly posts a message into the page's own window:
setInterval(()=>{
// bypass spoofing by posting a message to update 'hookedObj' in gps.js
let info = {
fakeIt: false,
coords: {
lat: 99.9999,
lon: 99.9999,
}
window.postMessage({ method: 'updateLocation', info: info }, "*")
}
}, 1000)
The important parts are the method: 'updateLocation' field, which matches the message type the content script listens for, and fakeIt: false, which is what ends up clearing hookedObj.fakeGeo. The coords object is included in the message but the effect described in the report comes from turning spoofing off, not from the coordinates themselves. The setInterval re-sends the message every second, so the state is reasserted if anything resets it. The target origin is "*", so the message is delivered regardless of origin.
The report links an unlisted YouTube video as the proof of concept.
Step 4: Deliver the script to a victim
The researcher describes two delivery routes. The first is an attacker-owned malicious site, where the user has to approve location usage for the browser. The second is XSS on a site the victim already trusts, with maps.google.com given as an example, where the victim has already granted location permission to that origin. In both cases the page only has to run the script above.
Root cause
The message listener in gps.js authenticates the sender with event.source == window. That is not an authentication check at all: every script executing in the page, including injected XSS payloads and third-party scripts, posts from the same window object. The extension therefore cannot tell its own updateLocation messages from a page's forged ones, and the handler applies the page-supplied info to hookedObj, including fakeIt: false, which disables spoofing for later geolocation calls.
The report does not describe any additional defence, such as a secret token in the message, an origin allowlist, or a check that the message came from the extension's isolated world, so the source check appears to have been the only barrier.
Impact
With spoofing disabled, the page can read the user's real physical location through the normal geolocation API, subject to the permission the user has already granted. The report frames the risk around users who depend on the feature for physical safety: investigative journalists in dangerous countries, politicians, confidential informants, undercover personnel and deployed military personnel. For those users a successful attack may give an attacker enough information to pose an immediate physical threat to the user and those around them.
The researcher also notes that combining the timestamp, the physical location and the VPN server IP could, with additional data such as ISP records for the local region, let an advanced threat actor correlate the user's private IP.
The report hedges the accuracy: the physical location feature ranges in accuracy and may or may not be accurate when spoofing is disabled. Exploitation also depends on the victim granting location permission to the attacking origin, either by visiting an attacker site and approving the prompt or by the attacker having script execution on an origin the victim already trusts.
Fix
ExpressVPN states that the vulnerability was in the way it validated the source for geolocation updates, and that the issue has been resolved. The report does not describe the specific code change.
Variants to test
- Other message types in the same content script. Enumerate every
methodvalue the script handles and try sending each from page script. A positive result is any handler that changes extension state, such as the spoofing flag, without further validation. - Other extensions with page-facing bridges. Look for content scripts that accept
postMessageand validate onlyevent.sourceorevent.originagainst the page itself. A positive result is a page script changing a security-relevant setting in the extension. - XSS on a location-trusted origin. On a site where you already have script execution and the victim has granted geolocation, run the bypass payload. A positive result is real coordinates returned while the spoofing setting is still enabled.
- State reset behaviour. If the extension re-sends its own
updateLocationmessage periodically, check whether a single forged message is enough or whether repeated sending (as in thesetIntervalabove) is required. A positive result is a persistent bypass with a single message. - Other browsers. The researcher suggests Firefox, Chrome and Edge may carry the feature, but does not confirm it. Repeat the reproduction in each build. A positive result is the same real-location leak with spoofing still enabled.
What happened, in plain words
ExpressVPN makes a browser extension, a small add-on you install in Chrome (and, according to the researcher, in Firefox and Edge too). One of its features is location spoofing: when you switch it on, websites that ask the browser "where is this person?" get a fake location chosen by the extension instead of your real one. People use this to hide where they actually are.
The researcher, Bitspinner, found that this protection could be switched off from inside an ordinary web page. A page only had to send a particular message to itself, and the extension's script, which was listening for messages, would accept it and turn spoofing off. From then on, the same page could ask for your location and receive your real coordinates, even though the extension still showed the spoofing setting as enabled.
ExpressVPN confirmed the problem and states the issue has been resolved, and a bounty of 1,250 USD was paid. The report was disclosed on 28 August 2023 and rated high severity.
To follow the rest of this article you only need to know how to install a browser extension and open a web page. Every technical term is explained where it first appears, and there is a glossary at the end.
Context
What the product and the feature do
A browser extension is a small program added to a browser. Extensions can do things ordinary web pages cannot, such as read or change what a page shows, or add buttons to the toolbar. ExpressVPN's extension is the companion to their VPN service: you install it, connect it, and it can change how the browser behaves.
One of those behaviours is HTML5 geolocation spoofing. Geolocation is simply "where am I". Modern browsers expose a standard way for a website to ask for the visitor's position, and the browser then shows a permission prompt ("Allow this site to know your location?"). If you allow it, the site receives coordinates, usually latitude and longitude, sometimes with an accuracy figure. The ExpressVPN feature intercepts that request and hands the site coordinates chosen by the extension instead of the machine's real position.
The report covers the ExpressVPN Chrome extension. The researcher writes that the same feature exists in the Firefox and Edge builds, but phrases it as "both Firefox + Chrome + Edge + others?", so the full list of affected browsers is not confirmed.
How the feature is built
The extension does its work through a content script. A content script is a file of JavaScript that the extension injects into web pages as you browse them. Which pages get which script is declared in the extension's manifest.json, a configuration file that describes the extension to the browser. Here the script is called gps.js, and it is injected into every page the user browses.
Inside gps.js there is a JavaScript closure: a block of code that keeps its own private variables, which outside code cannot reach directly. That closure hooks the geolocation API. To hook something means to replace or wrap a built-in function so that your own code runs first and can change the result. In this case the hook decides, each time a page asks for a location, whether to return the spoofed coordinates or the real ones.
The decision is stored in a property called hookedObj.fakeGeo. Think of it as a light switch inside the closure: while it is on, the hook returns fake coordinates; when it is off, the hook lets the real ones through. The code that reads this switch sits at lines 19 and 42 of gps.js. The piece of code that can change the switch is a listener registered at line 130, and the line that actually clears the switch is line 139.
A listener is a function that waits for something to happen and then runs. Here it waits for messages. The content script listens for postMessage events, a standard browser mechanism that lets different scripts in the same page send each other messages.
Setup
No account, special role or unusual tooling is needed. The preconditions are the state any normal user of the feature is already in:
- The ExpressVPN browser extension is installed and connected.
- The HTML5 location spoofing option is enabled in the extension.
- The victim visits a page that asks for location permission and grants it. That page is either controlled by the attacker, or a trusted site where the attacker can run script through an XSS flaw.
XSS stands for cross-site scripting: a bug that lets an attacker slip their own JavaScript into a page other people trust, so it runs as if the site itself had written it. If you can run script on a site the victim already trusts, the victim sees no reason to be suspicious.
The researcher's proof of concept is a self-hosted HTML file, ExpressVPNGetPhysicalLocationLeakPOC.html, plus a hosted copy on do6.us used in the reproduction steps.
Finding it
The content script needs to receive the spoofed coordinates from the extension's privileged context, so it listens for postMessage events on the page's window. The window is the global object of a page: every script running in that page, whether it came from the site, from an advertisement, or from an injected XSS payload, shares the same window.
The validation on that listener only checks that event.source == window. In plain words: "did this message come from this same window object?" That check confirms the message came from the same window, but since every script in the page shares that window, it cannot tell the extension's own messages apart from a page's messages. It is like a doorman who lets anyone in as long as they are standing in the same building.
Because the message handler accepts input from page script, a page can send the same kind of message the extension sends and overwrite the state that controls spoofing. Setting hookedObj.fakeGeo to false flips the conditional logic at lines 19 and 42, and subsequent geolocation calls return the real position instead of the spoofed one. The feature that is supposed to hide the user's location can therefore be switched off from inside the very page it is meant to protect.
Exploitation
Step 1: Prepare the target browser
Download, install and connect the ExpressVPN extension, then enable HTML5 location spoofing. This is the state a normal user of the feature is in, so it is the fair starting point for testing whether the feature actually protects them.
Step 2: Visit the spoofed-location page and allow location
Navigate to the researcher's page and allow location services when the browser prompts:
https://do6.us/ca20a9ef-0390-438b-b83d-1826595d22ef/ExpressVPNPhysicalLocationLeakPOC
This is a plain web address. Opening it loads the researcher's test page. The browser will show its usual location permission prompt; you click allow, exactly as a real visitor would. At this point the page should be receiving the spoofed coordinates, which is the expected behaviour of the feature. This step establishes the baseline: with spoofing on, the page sees a fake location.
Step 3: Add the bypass parameter
Load the same page with ?bypass=1 appended:
https://do6.us/ca20a9ef-0390-438b-b83d-1826595d22ef/ExpressVPNPhysicalLocationLeakPOC?bypass=1
The part after the question mark is a query parameter, a small piece of information added to the end of a web address. Websites commonly use them to change what a page does. Here bypass=1 tells the test page to run the bypass code. The page now runs the bypass. The location reported should be noticeably more accurate even though the ExpressVPN spoofing setting in the extension is still enabled. The researcher states it should match what you would see if you disabled the HTML5 "Privacy & Security > Spoof your location" feature in the extension.
The bypass itself is a small script that repeatedly posts a message into the page's own window:
setInterval(()=>{
// bypass spoofing by posting a message to update 'hookedObj' in gps.js
let info = {
fakeIt: false,
coords: {
lat: 99.9999,
lon: 99.9999,
}
window.postMessage({ method: 'updateLocation', info: info }, "*")
}
}, 1000)
Line by line, in plain words:
setInterval(()=>{ ... }, 1000)asks the browser to run the code inside the braces again and again, every 1000 milliseconds, which is one second. Repeating matters because if anything resets the switch, the next message sets it back.- The comment line starting with
//is a note for humans and does nothing. It says the message is meant to updatehookedObjingps.js. let info = { ... }creates a small package of data, called an object, namedinfo.fakeIt: falseis the important field. It is the instruction that ends up clearinghookedObj.fakeGeo, turning spoofing off.coords: { lat: 99.9999, lon: 99.9999 }is a nested object holding a latitude and a longitude. The report's described effect comes from turning spoofing off, not from these coordinates themselves.window.postMessage({ method: 'updateLocation', info: info }, "*")sends the message.method: 'updateLocation'is the message type, chosen to match what the content script listens for.infocarries the package above. The"*"is the target origin, and the star means "deliver this regardless of which site the page belongs to".
The report links an unlisted YouTube video as the proof of concept.
Step 4: Deliver the script to a victim
The researcher describes two delivery routes. The first is an attacker-owned malicious site, where the user has to approve location usage for the browser. The second is XSS on a site the victim already trusts, with maps.google.com given as an example, where the victim has already granted location permission to that origin. In both cases the page only has to run the script above. The first route relies on the victim approving location for an unfamiliar site; the second relies on the victim having trusted a familiar site earlier.
Root cause
The message listener in gps.js authenticates the sender with event.source == window. That is not an authentication check at all: every script executing in the page, including injected XSS payloads and third-party scripts, posts from the same window object. The extension therefore cannot tell its own updateLocation messages from a page's forged ones, and the handler applies the page-supplied info to hookedObj, including fakeIt: false, which disables spoofing for later geolocation calls.
The report does not describe any additional defence, such as a secret token in the message, an origin allowlist, or a check that the message came from the extension's isolated world, so the source check appears to have been the only barrier. A token here would mean a secret value known only to the extension, which a page could not guess; an origin allowlist would mean accepting messages only from named sites. Neither is mentioned in the report.
Impact
With spoofing disabled, the page can read the user's real physical location through the normal geolocation API, subject to the permission the user has already granted. The report frames the risk around users who depend on the feature for physical safety: investigative journalists in dangerous countries, politicians, confidential informants, undercover personnel and deployed military personnel. For those users a successful attack may give an attacker enough information to pose an immediate physical threat to the user and those around them.
The researcher also notes that combining the timestamp, the physical location and the VPN server IP could, with additional data such as ISP records for the local region, let an advanced threat actor correlate the user's private IP. An ISP is the company that provides someone's internet connection, and it holds records of which customer was using which address at which time.
The report hedges the accuracy: the physical location feature ranges in accuracy and may or may not be accurate when spoofing is disabled. Exploitation also depends on the victim granting location permission to the attacking origin, either by visiting an attacker site and approving the prompt or by the attacker having script execution on an origin the victim already trusts.
Fix
ExpressVPN states that the vulnerability was in the way it validated the source for geolocation updates, and that the issue has been resolved. The report does not describe the specific code change.
Variants to test
- Other message types in the same content script. Enumerate every
methodvalue the script handles and try sending each from page script. A positive result is any handler that changes extension state, such as the spoofing flag, without further validation. - Other extensions with page-facing bridges. Look for content scripts that accept
postMessageand validate onlyevent.sourceorevent.originagainst the page itself. A positive result is a page script changing a security-relevant setting in the extension. - XSS on a location-trusted origin. On a site where you already have script execution and the victim has granted geolocation, run the bypass payload. A positive result is real coordinates returned while the spoofing setting is still enabled.
- State reset behaviour. If the extension re-sends its own
updateLocationmessage periodically, check whether a single forged message is enough or whether repeated sending (as in thesetIntervalabove) is required. A positive result is a persistent bypass with a single message. - Other browsers. The researcher suggests Firefox, Chrome and Edge may carry the feature, but does not confirm it. Repeat the reproduction in each build. A positive result is the same real-location leak with spoofing still enabled.
Glossary
- Browser extension: a small program installed into a browser that can add features or change how pages behave.
- Content script: a file of JavaScript that an extension injects into web pages as you browse.
- manifest.json: the configuration file that tells the browser what an extension contains and where its scripts run.
- HTML5 geolocation: the standard browser feature that lets a website ask for the visitor's physical position, with a permission prompt.
- Geolocation spoofing: replacing the real position with a fake one before a website sees it.
- JavaScript closure: a block of code that keeps private variables which outside code cannot reach directly.
- Hook: to wrap or replace a built-in function so your own code runs first and can change its result.
- API: a defined way for one piece of software to ask another for something, here the browser's way of answering "where am I?".
- Listener: a function that waits for an event, such as a message arriving, and then runs.
- postMessage: a standard browser mechanism that lets scripts in the same page send messages to each other.
- window: the global object of a page, shared by every script running in it.
- event.source: the property of a message event that says which window sent it.
- XSS (cross-site scripting): a bug that lets an attacker run their own JavaScript inside a page other people trust.
- Query parameter: a small piece of information added to the end of a web address after a question mark, used to change what the page does.
- setInterval: a JavaScript function that runs a piece of code repeatedly at a fixed time interval.
- Target origin: the part of
postMessagethat says which sites may receive the message;"*"means any site. - Token: a secret value used to prove that a message or request really comes from a trusted party.
- Origin allowlist: a list of named sites that are the only ones allowed to do something.
- ISP: the company that provides an internet connection, which keeps records linking customers to addresses and times.
- VPN: a service that routes your internet traffic through a server, so websites see the server's address instead of yours.
- Proof of concept (PoC): a small demonstration that shows a vulnerability really works.
- Bounty: a reward paid by a company to someone who reports a security problem responsibly.
- Severity: a rating of how serious a vulnerability is.
- VRT: Bugcrowd's Vulnerability Rating Taxonomy, a standard way of categorising reported issues.