Skip to content
New issue

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

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

Already on GitHub? # to your account

Sandbox prevent localhost listening on MacOS #5221

Open
maiste opened this issue Aug 4, 2022 · 2 comments
Open

Sandbox prevent localhost listening on MacOS #5221

maiste opened this issue Aug 4, 2022 · 2 comments

Comments

@maiste
Copy link

maiste commented Aug 4, 2022

The MacOS sandbox seems to prevent opening a connection on localhost. On the CI MacOS worker, the localhost:port binding raised:

Unix.Unix_error(Unix.EPERM, "bind", "")

@kit-ty-kate executed a command to test it and it also failed:

% ~/.opam/opam-init/hooks/sandbox.sh build nc -l 8000
nc: Operation not permitted

Would there be a way to tweak sandbox-exec to support it?

@kit-ty-kate
Copy link
Member

It looks like a hard problem to fix sadly :/
sandbox-exec does not seem to support creating a new network namespace like bubblewrap --unshare-net can.
The best that can be done is:

(allow network* (local ip "localhost:*"))

but this would allow possible outside attackers to connect to the macOS machine remotely (I tested it) and maybe even highjacking some of the already open ports (not tested)

@maiste
Copy link
Author

maiste commented Oct 10, 2022

Spending some time looking at it this weekend; here is what I've found.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants