Skip to content
Info disclosure Write-up Intermediate

Targeting Visual Studio Code for macOS: File Discovery and a TCC bypass (kinda)

Visual Studio Code stores recently opened files and unsaved edits in locations outside Apple's TCC protection, allowing an attacker with local access to read files that would otherwise be protected. The attacker can also modify unsaved edits, which are loaded when VSCode restarts.

Alfie Champion Follow

Published on ajpc500.github.io

In many environments, macOS endpoint users are synonymous with software and systems engineers. One application commonly used among this user group is Microsoft’s Visual Studio Code, aka VSCode.

Alfie Champion, on ajpc500.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely VSCode stores recent file paths and unsaved edit backups in user-writable locations that fall outside TCC's protected paths, so any process running as the user can read or modify them.

Impact

An attacker with local access could read files that TCC would otherwise protect and could alter unsaved edits, though the text notes the issue was reported and neither Apple nor MSRC deemed it to warrant a fix.

What the attacker needed

Local access as the victim user; VSCode installed and used; victim has unsaved edits or recent files

How it was found

  1. Obtain an initial foothold on the macOS endpoint as the user.
  2. Read VSCode's global state sqlite database to list recently opened files and folders.
  3. Alternatively, read the storage.json file to extract recent items from the menu bar data.
  4. Inspect the Backups directory to find unsaved edits of files, including those protected by TCC.
  5. Modify a backup file to change the unsaved edit.
  6. Restart VSCode to load the modified backup content.

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 write-up has not been written yet. The Original tab links to the source.

TCC is a macOS security feature that stops apps from reading sensitive folders like Documents without permission. VSCode keeps copies of files you edit in a backup folder that TCC does not protect, so malware running as your user can read those copies. The attacker can also change the backup so that when you restart VSCode, you see altered content.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.