Repository navigation
macOS entitlements and entries for Info.plist disallow developing and running certain types of apps via VSCode #119787
Copy link
Copy link
Closed
Labels
author-verification-requestedIssues potentially verifiable by issue authorIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code InsidersmacosIssues with VS Code on MAC/OS XIssues with VS Code on MAC/OS XterminalGeneral terminal issues that don't fall under another labelGeneral terminal issues that don't fall under another labelverifiedVerification succeededVerification succeeded
Milestone
Description
- VS Code Version: 1.54.3
- OS Version: macOS 10.15.7 (19H524)
Steps to Reproduce:
- macOS specific
- Develop a project in VSCode that somewhere down the chain uses call to
NSAppleScript. In my case it is an Electron project thatspawns multiple native binaries written in Swift where one of them usesNSAppleScriptand pipes data between Electron main process and native runtime. - Run the project through VSCode terminal (in my case it is live reloading Electron project).
- macOS security system will not ask user permission to allow access for VSCode to some other apps AE dictionary.
- Yes, VSCode, not the app developed via VSCode, because VSCode encapsulates the process and spawned subprocesses, it is the main bundle in this case.
- When some process wants to access AE dictionaries for other apps a permission to macOS is asked which in turn results in permissions dialog represented to user. Permission can be denied or granted, and the entry with chosen allowance will show up in Automation anchor under System preferences : Security & Privacy.
- In order for this to work the bundle that encapsulates the runtime that uses AE has to have
entitlement
<key>com.apple.security.automation.apple-events</key>
<true/>Info.plist entry
<key>NSAppleEventsUsageDescription</key>
<string>Bla bla</string>N.B. Entries NSAppleScriptEnabled and OSAScriptingDefinition are different beasts.
- Due to VSCode entitlements and Info.plist settings the call will not go through, that is - process running in VSCode terminal will not signal macOS gatekeeper that permission to access specific app AE is asked, user (in this case a developer using VSCode) will not be notified, System preferences : Security & Privacy : Automation will not populate, and app development/debugging cannot happen.
- Note that current VSCode setup passes through subprocesses that need Accessibility and Screen Recording permissions (I use them in my binaries, too) - System preferences : Security & Privacy anchors Accessibility and Screen Recording will populate. Not relevant to me, but I imagine that other permissions under
com.apple.security.*cases might fail Apple docs on Hardened Runtime
IMHO, VSCode should open up permissions as its terminal serves for live debugging apps that may ask different kind of permissions to OS. Due to the very nature of VSCode I consider this to be a bug not missing feature.
Does this issue occur when all extensions are disabled?: Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
author-verification-requestedIssues potentially verifiable by issue authorIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code InsidersmacosIssues with VS Code on MAC/OS XIssues with VS Code on MAC/OS XterminalGeneral terminal issues that don't fall under another labelGeneral terminal issues that don't fall under another labelverifiedVerification succeededVerification succeeded
Activity
deepak1556 commentedon Mar 25, 2021
Thanks for the detailed issue report, this is another variation of #95062. I haven't enabled these entitlements mainly because of the permission model around it, once a user grants these permissions to the app it is not only gonna help the terminal process but also other untrusted processes, specifically in our case the extension process. Say for example a bad extension wants to use some apple events or media device access, to a user the permission dialog will only mention that vscode wants this permission, there is no way to intercept this flow currently within vscode and explicitly tell the user who is asking for it and why.
Alternatively if I can enable these entitlements on a particular helper executable and not for the app, it would also allow some granularity to control these permissions for the app. It is unfortunate that the vscode terminal is expected to behave as the OS terminal but the permissions are tied down because of the app. I am happy to explore solutions that would not give the extension process these privileged entitlements.
Is it not possible to execute your app from the vscode terminal using the Launchservice (ex: open) that would ensure the app process is not related to vscode.
kroko commentedon Mar 25, 2021
Thanks for your time!
Security was on my mind
hence I mentioned that Accessibility and Screen Recording passes though. It already is a game where if user trusts VSCode in those areas, then the user is stripped naked for a rogue processes, be extensions or from within terminal. I can get all the data about user activity, mouselog, keylog via VSCode (via other means than AE,
NSEvent.addGlobalMonitorForEvents,NSWorkspace.shared.notificationCenterobservers,CoreGraphicsand other beasts), I know that first hand - the very Electron app I develop spawns native binaries that I have written that do that by design.Having those permissions already open probably is not a strong argument for enabling AE access, enabling yet another potential attack type via VSCode. I understand and respect your stance that VSCode has to do everything it can to protect the developer from malicious extensions, although I do not necessarily agree with it. I would set that responsibility on developer to choose wisely, disallowing AE is like shutting down pet door to an house while leaving open all the other doors, garage and windows. We are dealing Nodejs under the hood too, this is not i.e. Deno.
I will think about it. For example macOS 11 now comes with some new ways of doing things regarding permissions, but still the API regarding reading, asking for and self-disalowing is still unfinished. If there was a solution it would be hacky, I'm pulling my hair out how unfinished and rushed things are from Apple side for security-related APIs since changes in 10.15.
One instant idea that comes into mind is⚠️
tccutil.tccutil reset AppleEvents com.microsoft.VSCodeon every launch, thus every developer session in VSCode gets flushed permissions for AppleScript (andtccutil reset ScreenCapture, tccutil reset Accessibilitytoo). Thus VSCode user gets poked quite a lot if any extension uses AppleScript and maybe one will think twice, why the hell VSCode asks for it.<key>NSAppleEventsUsageDescription</key>can contain UTF8 emojis bringing attention to think twice too. 😸Other idea is that VSCode implements yet another "helper" - a custom app bundle that sits along
Code Helper.apps, call it SecurityHelper.app. It would be some kind of middleware - it exposes endpoint that must be used by any extension that wants to call applescript, extension sends in serialised json containing whoami and eastringtoexecute, middleware decides to execute or not and if yes does that and returns result. Then again - so much stuff to do for only one platform and only one potential attack vector while all others are open. And that would not solve my issue that some process within terminal wants to use AE.Hopefully you will not close this ticket, let it marinate a bit.
Yes and No.
No. It is an Electron project developed in VSCode. In development everything is watched, live reloaded, transported to console etc
electronmon(one of many packages that wrapsnpm run electronand restarts on changes) so that everything is streamlined, app autorestarts when changes in main and preload processes happen. Another VSCode terminal tab for that.child_process.spawns binaries that access stuff where al kinds of permissions are needed from OS. Even if I formulated those native binaries asnode_gyps it would be just another abstraction layer, it does not matter how I get that native OS bridge within nodejs userland in the context of this ticket.npm runswithin VSCode terminal.Yes. But that would bring out the process in such a manner that VSCode terminal is not needed any more - back to ground zero, where VSCode for text editing, and some other terminal (Terminal / iTerm / whatever) for running and observing.
deepak1556 commentedon Mar 30, 2021
Sorry for the delayed response, we had discussed this internally and decided to enable the following entitlements.
kroko commentedon Mar 31, 2021
Thank you! Apart from entitlements
NSAppleEventsUsageDescriptiontoInfo.plistNSCameraUsageDescriptionandNSMicrophoneUsageDescriptionalready are inherited by VSCode from Electron base.They could be reformulated though for uberclarity if one knows that VSCode itself will not use those features
This app needs access to (AppleScript | the camera | the microphone)
=>
⚠ An extension or a process in terminal within Visual Studio Code wants to use (AppleScript | your camera | your microphone). By allowing this feature you allow all future requests of this type from any process within Visual Studio Code. You can disable this permission at any time in System Preferences. ⚠
or smth like that. Decorated with U+26A0 (
⚠) which should be safe.FYI to reset permissions programmatically (which would allow VSCode to have a menu entry under Preferences or Help to disallow itself)
or just
full list (will differ based on os version)
deepak1556 commentedon Mar 31, 2021
Given that these access in most situations are performed under a user triggered action in the terminal or extension they have installed, I don't think we need to be specific in the wording and just follow suite of what other mac IDE apps do.
I don't think we want to add these helpers to the app. A user should just default to the OS for clearing these permissions and not look for way to perform it from within the app.
vscode-triage-bot commentedon Apr 28, 2021
This bug has been fixed in the latest release of VS Code Insiders!
Reinis Adovičs / kroko (@kroko), you can help us out by commenting
/verifiedif things are now working as expected.If things still don't seem right, please ensure you're on version 13f1aff of Insiders (today's or later - you can use
Help: Aboutin the command palette to check), and leave a comment letting us know what isn't working as expected.Happy Coding!
paulvonallwoerden commentedon Apr 30, 2021
/verified
chore: add media and apple event entitlements