Insufficient data validation in Permission Prompts (CVE-2023-7012)
Chrome automatically handles the mailto, news, and snews URL schemes without asking the user. On macOS, an attacker could register a malicious application for the news or snews scheme and then use a website to launch it, leading to arbitrary code execution.
- Fix shipped in 11 months
Steps to reproduce the problem:
1、Browse poc.html in any version chrome.
2、git clone https://github.com/koocola/test_app.git
3、open the click_me button or wait 30s then you will see calculator open
Problem Description:
mailto, news, snews are three external url scheme which will be handled by default[1] without asking user for permission in chrome[1][2].
It's ok in windows or linux and it can be regarded as a feature. However, it can result in critical security impact in macos.
[1]
[2]
constexpr const char* kAllowedSchemes[] = {
"mailto", "news", "snews",
};
In macos, most user don’t have an application to handle “news” and “snews” url scheme. And if an application was download from network. Macos system will **automatically** register the application’s url scheme from its info.plist. Turns out if a malicious application with “news” and “snews” url scheme mentioned in there info.plist. Then chrome can use “snews://xxx” or “news://xxx” to open it. Lead to arbitrary code execution.
However, macos has there own security mechanism called gatekeeper to detect user open the application from network directly. If user download an application from network directly. Then the file will be set a flag “com.apple.quarantine”. The first open of an application with this flag will ask user whether they really want to open this application which is from network.
There are two possibly attack situation through my research:
1、Using git or curl(eg..).
If an application is downloaded from git or curl. It will not set the flag “com.apple.quarantine”. It means the application can be opened without any warning message. So bypass the gatekeeper.
So there has a attack situation.
User visit attacker’s website. Attacker could guide user to use git to clone a malicious github or gitlab repo which include a malicious application has “news” and “snews” url scheme mentioned in there info.plist. Once git clone success. the “news” and “snews” url scheme will be registered to mac. Then the website in chrome can use “news” or “snews” url scheme to open the malicious app.
**In this attack situation. The only thing user should do is to git clone a repo. User will not realize this operation has any security impact. And then rce and sbx escape will be achieved.**
2、 With a gatekeeper bypass bug in mac.
Although user may upgrade chrome to the newest version. there operation system may not upgrade to the newest. And the version of user’s operation system information will be sent to attacker by the first get requests user requests the website. If a user’s operation system is lower then 15.1( user don’t upgrade there system after july, 2022). User can use cve-2022-32910(See https://www.jamf.com/blog/jamf-threat-labs-macos-archive-utility-vulnerability/) to bypass gatekeeper.
So there has a attack situation.
A user don’t upgrade there operation system from july,2022. A user visit attacker's website. Attacker’s website automatically download a zip file. User curiously click the zip file then macos will automatically unzip it. Then a malicious application will be released to user’s computer and “news”,snews url scheme is registered. After that , the website can open this malicious application without user's permission with the url scheme being registered.
**In this attack situation. The only thing user should do is to unzip a zip file download from chrome.**
Additional Comments:
Report credit: koocola and Guang Gong of 360 Vulnerability Research Institute
**Chrome version: ** 106.0.0.0 **Channel: ** Stable
OS: Mac OS
Context
Chrome treats a small set of external URL schemes as safe to hand off to the operating system without asking the user first. The report points at the handler source and at the allowlist that drives this behaviour:
constexpr const char\* kAllowedSchemes[] = {
"mailto", "news", "snews",
};
So when a page navigates to a mailto:, news: or snews: URL, Chrome passes it to the OS without a permission prompt. On Windows and Linux the researcher considers this acceptable and calls it a feature. The problem is what macOS does with the news and snews schemes.
Setup
The proof of concept was tested on macOS with Chrome 106.0.0.0, Stable channel. The researcher states that the issue reproduces in any version of Chrome, so no special build is needed. Two pieces are required:
- A page (
poc.html) that triggers the scheme navigation. - A test application repository, cloned from GitHub, whose
info.plistdeclares thenewsandsnewsschemes.
Finding it
Most macOS users have no application registered for news or snews. macOS automatically registers the URL schemes declared in an application's info.plist when that application is downloaded from the network. If a malicious application declares news and snews, Chrome can launch it through snews://xxx or news://xxx, which the researcher describes as leading to arbitrary code execution.
The obvious defence is Gatekeeper: a file downloaded from the network is tagged with the com.apple.quarantine flag, and the first launch of a quarantined application prompts the user to confirm. The researcher found two ways around that prompt.
Exploitation
Step 1: serve the page and clone the repository
The reproduction steps are:
- Browse
poc.htmlin any version of Chrome. - Clone the test application:
git clone https://github.com/koocola/test_app.git
- Open the
click_mebutton, or wait 30 seconds, and the calculator opens.
Opening the click_me button, or waiting 30 seconds, causes the calculator to open.
Step 2: bypass Gatekeeper with git or curl
When an application is downloaded with git or curl, the com.apple.quarantine flag is not set. The application can therefore be opened without any warning, which bypasses Gatekeeper.
The attack flow is:
- The user visits the attacker's website.
- The attacker guides the user into cloning a malicious GitHub or GitLab repository with
git. The repository contains an application whoseinfo.plistdeclares thenewsandsnewsschemes. - Once the clone succeeds, the schemes are registered with macOS.
- The website in Chrome navigates to a
news://orsnews://URL and opens the malicious application.
In this scenario the only action the user takes is cloning a repository, an operation that does not look security-relevant. The researcher states that remote code execution and sandbox escape would then be achieved.
Step 3: bypass Gatekeeper with a macOS bug
A user may keep Chrome up to date while leaving the operating system behind. The OS version is sent to the attacker in the first GET request the user makes to the website, so the attacker can target older systems. If the OS is lower than 15.1, meaning the user has not upgraded since July 2022, CVE-2022-32910 can be used to bypass Gatekeeper. The report links to a Jamf Threat Labs write-up on a macOS Archive Utility vulnerability for that bug.
The attack flow is:
- The user has not upgraded the OS since July 2022 and visits the attacker's website.
- The website automatically downloads a zip file.
- The user clicks the zip file and macOS automatically unzips it.
- A malicious application is released onto the computer and the
newsandsnewsschemes are registered. - The website opens the malicious application through the registered scheme without the user's permission.
Here the only action the user takes is unzipping a file downloaded through Chrome.
Root cause
Chrome's external protocol handler treats mailto, news and snews as allowed schemes and hands them to the OS without a permission prompt. On macOS, scheme registration is automatic for applications that declare the scheme in info.plist, so an unregistered scheme becomes an execution path to attacker-supplied code. Gatekeeper is the only barrier, and it does not apply to files fetched with git or curl, nor to systems vulnerable to CVE-2022-32910. The report does not describe any change to the handler or the allowlist.
Impact
An attacker who can get a malicious application onto a macOS host, either through a git clone the user performs or through a zip file unzipped on an OS older than 15.1, can have Chrome launch it without a prompt. The researcher describes the result as arbitrary code execution and sandbox escape. The attack depends on user interaction (cloning a repository or unzipping a file) and on the target running macOS; the researcher considers the behaviour acceptable on Windows and Linux.
Fix
The report does not state what was changed. The natural fix, given the root cause, is to stop treating news and snews as schemes that can be launched without a permission prompt, at least on macOS.
Variants to test
- Check other schemes in the allowlist on platforms where they map to registered applications. A positive result is a scheme navigation that launches an application with no browser prompt.
- Test whether downloads made by other command-line tools (beyond
gitandcurl) also skip thecom.apple.quarantineflag. A positive result is an application that launches without the Gatekeeper confirmation. - Test scheme registration from archives extracted by the OS on patched and unpatched macOS versions. A positive result is a registered scheme that Chrome can invoke immediately after extraction.
What happened, in plain words
Chrome has a short list of special kinds of web links that it hands straight to your computer's operating system without asking you first. One of those kinds is the mailto: link, which opens your email program when you click an email address on a web page. You have probably seen that happen: you click an address, and your mail app pops up. Chrome does not stop to ask "do you want to open your mail app?" because it considers that harmless.
The researcher found that two other kinds of link on that same trusted list, news: and snews:, are not harmless on a Mac. On macOS, when an application is downloaded from the internet, the system reads a small settings file inside it (called info.plist) and registers any link types the application claims to handle. So a malicious application can say "I handle news: links", get itself registered, and then a website can make Chrome launch it just by pointing the browser at a news: link. No prompt, no warning. The researcher describes the result as arbitrary code execution, meaning the attacker's program runs on your machine.
Normally macOS has a safety net called Gatekeeper that warns you the first time you open an application that came from the internet. The report describes two ways around that warning: downloading the application with tools like git or curl, which do not mark the file as downloaded, or using an older macOS version that has a separate Gatekeeper bug. In both cases the user does something that looks completely ordinary, like cloning a code repository or unzipping a file, and the malicious application ends up running.
Background: the pieces involved
Before the steps make sense, here are the parts of the system the report relies on.
URL schemes. A URL is normally something like https://example.com/page. The part before the colon, https, is called the scheme. It tells the browser what kind of address this is and therefore what to do with it. https means "fetch a web page". mailto means "open an email program and start a message". Other schemes exist for other purposes, and the operating system keeps a registry of which installed application handles which scheme.
Chrome's external protocol handler. When a page points the browser at a scheme Chrome cannot display itself, Chrome has to hand the address to the operating system, which then finds the right application. This hand-off is called an external protocol. Chrome normally asks the user for permission before doing this, because launching another program is a meaningful action. But some schemes are on an allowlist, a list of things treated as safe enough to skip the question.
The allowlist. The report quotes the source code that defines which schemes skip the prompt:
constexpr const char\* kAllowedSchemes[] = {
"mailto", "news", "snews",
};
Line by line: constexpr means this is a fixed value decided when the program is built, not something that changes while it runs. const char\* is the type of each entry, a pointer to a piece of text. kAllowedSchemes[] is the name of the list, with the empty brackets meaning it holds several entries. The three lines inside the braces are the entries themselves: "mailto", "news" and "snews". So the list contains exactly three schemes, and any navigation to one of them is passed to the operating system without a permission prompt.
info.plist. Every macOS application is really a folder with a particular structure, and inside it is a file called info.plist. It is a settings file written in a structured text format. Among other things it can declare which URL schemes the application handles. When macOS learns about an application, it reads this file and adds the declared schemes to its registry, so that future links of that kind open that application.
Gatekeeper and the quarantine flag. macOS marks files that arrive from the internet with an attribute called com.apple.quarantine. The first time you try to open a file carrying that mark, Gatekeeper shows a dialog asking whether you really want to open something downloaded from the network. This is the safety net the report is trying to get around.
Arbitrary code execution and sandbox escape. Arbitrary code execution means an attacker gets their own program to run on your computer, rather than being limited to what a web page can do inside the browser. A sandbox is the restricted environment a browser tab runs in, designed so that even a compromised page cannot touch the rest of the system. A sandbox escape means getting out of that restricted environment. The researcher states that both are achieved here.
Setting up the test
The proof of concept was tested on macOS with Chrome 106.0.0.0 on the Stable channel, which is the ordinary release most people run. The researcher notes that the problem reproduces in any version of Chrome, so no special build is needed. Two things are required:
- A web page, named
poc.html, that triggers the navigation to the special scheme. - A test application, stored in a repository on GitHub, whose
info.plistdeclares thenewsandsnewsschemes.
A repository here just means a folder of files hosted on a code-sharing site, which other people can copy down to their own machine.
Finding the problem
Most Mac users have no application at all registered for news or snews. That matters, because it means the slot is free: whoever registers first gets to handle those links. macOS registers the schemes declared in an application's info.plist automatically when the application is downloaded from the network. So a malicious application that declares news and snews gets those schemes registered for itself. After that, Chrome can launch it through a snews://xxx or news://xxx address, and the researcher describes this as leading to arbitrary code execution.
The obvious defence is Gatekeeper. A file downloaded from the network is tagged with the com.apple.quarantine flag, and the first launch of a quarantined application prompts the user to confirm. The researcher found two ways around that prompt, described in the next section.
Exploitation
Step 1: serve the page and clone the repository
The reproduction steps are:
- Browse
poc.htmlin any version of Chrome. - Clone the test application:
git clone https://github.com/koocola/test_app.git
Line by line: git is a program for copying and tracking code repositories. clone is the instruction to make a full local copy of a repository. https://github.com/koocola/test_app.git is the address of the repository being copied. Running this command downloads the whole test application folder, including its info.plist, onto the user's machine.
- Open the
click_mebutton, or wait 30 seconds, and the calculator opens.
Opening the click_me button, or waiting 30 seconds, causes the calculator to open.
Step 2: bypass Gatekeeper with git or curl
When an application is downloaded with git or curl, the com.apple.quarantine flag is not set. curl is a command-line tool for fetching files from the internet. Because the flag is missing, the application can be opened without any warning, which bypasses Gatekeeper entirely.
The attack flow is:
- The user visits the attacker's website.
- The attacker guides the user into cloning a malicious GitHub or GitLab repository with
git. The repository contains an application whoseinfo.plistdeclares thenewsandsnewsschemes. - Once the clone succeeds, the schemes are registered with macOS.
- The website in Chrome navigates to a
news://orsnews://URL and opens the malicious application.
In this scenario the only action the user takes is cloning a repository, an operation that does not look security-relevant. Developers do it all the time. The researcher states that remote code execution and sandbox escape would then be achieved.
Step 3: bypass Gatekeeper with a macOS bug
A user may keep Chrome up to date while leaving the operating system behind. The OS version is sent to the attacker in the first GET request the user makes to the website. A GET request is the ordinary request a browser sends when it asks a server for a page, and it carries some information about the browser and the system making it. So the attacker can tell which systems are old and target only those. If the OS is lower than 15.1, meaning the user has not upgraded since July 2022, CVE-2022-32910 can be used to bypass Gatekeeper. CVE stands for Common Vulnerabilities and Exposures: it is a public catalogue number given to a known security flaw so people can refer to it unambiguously. The report links to a Jamf Threat Labs write-up on a macOS Archive Utility vulnerability for that bug.
The attack flow is:
- The user has not upgraded the OS since July 2022 and visits the attacker's website.
- The website automatically downloads a zip file.
- The user clicks the zip file and macOS automatically unzips it.
- A malicious application is released onto the computer and the
newsandsnewsschemes are registered. - The website opens the malicious application through the registered scheme without the user's permission.
Here the only action the user takes is unzipping a file downloaded through Chrome, which again looks like an everyday thing to do.
Root cause
Chrome's external protocol handler treats mailto, news and snews as allowed schemes and hands them to the OS without a permission prompt. On macOS, scheme registration is automatic for applications that declare the scheme in info.plist, so an unregistered scheme becomes an execution path to attacker-supplied code. Gatekeeper is the only barrier, and it does not apply to files fetched with git or curl, nor to systems vulnerable to CVE-2022-32910. The report does not describe any change to the handler or the allowlist.
Impact
An attacker who can get a malicious application onto a macOS host, either through a git clone the user performs or through a zip file unzipped on an OS older than 15.1, can have Chrome launch it without a prompt. The researcher describes the result as arbitrary code execution and sandbox escape. The attack depends on user interaction (cloning a repository or unzipping a file) and on the target running macOS; the researcher considers the behaviour acceptable on Windows and Linux.
Fix
The report does not state what was changed. The natural fix, given the root cause, is to stop treating news and snews as schemes that can be launched without a permission prompt, at least on macOS.
Variants to test
- Check other schemes in the allowlist on platforms where they map to registered applications. A positive result is a scheme navigation that launches an application with no browser prompt.
- Test whether downloads made by other command-line tools (beyond
gitandcurl) also skip thecom.apple.quarantineflag. A positive result is an application that launches without the Gatekeeper confirmation. - Test scheme registration from archives extracted by the OS on patched and unpatched macOS versions. A positive result is a registered scheme that Chrome can invoke immediately after extraction.
Glossary
- Allowlist: a list of items that are trusted by default and skip a check that everything else has to pass.
- Arbitrary code execution: a situation where an attacker gets their own program to run on a victim's computer.
- Chrome VRP: Chrome's Vulnerability Reward Program, the scheme that pays researchers for reporting security bugs in Chrome.
com.apple.quarantine: a marker macOS attaches to files that came from the internet, used by Gatekeeper to decide whether to warn before opening them.curl: a command-line program for downloading files and data from the internet.- CVE: Common Vulnerabilities and Exposures, a public numbering system for known security flaws.
- External protocol handler: the part of a browser that passes a link the browser cannot display itself to the operating system, which then opens the right application.
- Gatekeeper: a macOS security feature that warns the user before opening applications downloaded from the internet.
- GET request: the ordinary request a browser sends to a server when asking for a page; it carries some information about the browser and system.
git: a program for copying and tracking code repositories.git clone: the command that makes a full local copy of a remote repository.info.plist: a settings file inside every macOS application, which can declare, among other things, which URL schemes the application handles.- macOS: Apple's operating system for Mac computers.
- Permission prompt: a dialog asking the user to approve an action before it happens.
- Proof of concept (PoC): a small demonstration that shows a vulnerability is real, without needing to be a full attack.
- Remote code execution (RCE): the same idea as arbitrary code execution, with the attacker working from a remote location such as a website.
- Repository: a folder of files, usually code, hosted somewhere like GitHub or GitLab so others can copy it.
- Sandbox: a restricted environment a program runs in, so that if it is compromised it cannot affect the rest of the system.
- Sandbox escape: getting out of that restricted environment.
- Stable channel: the ordinary release of Chrome that most users run, as opposed to test or developer builds.
- URL scheme: the part of an address before the colon, such as
httpsormailto, which tells the system what kind of address it is and what should handle it. - Zip file: a single file that packs other files inside it in compressed form; unzipping extracts them.