URL Advisor component in KIS products family is vulnerable to Universal XSS
The URL Advisor UI in Kaspersky Internet Security is served as first-party content on every domain in Microsoft Edge and accepts postMessage data without origin validation, allowing a malicious site to set a link to a javascript: URL. Clickjacking then lets the attacker make the user click that link, executing code in the context of any domain.
- Triaged in 48 hours
- Fixed in 4 months
- Paid in 17 days
- Disclosed after 8 months
Summary In Microsoft Edge, URL Advisor UI is served as first-party content on every domain. So the XSS vulnerability I found in this UI automatically applies to all websites, it allows running code in the context of any domain.
Description
URL Advisor frame is located under https://www.google.com/<INJECT_ID>/ua/url_advisor_balloon.html and https://www.yahoocom/<INJECT_ID>/ua/url_advisor_balloon.html in Microsoft Edge (always the same INJECT_ID value). It gets its content from a message sent via window.postMessage() without validating message origin. Under some circumstances it will assign that data as link target, so a malicious website can make that link point to a javascript: URL. Clickjacking then allows making the user click that link - while sites like google.com use X-Frame-Options header to disallow framing, no such restrictions are in place for the url_advisor_balloon.html frame.
Environment
- Scope: Application
- Product name: Kaspersky Internet Security
- Product version: 19.0.0.1088
- OS name and version (incl SP): Windows 10.0.17134
- Attack type: Universal XSS
- Maximum user privileges needed to reproduce your issue: no privileges
Steps to reproduce
- Download attached
server.pyanduniversal_xss.htmlto some directory on your computer and runserver.py(Python 3 required). This is a very rudimentary HTTP server running on http://localhost:5000/, you could use some other web server as well. - Edit the file %WINDIR%\sysnative\drivers\etc\hosts as administrator and add the following line:
127.0.0.1 www.google.example.com. Normally, you would just use a subdomain of a domain you own - the host name has to start with "www.google." for URL Advisor to apply to it. - Open Microsoft Edge and go to http://www.google.example.com:5000/universal_xss.html
- As advised by the page, move your mouse and click somewhere on the page.
You will see an alert message saying: "Hi, this is JavaScript code running on www.google.com." That's the result of the code alert('Hi, this JavaScript code is running on ' + document.domain) executing in the context of the Google website. Injecting code into any other domain would have been easily possible as well.
Recommendation This user interface should never be served as first-party, even once the vulnerability here is fixed. Any XSS vulnerability in Kaspersky code automatically elevates to Universal XSS otherwise, this is too dangerous. Frankly, I don't see why it is done in this way with Microsoft Edge - in Firefox and Internet Explorer the same UI is always served via kis.v2.scr.kaspersky-labs.com, so vulnerabilities here don't affect other websites.
Impact
A malicious website can easily make users click by pretending to be a game. And while the user clicks, they will be allowing the attackers to inject code into various internet domains and exfiltrating data in the background.
Context
Kaspersky Internet Security (KIS) ships a feature called URL Advisor, which annotates links in the browser with reputation information. In Microsoft Edge, the report explains, the URL Advisor UI is served as first-party content on every domain. That design decision is the heart of the issue: any XSS in the URL Advisor UI becomes a Universal XSS, because the injected code runs in the context of whatever domain the user is visiting.
The researcher, palant, describes the frame as being located under these URLs in Microsoft Edge (with the same INJECT_ID value in both):
https://www.google.com/<INJECT_ID>/ua/url_advisor_balloon.html
https://www.yahoocom/<INJECT_ID>/ua/url_advisor_balloon.html
The frame receives its content from a message sent via window.postMessage() without validating the message origin. Under some circumstances the UI assigns that data as a link target, so a malicious website can make the link point to a javascript: URL. Clickjacking then lets the attacker make the user click that link. Sites such as google.com use the X-Frame-Options header to disallow framing, but no such restriction applies to the url_advisor_balloon.html frame, so it can be framed by an attacker page.
Setup
The environment recorded in the report is:
| Item | Value |
|---|---|
| Scope | Application |
| Product name | Kaspersky Internet Security |
| Product version | 19.0.0.1088 |
| OS name and version | Windows 10.0.17134 |
| Attack type | Universal XSS |
| Maximum user privileges needed to reproduce | no privileges |
No accounts or special roles are required. The reproduction uses two files supplied with the report, server.py and universal_xss.html, plus Python 3 to run the server. The server listens on http://localhost:5000/, though the report notes that any other web server could be used instead. Administrative access is needed only to edit the hosts file.
Finding it
The researcher observed that in Microsoft Edge the URL Advisor frame is served as first-party content on every domain, under a path of the form /<INJECT_ID>/ua/url_advisor_balloon.html. Because the frame is first-party, any XSS inside it executes in the origin of the visited site rather than in a Kaspersky-controlled origin.
The frame populates itself from data delivered through window.postMessage(), and the message origin is not validated. The UI will, under some circumstances, assign that data as a link target. That combination means a malicious page can supply a javascript: URL as the link target and then use clickjacking to get the user to click it. The usual defence against framing, X-Frame-Options, is used by sites like google.com but is not in place for url_advisor_balloon.html, so the frame can be embedded in an attacker page.
For comparison, the report notes that in Firefox and Internet Explorer the same UI is always served via kis.v2.scr.kaspersky-labs.com, so vulnerabilities there do not affect other websites.
Exploitation
Step 1: run the local server
Download the attached server.py and universal_xss.html to a directory and run server.py with Python 3. The report describes it as a very rudimentary HTTP server running on http://localhost:5000/; another web server would work as well.
Step 2: point a matching hostname at localhost
Edit the hosts file as administrator and add the following line:
[redacted] www.google.example.com
The full path in the report is %WINDIR%\sysnative\drivers\etc\hosts. The host name has to start with www.google. for URL Advisor to apply to it. The report notes that normally one would simply use a subdomain of a domain one owns; the hosts entry is only a local way to obtain such a name.
Step 3: open the page in Microsoft Edge
Navigate to:
http://www.google.example.com:5000/universal_xss.html
Step 4: interact with the page
As the page advises, move the mouse and click somewhere on the page.
Result
An alert appears saying:
Hi, this is JavaScript code running on www.google.com.
That message is the output of the following code executing in the context of the Google website:
alert('Hi, this JavaScript code is running on ' + document.domain)
The report adds that injecting code into any other domain would have been easily possible as well.
Root cause
The design flaw is that the URL Advisor UI is served as first-party content on every domain in Microsoft Edge. On top of that, the UI takes its content from window.postMessage() messages without validating the origin of the sender, and under some circumstances assigns the received data as a link target. A javascript: URL supplied by a malicious page therefore becomes a clickable link inside a first-party frame. Because url_advisor_balloon.html is not protected by X-Frame-Options, the attacker can frame it and use clickjacking to obtain the click that triggers the payload.
The existing defence that would normally limit the damage, serving the UI from a Kaspersky-controlled origin, is present in Firefox and Internet Explorer (via kis.v2.scr.kaspersky-labs.com) but not in the Edge implementation described here. The report does not describe any further validation or mitigation in the Edge UI.
Impact
A malicious website can make users click by pretending to be a game. While the user clicks, the attacker is able to inject code into various internet domains and exfiltrate data in the background. Because the injected code runs in the context of the visited domain, the consequences are not limited to Kaspersky's own UI: any XSS in Kaspersky code is elevated to a Universal XSS. The report frames this as too dangerous to leave in place.
Fix
The report's recommendation is that this user interface should never be served as first-party, even once the vulnerability itself is fixed. Otherwise any XSS vulnerability in Kaspersky code automatically becomes a Universal XSS. The researcher points out that Firefox and Internet Explorer already serve the same UI via kis.v2.scr.kaspersky-labs.com, which keeps vulnerabilities in the UI from affecting other websites, and questions why Microsoft Edge is handled differently. The report does not state which changes, if any, were made.
Variants to test
- Other first-party UI frames. Look for any Kaspersky (or other security product) UI that is served under the visited site's own origin rather than a vendor domain. A positive result is a frame whose URL sits on the target domain and whose content is influenced by page-supplied data.
postMessagehandlers without origin checks. Enumerate frames that listen for messages and test whether they act on data from any origin. A positive result is the frame changing its content, navigation target or link target in response to a message sent from an unrelated origin.- Data assigned as a link target. Where received data becomes an
href, tryjavascript:URLs. A positive result is a clickable link that executes script in the frame's origin. - Framing of vendor UI. Check whether UI frames that are meant to be embedded lack
X-Frame-Optionsor a suitable frame-ancestors policy. A positive result is the frame rendering inside an attacker-controlled page. - Clickjacking to trigger the payload. Combine a framed UI with an overlay that induces a click on the injected link. A positive result is script execution in the context of the visited domain, as demonstrated by the alert in this report.
What happened, in plain words
Kaspersky Internet Security (KIS) is a security program you install on a Windows computer. Among other things it adds a feature called URL Advisor to your web browser. URL Advisor looks at the links on a page and adds small reputation hints next to them, so you can see whether a link is considered safe or suspicious before you click it.
In Microsoft Edge, the small window (called a frame) that draws this URL Advisor information is not loaded from a Kaspersky server. Instead it is loaded as if it belonged to the website you are currently visiting. The researcher, palant, found that this frame can be tricked into running code that the attacker supplies. Because the frame counts as part of the visited website, that code runs with the powers of that website. In other words, a bug in one Kaspersky component turns into a bug on every website at once. That is what "Universal XSS" means: a cross-site scripting flaw that is not limited to one site but applies everywhere the component appears.
The report shows this with a small test page served from the researcher's own computer. When the user moves the mouse and clicks, a pop-up appears that says the JavaScript is running on www.google.com, even though the code came from the attacker's page.
Background you need first
A few ideas come up again and again below, so here they are from zero.
- A web page and its origin. Every page you open has an address, and the browser groups addresses by "origin": the combination of protocol (http or https), host name (for example www.google.com) and port number. The browser uses the origin as a security boundary. Code that runs in the origin of www.google.com can read and change things that belong to www.google.com. Code from a different origin cannot. Think of it like a building: each origin is a separate building with its own keys, and the browser is the doorman who will not let a visitor from one building wander into another.
- JavaScript. The programming language that web pages run inside your browser. It is what makes pages interactive. If an attacker can get their own JavaScript to run inside a page, they can do whatever that page is allowed to do.
- XSS (cross-site scripting). A class of bug where an attacker manages to get their JavaScript to run inside someone else's web page. Normally the damage is limited to that one site. "Universal XSS" is the worse version: the same flaw affects every site at once, because the vulnerable component is present everywhere.
- A frame (iframe). A way to place one web page inside another, like a picture-in-picture window. The inner page keeps its own address and its own origin. A frame is useful for embedding widgets, but it also means one site can show another site's content inside itself.
window.postMessage(). A browser feature that lets one frame send a message to another frame, even when they come from different origins. Because any page can send such a message, the receiving side is supposed to check who sent it (the "origin") before trusting the content. If it does not check, any website can feed it data.javascript:URL. A link whose target starts withjavascript:does not go to another page. Instead the browser runs the text after it as JavaScript. If an attacker can make a link point to ajavascript:URL, then a click on that link runs the attacker's code.- Clickjacking. A trick where the attacker puts an invisible or disguised frame over something the user wants to click, so that the user's click lands on the attacker's target instead. The everyday comparison: someone places a transparent sheet with a fake "Play" button over a real button underneath, and you press what you think is the game.
X-Frame-Options. A response header a website can send to tell browsers "do not put my pages inside a frame on another site". It is a defence against clickjacking. If a page does not send it, other sites are free to frame it.- The hosts file. A small text file on your computer that maps host names to IP addresses before the normal internet lookup happens. Editing it lets you point a name like www.google.example.com at your own machine, which is handy for local testing.
- localhost and ports.
localhostmeans "this computer". A port number (here 5000) is like a door number on that computer, so several services can listen at once without colliding.
The setup used in the report
The researcher recorded the environment like this:
| Item | Value |
|---|---|
| Scope | Application |
| Product name | Kaspersky Internet Security |
| Product version | 19.0.0.1088 |
| OS name and version | Windows 10.0.17134 |
| Attack type | Universal XSS |
| Maximum user privileges needed to reproduce | no privileges |
"No privileges" means you do not need an administrator account or any special role in the product to trigger the bug. The only place administrator rights are needed is editing the hosts file, which is a normal Windows restriction on that file, not part of the attack.
The reproduction uses two files that came with the report, server.py and universal_xss.html, plus Python 3 to run the server. The server listens on http://localhost:5000/, and the report notes that any other web server would work just as well.
How the flaw works
In Microsoft Edge, the URL Advisor frame is served as first-party content on every domain. "First-party" here means the frame's address sits on the same host as the site you are visiting, rather than on a Kaspersky-owned host. The report gives these two example addresses, with the same INJECT_ID value in both:
https://www.google.com/<INJECT_ID>/ua/url_advisor_balloon.html
https://www.yahoocom/<INJECT_ID>/ua/url_advisor_balloon.html
What this shows: the balloon page that draws the URL Advisor pop-up appears under the visited site's own name. <INJECT_ID> is a placeholder in the addresses the report gives. The important part is the host: because the frame's address is on www.google.com (or the site you are on), the browser treats the frame as part of that site. Any JavaScript running inside it therefore runs with that site's origin, and can do what that site's own code could do.
The frame fills itself with content that arrives through window.postMessage(), and it does not check the origin of the sender. Under some circumstances the UI takes that received data and uses it as the target of a link. Put those two facts together and a malicious page can send a message that makes the link point to a javascript: URL. When the user clicks the link, the browser runs the attacker's JavaScript inside the first-party frame, which means inside the visited site's origin.
To get that click, the attacker uses clickjacking. Sites such as google.com send the X-Frame-Options header, which stops other pages from framing them. The url_advisor_balloon.html frame does not have that protection, so an attacker page is free to embed it and place its own decoy on top.
For comparison, the report notes that in Firefox and Internet Explorer the same UI is always served via kis.v2.scr.kaspersky-labs.com. The report says that in Firefox and Internet Explorer the same UI is always served via kis.v2.scr.kaspersky-labs.com, so vulnerabilities there do not affect other websites.
Reproducing it, step by step
Step 1: run the local server
Download the attached server.py and universal_xss.html into a directory and run server.py with Python 3. The report calls it a very rudimentary HTTP server running on http://localhost:5000/, and notes that another web server would do.
Step 2: point a matching host name at your own computer
Edit the hosts file as administrator and add this line:
[redacted] www.google.example.com
Line by line: [redacted] is the address of your own computer (the same as localhost). www.google.example.com is the name you want the browser to use. The line tells Windows: whenever something asks for www.google.example.com, send it to this machine instead of out to the internet. The full path in the report is %WINDIR%\sysnative\drivers\etc\hosts.
The host name has to start with www.google. for URL Advisor to apply to it. That is why the example uses www.google.example.com rather than something arbitrary. The report notes that in real life you would simply use a subdomain of a domain you own; the hosts entry is only a local way to get a matching name without registering anything.
Step 3: open the page in Microsoft Edge
Navigate to:
http://www.google.example.com:5000/universal_xss.html
Reading the address: http is the protocol, www.google.example.com is the name you just pointed at your machine, :5000 is the port your Python server listens on, and /universal_xss.html is the test page. Because the name starts with www.google. URL Advisor applies to it.
Step 4: move the mouse and click
As the page advises, move the mouse and click somewhere on the page.
What you see
An alert appears saying:
Hi, this is JavaScript code running on www.google.com.
That text is the output of this code, running in the context of the Google website:
alert('Hi, this JavaScript code is running on ' + document.domain)
Line by line: alert(...) tells the browser to show a pop-up box with the text inside the brackets. The text is built by joining two pieces with +: the fixed string 'Hi, this JavaScript code is running on ' and the value of document.domain. document.domain is the browser's own record of which site the running code belongs to. Because the pop-up reports www.google.com, the code is running as if it were Google's own code, even though it came from the attacker's page. The report adds that injecting code into any other domain would have been easily possible as well.
Why it works: the root cause
The design decision at the centre of this is that the URL Advisor UI is served as first-party content on every domain in Microsoft Edge. On top of that, the UI takes its content from window.postMessage() messages without checking who sent them, and under some circumstances uses the received data as a link target. A javascript: URL supplied by a malicious page therefore becomes a clickable link inside a first-party frame. And because url_advisor_balloon.html is not protected by X-Frame-Options, the attacker can frame it and use clickjacking to obtain the click that sets the payload off.
The defence that would normally limit the damage, serving the UI from a Kaspersky-controlled origin, exists in Firefox and Internet Explorer (via kis.v2.scr.kaspersky-labs.com) but not in the Edge implementation described here. The report does not describe any further validation or mitigation in the Edge UI.
What an attacker could do with it
A malicious website can make users click by pretending to be a game. While the user clicks, the attacker can inject code into various internet domains and take data out in the background. Because the injected code runs in the context of the visited domain, the consequences are not limited to Kaspersky's own UI: any XSS in Kaspersky code is raised to a Universal XSS. The report says serving this UI as first-party is too dangerous.
The recommended fix
The report's recommendation is that this user interface should never be served as first-party, even once the vulnerability itself is fixed. Otherwise any XSS vulnerability in Kaspersky code automatically becomes a Universal XSS. The researcher points out that Firefox and Internet Explorer already serve the same UI via kis.v2.scr.kaspersky-labs.com, which keeps bugs in the UI from affecting other websites, and asks why Microsoft Edge is handled differently. The report does not state which changes, if any, were made.
Related things worth testing
These are the same ideas generalised, so a tester can look for similar bugs elsewhere.
- Other first-party UI frames. Look for any Kaspersky (or other security product) UI that is served under the visited site's own origin rather than a vendor domain. A positive result is a frame whose address sits on the target domain and whose content is influenced by data the page supplies.
postMessagehandlers without origin checks. Find frames that listen for messages and test whether they act on data from any origin. A positive result is the frame changing its content, its navigation target or its link target in response to a message sent from an unrelated origin.- Data used as a link target. Where received data becomes an
href(the target of a link), tryjavascript:URLs. A positive result is a clickable link that runs script in the frame's origin. - Framing of vendor UI. Check whether UI frames that are meant to be embedded lack
X-Frame-Optionsor a suitable frame-ancestors policy. A positive result is the frame rendering inside an attacker-controlled page. - Clickjacking to trigger the payload. Combine a framed UI with an overlay that induces a click on the injected link. A positive result is script running in the context of the visited domain, as the alert in this report demonstrates.
Glossary
- API: a defined way for one piece of software to talk to another, like a menu of allowed requests and answers.
- Clickjacking: tricking a user into clicking something they did not intend, usually by hiding or disguising the real target under a decoy.
- Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests.
- Cross-site scripting (XSS): a bug that lets an attacker run their own JavaScript inside someone else's web page.
document.domain: the browser's record, available to running JavaScript, of which site the code belongs to.- First-party content: content whose address sits on the same host as the site you are visiting, rather than on a separate vendor host.
- Frame (iframe): a web page embedded inside another web page, keeping its own address and origin.
- Frame-ancestors: a browser policy that says which sites are allowed to embed a page in a frame.
- Hosts file: a local text file that maps host names to IP addresses before normal internet lookup.
href: the attribute of a link that says where the link goes.- HTTP: the protocol browsers and web servers use to exchange pages and data.
- IP address: the numeric address of a machine on a network;
[redacted]means the local machine. - JavaScript: the programming language web pages run in the browser.
javascript:URL: a link target that makes the browser run the text after it as JavaScript instead of navigating.- Kaspersky Internet Security (KIS): a security program for Windows computers.
- localhost: the name for "this computer".
- Origin: the combination of protocol, host name and port that the browser uses as a security boundary between sites.
- Port: a numbered door on a machine, so several services can listen at once.
postMessage(): a browser feature that lets frames send messages to each other, even across origins.- Python 3: a programming language and runtime used here to run the small test server.
- Universal XSS: an XSS flaw in a component that appears on every site, so the injected code runs in the context of any domain the user visits.
- URL Advisor: a Kaspersky feature that annotates links in the browser with reputation information.
X-Frame-Options: a response header a site sends to forbid other sites from framing its pages.