Skip to content

Cork should use macOS-native PAM authorization instead of ingesting an admin password #593

Open

Description

@elsiehupp

Note: I initially posted this as a security issue on Homebrew's GitHub, but apparently I misremembered, and the Homebrew CLI actually does properly support Touch ID, so this seems to be specific to Cork and not Homebrew.

Hopefully I haven't misremembered again; I could swear I got hit with a bunch of password prompts when I was adopting apps into Homebrew using Cork...

Currently Cork seemingly passes sudo password prompts through to the user by directly ingesting an admin password as a string.

EDIT: Yep! I just got hit with this prompt!

password prompt

This behavior is particularly noticeable if the user has enabled PAM support for Touch ID, as Cork does not provide passthrough Touch ID support via PAM.

I have observed this same behavior in other places, where it is generally identified as a known security issue.

In the comments on basically this same issue for Balena Etcher I noted that Raspberry Pi Imager does in fact implement this correctly, providing a representative sample of how to call PAM authorization from non-native code, albeit in Objective-C++ rather than Swift (or TypeScript). [Direct link to Raspberry Pi Imager code]

Off the top of my head I don't know if Raspberry Pi Imager is license-compatible with Cork, but the useful thing with the code sample is just that it shows what precisely is involved in requesting sudo access from Apple's system APIs rather than simply ingesting the administrator password as a string.

I am not a Swift developer, but I imagine that since you are already using Apple's system APIs it should be relatively simple to add similar functionality to Cork.

Activity

  1. buresdv commented on Jan 28, 2026

    @buresdv
    Owner

    The problem with PAM is that this is blocked by Homebrew itself. When you spawn a Homerbew process through Swift's Process, it can only be a non-root process, because Homebrew does not execute root processes and errors out.

    It has a weird implementation where it requires the admin password to be passed through the SUDO_ASKPASS variable.

    I already tried it before using PAM and couldn't do it, which is why this custom implementation is needed. There's no way to escalate privileges through PAM and then pass the password to the SUDO_ASKPASS variable, as far as I was able to find.

    If the Homebrew developers wanted to talk to me on this, I'd be open to resolving this issue on their end, but they do not want to cooperate, so I had to resort to this solution.

  2. elsiehupp commented on Jan 30, 2026

    @elsiehupp
    Author

    [Homebrew] has a weird implementation where it requires the admin password to be passed through the SUDO_ASKPASS variable.

    Is this perhaps an instance where pinentry-mac could be used? If so, that might just be the simplest solution here...

  3. Forge-Falcon commented on Mar 28, 2026

    @Forge-Falcon

    The way around this would be to install a launch deamon for executing brew commands, and have corkbrew communicate with that. No one else is doing this right now, so would really elevate your product.

    Unprivlaged user with cork brew > Launch Deamon (root) *[1] > Service Account (non-root) *[2] > Brew.

    1. Root account can run brew commands as service account using sudo -H -iu homebrew_svc_account brew ...
    2. Service account in sudoers but without the password requirement, prevents brew from complaining echo "homebrew_svc_account ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/homebrew
  4. moved this from To be Sorted to Ideas in Cork Project Boardon Jul 15, 2026
  5. buresdv commented on Jul 15, 2026

    @buresdv
    Owner

    I keep thinking about this and I believe it would require a custom rewrite of the whole package installation process. Step in if it doesn't make sense.

    The problem is much more complex than it might seem at first:

    • You can't escalate the process right off the bat, because not every Homebrew workflow needs elevated privileges, and there's not way to know when a process needs additional privileges until it gets to an install/removal/etc. process that requires elevated privileges
    • At the same time, you can't run a root-owned Homebrew process, because that is blocked by Homebrew itself
    • You also can't escalate the process mid-execution; when the install process inside Homebrew encounters an action that requires escalated permissions, it only escalates system actions (like move, copy, etc.) and not the Homebrew process itself
    • What's worse, I also can't intercept the lines that would tell me that additional permissions are required - I have no way to, for example, halt the process and restart it. At that point, it would take about as much effort to implement support for restarting these processes, as just rewriting the process itself
    • Even a privileged helper wouldn't work, because we would still need to perform the system actions only, anyway - as I said above, we can't escalate the process itself mid-execution

    So the only option that remains is to rewrite the whole process and handle the privileged actions in that process.

    I think this would be a long-term task better suited for https://github.com/buresdv/Spirytus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions