-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
block-network not working as expected in darwin-sandbox #10068
Comments
/cc @buchgr |
Confirmed; on 10.14.6, the following sandbox.sb profile will allow external network access from curl:
(To test, call To block network access, either one of the following is sufficient:
|
I think our sandbox-exec specification is just wrong and sandbox-exec swallows it without complaining.
Note that there is no Also note that |
Thanks @tetromino for reporting and thanks @jmmv for investigating! I guess this is just the sandbox profile API changing underneath our feet. When I initially wrote the profile, I based it on the reverse engineered documentation available on the internet. Looking at the profiles in /usr/share/sandbox, I see a lot of features that didn't exist at the time. I'd suggest to first add a test that proves that it's currently not working (e.g. test that it should block, but doesn't) and then add a fix for the profile that turns the test green. |
I think this deserves being a P1 bug given that, the longer this remains broken, the more projects will gain rules that violate the sandboxing restrictions. |
But I'm concerned that fixing this issue can actually be seen as a breaking change... so sent https://groups.google.com/g/bazel-dev/c/PDhzYQd6umE to seek guidance. |
Remove the check_supported_platform helper function, which was used to prevent running integration tests on non-Linux systems -- even when those tests would have been useful for a long while. Instead, check for OS-specific requirements where appropriate. To make this work, fix the file system related test to work on macOS and explicitly disable a few that really are Linux-specific. Prerequisite to address #10068 as we'll want to have integration tests to validate that the fix remains functional across macOS upgrades. RELNOTES: None. PiperOrigin-RevId: 278471566
To give an update on this, I have a one-line fix ready (it's just a matter of removing the |
This uncovers a divergence in localhost sandboxing between Linux and macOS, which in theory should not exist based on the code... but somehow does. Added a TODO to investigate later. Prerequisite for #10068. RELNOTES: None. PiperOrigin-RevId: 279949248
Should be fixed now. Please let me know if you confirm. |
This allows, for example, Bazel to run itself within an integration test. (Ideally Bazel would be using a Unix socket here, but allowing loopback connections within a test seems legitimate.) I'm not sure why `(allow network-bind)`, which I found in the various configuration files in /usr/share/sandbox/ doesn't work... but I think this change opens up the sandbox in the minimal way to allow this. Fixes #10305 and improves upon #10068. RELNOTES: None. PiperOrigin-RevId: 282735849
Description of the problem / feature request:
When using
block-network
tags with strategydarwin-sandbox
, network calls are not blocked as expected.To reproduce:
What operating system are you running Bazel on?
macOS 10.14.6
What's the output of
bazel info release
?Have you found anything relevant by searching the web?
Tried issues, bazel-discuss, and stack. Did not find anything relevant.
From reading the source, it seems like
darwin-sanbox
should support blocking network:https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java;l=341?q=%22allow%20network%22&ss=bazel
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: