Skip to content

core: only allow Host.unixSocket to be used from main client - #6748

Merged
jedevc merged 1 commit into
dagger:mainfrom
sipsma:socket-caller
Feb 27, 2024
Merged

jedevc merged 1 commit into
dagger:mainfrom
sipsma:socket-caller

Conversation

@sipsma

@sipsma sipsma commented Feb 27, 2024

Copy link
Copy Markdown
Contributor

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.0 since 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.

@sipsma sipsma added this to the v0.10.0 milestone Feb 27, 2024
@sipsma
sipsma requested review from jedevc and vito February 27, 2024 03:59
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]>

@jedevc jedevc left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jedevc
jedevc merged commit 01c2eda into dagger:main Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants