Repository navigation
core: only allow Host.unixSocket to be used from main client - #6748
Merged
Merged
Conversation
Before this, it was technically possible for a module to make a raw graphql query to the Host.unixSocket API and gain access to any unix socket on the main client caller's host (i.e. where the CLI is running). This is due to the fact that the socket attachable currently has to be hardcoded to always refer to the main client caller (which in turn is due to relevant grpc metadata not being forwarded by buildkit yet in those codepaths). Now we just enforce that this API can only ever be called from the main client caller. This is okay for now because we don't yet support passing unix sockets around modules. We do want to support that in the near future, but it will require some tweaks upstream in buildkit and more plumbing in our own code to carefully track which module has access to a given socket based on being explicitly passed it as an arg (or embedded in the DAG of some arg like a Container). This change just blocks that backdoor in the meantime. Signed-off-by: Erik Sipsma <[email protected]>
sipsma
force-pushed
the
socket-caller
branch
from
February 27, 2024 04:00
945203e to
9689044
Compare
jedevc
approved these changes
Feb 27, 2024
Contributor
There was a problem hiding this comment.
I think this is fine for a quick addition before the release 🎉
Curious if you thought about an approach like #6535? In addition to typesHiddenFromModuleSDKs, we could have typesProtectedFromModuleSDKs.
What's the reason that a module should even have graphql access to any of the Host API, maybe I'm missing something.
Edit: oh I see - yes, these functions will still get called when passed by ID, so we'd need something like the dagql.Instance trick that we do for secrets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this, it was technically possible for a module to make a raw graphql query to the Host.unixSocket API and gain access to any unix socket on the main client caller's host (i.e. where the CLI is running). This is due to the fact that the socket attachable currently has to be hardcoded to always refer to the main client caller (which in turn is due to relevant grpc metadata not being forwarded by buildkit yet in those codepaths).
Now we just enforce that this API can only ever be called from the main client caller. This is okay for now because we don't yet support passing unix sockets around modules. We do want to support that in the near future, but it will require some tweaks upstream in buildkit and more plumbing in our own code to carefully track which module has access to a given socket based on being explicitly passed it as an arg (or embedded in the DAG of some arg like a Container). This change just blocks that backdoor in the meantime.
Support for the above is tracked here: #6747
Adding to
v0.10.0since this is quite trivial and very nice-to-have for general security+sandboxing. However, similar to #6601 I wouldn't consider this a total blocker since we haven't exactly hardened against every possible malicious module yet.