-
-
Notifications
You must be signed in to change notification settings - Fork 232
[Docs]: Tenant isolation guide #3913
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
Changes from all commits
2e1adb1
5ca159b
c053acd
d7f85d7
43fae1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| --- | ||
| title: Tenant isolation | ||
| description: Restricting access to hosts managed by dstack | ||
| --- | ||
|
|
||
| # Tenant isolation | ||
|
|
||
| `dstack` assumes mutual trust between users of the same project. While users' jobs run in Docker containers, users and their containers may have broad access to the underlying hosts. This guide explains how to restrict access to the host when stronger boundaries are required. | ||
|
|
||
| !!! info "Isolation guarantees" | ||
| The methods described in this guide should be treated as best-effort hardening measures, not as a guarantee of isolation between users, as isolation ultimately depends on the underlying hardware and software. For the strongest isolation, place users in separate `dstack` projects and avoid sharing hardware between them. | ||
|
|
||
|
|
||
| ## Host SSH access | ||
|
|
||
| While attached to a run, users can SSH directly into the host machine — not just the container — using: | ||
|
|
||
| ```shell | ||
| ssh <run-name>-host | ||
| ``` | ||
|
|
||
| This gives unrestricted access to the underlying instance, bypassing container boundaries. | ||
|
|
||
| If desired, host SSH access can be disabled server-wide by configuring the [SSH proxy](server-deployment.md#ssh-proxy) and setting the following environment variable when starting the `dstack` server: | ||
|
|
||
| ```shell | ||
| DSTACK_SERVER_SSHPROXY_ENFORCED=1 | ||
| ``` | ||
|
|
||
| With this setting, all users' SSH connections go through the SSH proxy, which only allows connections into the container and not into the host. | ||
|
|
||
| ## Privileged mode | ||
|
|
||
| Running a container in privileged mode gives it full access to the host kernel, making container escape straightforward. `dstack` supports requesting privileged mode through several configuration properties: | ||
|
|
||
| | Property | Applies to | | ||
| |---|---| | ||
| | `privileged: true` | Tasks, dev environments, services | | ||
| | `docker: true` | Tasks, dev environments, services | | ||
| | `replicas[i].privileged: true` | Services with replica groups | | ||
| | `replicas[i].docker: true` | Services with replica groups | | ||
|
|
||
| To block runs that request privileged mode, write a [REST plugin](../reference/plugins/rest/index.md) or a [Python plugin](../reference/plugins/python/index.md) with an apply policy. | ||
|
|
||
| ## Instance volumes | ||
|
|
||
| [Instance volumes](../concepts/volumes.md#instance-volumes) mount a path from the host filesystem directly into the container. A user with access to this feature can mount arbitrary host paths — including sensitive directories such as `/etc`, `/proc`, or `/var`. | ||
|
|
||
| You can disallow instance volumes or restrict access to certain paths by writing a [REST plugin](../reference/plugins/rest/index.md) or a [Python plugin](../reference/plugins/python/index.md). | ||
|
|
||
| ## Host network access | ||
|
|
||
| By default, most `dstack` jobs run in host networking mode. This allows them to listen on any host network interface and communicate with other jobs over the internal network, which facilitates workloads such as [distributed tasks](../concepts/tasks.md#distributed-tasks) or [services with routers](../concepts/services.md#pd-disaggregation). | ||
|
|
||
| However, exposing the host network to the job also exposes internal `dstack` APIs used to manage containers and SSH authorized keys on the host. If this is not acceptable, bridge networking should be used, which isolates the job from the host network. Bridge networking, however, breaks workloads that do need inter-job communication. | ||
|
|
||
| The `DSTACK_SERVER_JOB_NETWORK_MODE` environment variable controls which jobs get host vs. bridge networking: | ||
|
|
||
| | Value | Name | Behavior | | ||
| |---|---|---| | ||
| | `1` | `HOST_FOR_MULTINODE_ONLY` | Host for distributed tasks, bridge otherwise | | ||
| | `2` | `HOST_WHEN_POSSIBLE` | Host whenever the job occupies a full instance (default) | | ||
| | `3` | `FORCED_BRIDGE` | Always bridge, including distributed tasks | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must be explicit that this prevents both distributed tasks and PD disaggregation to work
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, distributed tasks can still work with I've updated the section to describe the difference between host and bridge networking, and mentioned that host networking facilitates distributed tasks and routers. This should help users make a more informed decision |
||
|
|
||
| ### No distributed tasks | ||
|
|
||
| If you don't need distributed tasks or other runs with inter-job communication, you can set `DSTACK_SERVER_JOB_NETWORK_MODE=3` when starting the server: | ||
|
|
||
| ```shell | ||
| DSTACK_SERVER_JOB_NETWORK_MODE=3 | ||
| ``` | ||
|
|
||
| This forces bridge networking for all jobs on the server without exception, preventing access to internal `dstack` APIs, as well as communication between jobs. | ||
|
|
||
| ### Allow distributed tasks in selected projects | ||
|
|
||
| If you want distributed tasks or other runs with inter-job communication to be available in some projects but not others, use `DSTACK_SERVER_JOB_NETWORK_MODE=1` instead. With this mode, single-node jobs get bridge networking, while distributed tasks still run with host networking. Distributed tasks can then be selectively blocked per project or user by writing a [REST plugin](../reference/plugins/rest/index.md) or a [Python plugin](../reference/plugins/python/index.md). | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOn't we want to include a guide on how to set up SSH proxy here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a reference to the deployment guide, I wouldn't duplicate the guide here