erikberglund / SwiftPrivilegedHelper

Example application using a privileged helper tool with authentication in an unsandboxed application written in Swift
MIT License
182 stars 34 forks source link

Non sandboxed app #2

Closed ghost closed 6 years ago

ghost commented 7 years ago

This sample project helped me understanding the concept of how a helper tool is installed. But when I finally added all the components to my own project, I always got an errAuthorizationDenied error when calling AuthorizationCreate.

After investigating the issue, I found out that the AuthorizationCreate is now allowed in a sandboxed app. I then saw that this sample project is not sandboxed, which leads to my question: Why create a helper tool at all and not just call the code itself?

Is it even possible to have a helper tool with privileged rights?

erikberglund commented 7 years ago

Hi. I created this example project to help a few people that were asking for ways to create an internal tool that was going to use privilege escalation. I have not heard of ways to escalate your privileges within a sandbox, so if you have links to that information I would be interested to read about that.

When I have been reading about sandboxing this feature is the first thing listed as unsupported: AppSandboxDesignGuide

The following app behaviors are incompatible with App Sandbox: Use of Authorization Services With App Sandbox, you cannot do work with the functions described in Authorization Services C Reference.

And here: authorization_services

Important The Authorization Services API is not supported within an App Sandbox because the API allows privilege escalation.

BUT, that is only for escalating privileges, and it probably wasn't clear in this project that it was designed to do that. I could update the description to make it more clear.

You could very well use a helper tool without escalating privileges to separate your code for improved security or move some work to another process. You could watch this session from WWDC for a sandboxed example of that: WWDC2012-Cocoa Interprocess Communication with XPC. It also speaks on why you would want to use a helper.

Some code in this example should still be valid for that, you just have to remove the privilege escalation parts and you can just call the code in the helper without verifying or escalating the privileges.

I have one call checkWithoutAuthorization that does just that. So that should be usable in the sandbox.

But, you would have to change these parts: installHelper, to not try and install a privileged helper, and just install a standard helper.

I haven't done that so I don't have any direct examples unfortunately.

erikberglund commented 7 years ago

I update the readme and short description to be more clear that it's only for unsandboxed applications.

ghost commented 7 years ago

Thanks for the reply. Let me just clarifiy what I am trying to do:

So, if I understand you correctly, I don't need special privileges, right? So a helper app would still be an option?

Regards, Sascha