Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAS com.apple.security.app-sandbox in entitlements crashes the application #4790

Closed
danutzcodrescu opened this issue Mar 16, 2020 · 32 comments
Closed
Labels

Comments

@danutzcodrescu
Copy link

  • Version: 22.4.1
  • Target: mas

Sandbox entitlement is crashing the mas build on startup. The application works fine if I do not include <key>com.apple.security.app-sandbox</key><true/>, but it is refused by Mac Store. I tried using both mac and mas plist.

I even tried a workaround proposed in [https://github.com/electron/osx-sign/issues/192](this issue) to add to node_modules/app-builder-lib/templates/entitlements.mac.plist the sandbox entitlement. The app crashes.

Here is my build config:

 "build": {
    "productName": "xxxxx",
    "appId": "com.xxx.xx",
    "artifactName": "${productName} Setup-${version}.${ext}",
    "mac": {
      "entitlementsInherit": "build/entitlements.mac.plist",
      "category": "public.app-category.business",
      "extraResources": [
        {
          "from": "./preconfigMac",
          "to": "preconfig",
          "filter": [
            "*.sh"
          ]
        }
      ]
    },
    "directories": {
      "output": "release"
    },
    "files": [
      "dist/",
      "package.json"
    ],
    "protocols": {
      "name": "Test protocol",
      "role": "Viewer",
      "schemes": [
        "test"
      ]
    },
    "mas": {
      "type": "distribution",
      "provisioningProfile": "embedded.provisionprofile",
      "entitlements": "build/entitlements.mas.plist",
      "entitlementsInherit": "build/entitlements.mas.inherit.plist"
    },
    "afterSign": "scripts/notarize.js"
  },

I identified the problem by checking the entitlements of the output. It seems that when I add sandbox entitlement it completely messes up the xml.

Here is the output of codesign -d --entitlements :- Test.app when entitlements do not include sandbox:

Executable=xxxxxx
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>com.apple.security.cs.allow-jit</key>
  <true/>
  <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
  <true/>
  <key>com.apple.security.cs.disable-library-validation</key>
  <true/>
</dict>
</plist>

That is exactly the xml that I have in my entitlements.mas.plist.

However, when I add the sandbox entitlement to mas.plist or to mas.inherit.plist, this is the output:

Executable=xxxxx
bplist00?
                _ com.apple.application-identifier_#com.apple.developer.team-identifier_com.apple.security.app-sandbox_%com.apple.security.application-groups_com.apple.security.cs.allow-jit_6com.apple.security.cs.allow-unsigned-executable-memory_0com.apple.security.cs.disable-library-validation_xxxxxx	?       	       :`???7U`acdef%  

As you can see the entitlements are completely messed up because of the sandbox. Seems that there is some issue in how the entitlements are created during the build.

Any suggestions of what might be wrong?

@werber
Copy link

werber commented Mar 30, 2020

I have identical issue with identical setup. Also I can change entitlements to anything I want and all works except the case when I enable app-sandbox in entitlements. Tried building for mas-dev and mas with different provision profiles and certificates. Any updates on this?

@greenimpala
Copy link
Contributor

Having the exact same issue here too. Add com.apple.security.app-sandbox and the built app will not launch.

@schetle
Copy link
Contributor

schetle commented Apr 8, 2020

The reason the entitlements gets "messed up" is because your entitlements are being regenerated with extra fields, and then binary encoded. This only occurs when com.apple.securirty.app-sandbox is supplied in your entitlements, and is caused by util-entitlements.js in electron-osx-sign.

I'm currently unsure why this process takes place, because my native (non-electron) macOS apps don't have any of the extra stuff electron-osx-sign is adding to the entitlements, and further they are not in the encoded format being used here.

@greenimpala
Copy link
Contributor

greenimpala commented Apr 8, 2020

@schetle yep I think you're right. See electron/osx-sign#223 (comment) for reversal of this binary encoding.

@runofthemillgeek
Copy link

@schetle doesn't the binary encoding stem from the app-builder-bin package and not osx-sign?

@schetle
Copy link
Contributor

schetle commented Apr 8, 2020

@sangeeth96 The originating call for the entitlements (specifically the parent entitlements) getting encoded is in the preAutoEntitlements code in util-entitlements.js from the dependent electron-osx-sign package. The code can be seen on line 88 of util-entitlements.js. It is calling into appBuilder to perform the operation, it looks like, but you can prevent entitlements from getting encoded by preventing the call altogether.

Bypassing that whole section of electron-osx-sign will prevent your entitlements from getting encoded. Take a peek at the file for confirmation of this.

@stale
Copy link

stale bot commented Jul 11, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jul 11, 2020
@mahnunchik
Copy link
Contributor

mahnunchik commented Jul 11, 2020 via email

@stale stale bot removed the backlog label Jul 11, 2020
@stale
Copy link

stale bot commented Sep 10, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Sep 10, 2020
@danutzcodrescu
Copy link
Author

It is relevant and no solution is provided...

@stale stale bot removed the backlog label Sep 10, 2020
@johannesjo
Copy link

One of the many critical issues solved by the great stale bot! 🥳

@stale
Copy link

stale bot commented Nov 9, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Nov 9, 2020
@mahnunchik
Copy link
Contributor

110419_Gipnozhaba

@stale stale bot removed the backlog label Nov 9, 2020
@stale
Copy link

stale bot commented Jan 9, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jan 9, 2021
@mahnunchik
Copy link
Contributor

#4790 (comment)

@stale stale bot removed the backlog label Jan 10, 2021
@stale
Copy link

stale bot commented Mar 19, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Mar 19, 2021
@danutzcodrescu
Copy link
Author

no fix yet...

@Taz-Bizeloper
Copy link

Taz-Bizeloper commented Mar 24, 2021

I had this issue but found out that it was because I was using requestSingleInstanceLock() in the main.js file and this was crashing the mas-dev build when setting sandbox in the entitlements

electron/electron#15958

@stale stale bot removed the backlog label Mar 24, 2021
@czzonet
Copy link

czzonet commented Apr 11, 2021

The mas-dev runs well after I install the correct provisionprofile. My crash info was 'EXC_CRASH (Code Signature Invalid)'.

"electron-builder": "22.10.5"

@stale
Copy link

stale bot commented Jun 11, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jun 11, 2021
@mahnunchik
Copy link
Contributor

#4790 (comment)

@stale
Copy link

stale bot commented Aug 22, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Aug 22, 2021
@stale stale bot closed this as completed Sep 21, 2021
@danutzcodrescu
Copy link
Author

#4790 (comment)

@devon2018
Copy link

☝️

@hisnameisjimmy
Copy link

I'm still running into this exact issue. How do we fix this?

@fatemehmarzoughi
Copy link

Same here (

@gregoiregentil
Copy link

I have the same issue. Is there a basic entitlement file working somewhere?

@tylerlong
Copy link

tylerlong commented Feb 27, 2023

I had been stuck on this issue for 2-3 days and finally I made it work!
Let me share the keys with your guys:

Put *.plist files and *.provisionprofile files in the root of build/ folder

I didn't do that, and my app quit right after I saw a window and no error was thrown.

Install the *.provisionprofile file

I generated a *.provisionprofile file and I told electron-builder where it is.
But I didn't double click to install it to my operating system.
I spent almost a day before I realized that I needed to install it.

There are lots of mistakes that you can make. The two above are the ones that cost me most time.

@gregoiregentil
Copy link

On my side, this issue #7229 helped me to resolve the problem.

@mordom0404
Copy link

Thank you so much for your solution here, this solved a problem that had been bugging me for weeks, especially the second point.
It should be pointed out that the plist file and provisionprofile file can be placed anywhere, as long as it can be referenced normally, not necessarily in the ./build folder
Regarding the second point, it took me 2 days to successfully install this provisionprofile into the system, until I found this link: "Provisioning profile does not allow this device." Mac mini M1
The key point is that both your mac's UUID and UDID should be added to apple developer's device id list, and make sure they both exist in the provisionprofile.
At this point, my mas-dev can finally run normally.
Hope these experience can help latecomers and thank you again.

I had been stuck on this issue for 2-3 days and finally I made it work! Let me share the keys with your guys:

Put *.plist files and *.provisionprofile files in the root of build/ folder

I didn't do that, and my app quit right after I saw a window and no error was thrown.

Install the *.provisionprofile file

I generated a *.provisionprofile file and I told electron-builder where it is. But I didn't double click to install it to my operating system. I spent almost a day before I realized that I needed to install it.

There are lots of mistakes that you can make. The two above are the ones that cost me most time.

@p3x-robot
Copy link

anyone fixed this? I have sandbox but it quits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests