# File System Access API - vulnerabilities

Chrome's File System Access API save dialog displayed a spoofed file type (JPEG) while writing a .lnk file, enabling code execution on Windows.

- Payout: $5,000
- Severity: high
- Program: Google
- Found by: Maciej Pulikowski
- Disclosed: 2021-03-22
- CVE: CVE-2021-21123, CVE-2021-21129, CVE-2021-21130, CVE-2021-21131, CVE-2021-21172, CVE-2021-21141
- Write-up quality: 6/10
- Original: https://github.com/Puliczek/CVE-2021-21123-PoC-Google-Chrome
- Library page: https://bugbountylibrary.com/r/blog%3Agithub-com-puliczek-cve-2021-21123-poc-google-chrome
- Tags: area:os domain:browser impact:rce kind:bounty platform:blog sev:high tech:chromium technique:chained technique:unicode-normalization vuln:file-upload vuln:misconfiguration

**Target:** Chrome File System Access API (showSaveFilePicker / getFileHandle) save dialog
**Root cause:** The save-as dialog derived the displayed 'Save as type' from a user-controlled description/extension string rather than the actual filename, so a .lnk file could be presented as a JPEG image.
**Steps:**
1. Open example_showSaveFilePicker.html in Chrome 86/87 on Windows, Mac, and Linux.
2. Call `showSaveFilePicker()` with a suggested name like `virus.jpg.lnk` and a type description `JPEG Image (*.jpg)`.
3. Dialog shows 'Save as type: JPEG (.jpg)' but writes `virus.jpg.lnk`.
4. Variant: use RTL characters, trailing spaces/periods, long descriptions, or many whitespace to further spoof the extension.
5. For CVE-2021-21172 use `getFileHandle()` to save a .lnk file to a selected folder (works in Chrome 86, 87, and 88; patched in 89+).
**How found:** Researcher explored the new File System Access API's save dialog and noticed the displayed file type came from the description string, not the real filename, then tested extension-spoofing tricks (RTL, whitespace, trailing dots, long descriptions).
**Exploitation:** Attacker hosts a page that triggers the save dialog; victim saves the file believing it is a JPEG, then opens the .lnk which runs PowerShell to download and execute virus.exe.
**Escalation:** Chained with a .lnk payload that invokes PowerShell to fetch and run a remote executable, turning a file-save spoof into RCE on the victim host.
**Insight:** When a new browser API renders a save/open dialog, compare the displayed type/extension against the actual written filename; description strings are often trusted for display while the real name is attacker-controlled.

