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

Sandbox memory exhaustion #136

Open
andreasley opened this issue Jun 18, 2024 · 0 comments
Open

Sandbox memory exhaustion #136

andreasley opened this issue Jun 18, 2024 · 0 comments

Comments

@andreasley
Copy link

andreasley commented Jun 18, 2024

Commit: 1cece54

I'm running into an interesting issue. Both my XPC server and client are sandboxed and have the requirement .sameTeamIdentifier. After handling about 2000 XPC requests, the following error is logged for every single XPC request:

YourAppNameHere exhausted sandbox memory capacity; may be leaking extensions

The problem originates here:

_ = try URL(resolvingBookmarkData: clientBookmark, bookmarkDataIsStale: &isStale)

The resulting URL is a security-scoped bookmark, meaning a sandbox exception is temporarily granted by the kernel (which stores this information in wired memory, which is finite).

To revoke the exception and release the kernel resources, the following method has to be called on the URL: stopAccessingSecurityScopedResource()
This currently doesn't happen in SecureXPC, so the app leaks kernel memory.

However, the security-scoped resource needs to stay alive until the XPC request is handled, so calling stopAccessingSecurityScopedResource() right after creating the URL won't work (XPC requests will fail).

I've implemented a simple workaround, but that 1) still leaks the first bookmark 2) only works on macOS 11.2 and up, so it's probably not up to this project's standards:

andreasley@0b65dbb

Of course, stopAccessingSecurityScopedResource() could also be called in the XPC client app after the XPC request succeeded or failed.

I'm willing to work on this if you tell me your preferred way.

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

No branches or pull requests

1 participant