Skip to content

ffi.callback() issues in code-signed, notarized MacOS app #270

Open
@mattgwwalker

Description

@mattgwwalker

Hi,

Do you have any experience with this error message?
builtins.MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks

I've spent all week dealing with the joys of code signing my work for macOS, only for this error to show its head on Friday evening.

One option looks to be just to accept that this code is dangerous and to apply the work around of giving my application the entitlement com.apple.security.cs.allow-unsigned-executable-memory. Maybe for a demo that sounds like a sufficient approach, but Apple's not exactly all roses over this: "Including this entitlement exposes your app to common vulnerabilities in memory-unsafe code languages. Carefully consider whether your app needs this exception." CFFI is even less positive:

[...] it is dangerous to allow write+execute memory in your program; that’s why the various “hardening” options above exist. But at the same time, these options open wide the door to another attack: if the program forks and then attempts to call any of the ffi.callback(), then this immediately results in a crash—or, with a minimal amount of work from an attacker, arbitrary code execution. To me it sounds even more dangerous than the original problem, and that’s why cffi is not playing along.

Another option is to look into converting sounddevice to the new style callbacks.

Regarding these new style callbacks, do you have any advice/feedback/experience/bald patches from already pulling your hair out over this?

Cheers,

Matthew

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions