Skip to content

Don't expose the whole system to the container #1649

Closed

Description

@dongdigua

"--volume", "/:/run/host:rslave",

Are you serious?
If something goes wrong in the container, it will affect the WHOLE host system.

Activity

  1. dongdigua commented on May 20, 2025

    @dongdigua
    Author

    ok fine, many toolbox implementations use this practice

  2. juhp commented on May 21, 2025

    @juhp
    Contributor

    It is read-only

  3. debarshiray commented on Jun 23, 2025

    @debarshiray
    Member

    Are you serious?

    Yes. :P

    If something goes wrong in the container, it will affect the WHOLE host system.

    Yes, only as far as the user that invoked toolbox(1) has access. As the website says:
    Toolbx makes no promise about security beyond what’s already available in the usual command line environment on the host that everybody is familiar with.

    There's some context here: #183

    Exposing the whole host file system is necessary to bypass the immutability of OCI containers. Otherwise, updating Toolbx won't give access to new locations from the host to containers created by older Toolbx versions.

  4. dongdigua commented on Jun 24, 2025

    @dongdigua
    Author

    (seems my email didn't arrive)

    Yes, only as far as the user that invoked toolbox(1) has access. As the website says: Toolbx makes no promise about security beyond what’s already available in the usual command line environment on the host that everybody is familiar with.
    ere's some context here: #183

    Exposing the whole host file system is necessary to bypass the immutability of OCI containers. Otherwise, updating Toolbx won't give access to new locations from the host to containers created by older Toolbx versions.

    oh, this makes sense

  5. Abdull commented on Jun 25, 2025

    @Abdull

    It is read-only

    By now I believe there are two separate universes:

    • in one universe, toolbx behaves just as its maintainers expierence it.
    • in the other universe, toolbx behaves how some of its outsider users experience it (<--- I live in this universe).
    # on Debian 12 bookworm
    
    # from the outside host:
    toolbox --version
    # toolbox version 0.1.2
    # just freshly installed from sources
    
    toolbox create --distro ubuntu --release 22.04
    
    toolbox enter ubuntu-toolbox-22.04
    
    #######
    # now inside container:
    echo "hello from inside toolbx container" >/tmp/from-inside-toolbx-container
    
    echo "another hello from inside toolbx container" >/run/host/tmp/file-inside-container-run-host-tmp
    #######
    
    # from the outside host:
    cat /tmp/from-inside-toolbx-container
    # gives stdout output: "hello from inside toolbx container"
    
    cat /run/host/tmp/file-inside-container-run-host-tmp
    another hello from inside toolbx container
    
    • How come that the container's /tmp directory is shared-modifiable-and-identical to host's /tmp directory?
    • How come that the container's /run/host/tmp directory is shared-modifiable-and-identical to host's /tmp directory? This is not what I understand as "it is read-only".
    • Indeed the directories /tmp and invoking-user's $HOME directory are 1:1 bidirectionally identical, shared, and synchronized ("1:1-mapped") between host and the toolbx container.
      • are there any other directories that are 1:1-mapped? I cannot find any information about this in the toolbx documentation.

    I expect GitHub issues like this issue popping up eternally as long as the toolbx documentation, website, and main README.md do not explicitly disambiguate what to expect and what not to expect with respect to filesystem isolation. And indeed, the current documentation gives onboarding users several chances for building up incorrect believes into toolbx's behavior/scope:

  6. dongdigua commented on Jun 25, 2025

    @dongdigua
    Author

    It is read-only

    By now I believe there are two separate universes:

    * in one universe, _toolbx_ behaves just as its maintainers expierence it.
    
    * in the other universe, _toolbx_ behaves how some of its outsider users experience it (<--- I live in this universe).
    
    # on Debian 12 bookworm
    
    # from the outside host:
    toolbox --version
    # toolbox version 0.1.2
    # just freshly installed from sources
    
    toolbox create --distro ubuntu --release 22.04
    
    toolbox enter ubuntu-toolbox-22.04
    
    #######
    # now inside container:
    echo "hello from inside toolbx container" >/tmp/from-inside-toolbx-container
    
    echo "another hello from inside toolbx container" >/run/host/tmp/file-inside-container-run-host-tmp
    #######
    
    # from the outside host:
    cat /tmp/from-inside-toolbx-container
    # gives stdout output: "hello from inside toolbx container"
    
    cat /run/host/tmp/file-inside-container-run-host-tmp
    another hello from inside toolbx container
    

    YES, IT'S NOT READ-ONLY
    that line of code I referenced explains it well, it's rslave, not ro

    I expect GitHub issues like this issue popping up eternally as long as the toolbx documentation, website, and main README.md do not explicitly disambiguate what to expect and what not to expect with respect to filesystem isolation. And indeed, the current documentation gives onboarding users several chances for building up incorrect believes into toolbx's behavior/scope:

    * "[_Toolbx supports a number of distributions, allowing you to run development environments totally separate from the host operating system._](https://containertoolbx.org/distros/)"
      
      * "totally separate" would include a totally separate file system.
    
    * "[_The development environment can be set up inside the container in the same way as on the host operating system. No longer will project environments clash with the host OS, nor will it be limited to a single OS version._](https://containertoolbx.org/use/#command-line-tools--libraries)"
      
      * But: installing _gdb_ inside the container **will** have that _gdb_ use my host system user's `~/.config/gdb/gdbinit` configuration file.
      * But: my host system's [_meson_ is installed at `~/.local/bin/meson`](https://mesonbuild.com/Getting-meson.html). It is therefore leaked into any toolbx container, albeit in a broken state.
    

    I do agree that the documentation should be more explict
    look what OpenSUSE/microos-toolbox says:
    https://github.com/openSUSE/microos-toolbox/blob/b335d1b3bc1178673a41ee5d13fe7e31ee638982/toolbox.1.md?plain=1#L17
    and their website

    Root filesystem available below /media/root

  7. debarshiray commented on Jun 26, 2025

    @debarshiray
    Member

    It is read-only

    By now I believe there are two separate universes:

    There's no need to insult someone who was trying to help, after I added more context and insight into the situation.

    are there any other directories that are 1:1-mapped? I cannot find any information about this in the toolbx documentation.

    I don't think there is an bullet point list of directories anywhere.

    The documentation does broadly describe how a Toolbx container is configured:

    The toolbox(1) manual page and online documentation says:

    Toolbx environments have seamless access to the user’s home directory, the Wayland and X11 sockets, networking (including Avahi), removable devices (like USB sticks), systemd journal, SSH agent, D-Bus, ulimits, /dev and the udev database, etc..

    ...

    Note that Toolbx makes no promise about security beyond what’s already available in the usual command line environment on the host that everybody is familiar with.

    The toolbox-create(1) manual page further says:

    The user ID and account details from the host is propagated into the Toolbx container, SELinux label separation is disabled, and the host file system can be accessed by the container at /run/host. The container has access to the host's Kerberos credentials cache if it's configured to use KCM caches.

    ...

    The entry point of a Toolbx container customizes the container to fit the current user by ensuring that it has a user that matches the one on the host, and grants it sudo and root access.

    Crucial configuration files, such as /etc/host.conf, /etc/hosts, /etc/localtime, /etc/resolv.conf and /etc/timezone, inside the container are kept synchronized with the host. The entry point also bind mounts various subsets of the host's file system hierarchy to their corresponding locations inside the container to provide seamless integration with the host. This includes /run/libvirt, /run/systemd/journal, /run/udev/data, /var/lib/libvirt, /var/lib/systemd/coredump, /var/log/journal and others.

    We can certainly try to update the documentation to address concerns that users face, and it needs to be updated to keep up with Toolbx's code.

    I expect GitHub issues like this issue popping up eternally as long as the toolbx documentation, website, and main README.md do not explicitly disambiguate what to expect and what not to expect with respect to filesystem isolation. And indeed, the current documentation gives onboarding users several chances for building up incorrect believes into toolbx's behavior/scope:

    "Toolbx supports a number of distributions, allowing you to run development environments totally separate from the host operating system."

    "totally separate" would include a totally separate file system.

    "The development environment can be set up inside the container in the same way as on the host operating system. No longer will project environments clash with the host OS, nor will it be limited to a single OS version."

    The phrase "host operating system" is used in this context to mean the host's /usr, which is a separate file system from the container's. We can try to make it more explicit in the documentation. Feel free to send pull requests for the website and the manual pages if you have any specific ideas.

    But: installing gdb inside the container will have that gdb use my host system user's ~/.config/gdb/gdbinit configuration file.

    Are you seeing incompatibilities between GDB versions and configuration files?

    But: my host system's meson is installed at ~/.local/bin/meson. It is therefore leaked into any toolbx container, albeit in a broken state.

    What is the exact breakage that you are seeing?

  8. debarshiray commented on Jun 26, 2025

    @debarshiray
    Member

    I do agree that the documentation should be more explict look what OpenSUSE/microos-toolbox says: https://github.com/openSUSE/microos-toolbox/blob/b335d1b3bc1178673a41ee5d13fe7e31ee638982/toolbox.1.md?plain=1#L17 and their website

    Root filesystem available below /media/root

    toolbox-create(1):
    ... the host file system can be accessed by the container at /run/host.

  9. debarshiray commented on Jul 28, 2025

    @debarshiray
    Member
    * "[_Toolbx supports a number of distributions, allowing you to run development environments totally separate from the host operating system._](https://containertoolbx.org/distros/)"
      
      * "totally separate" would include a totally separate file system.
    

    This line got dropped when the text on the containertoolbx.org/distros page got reworded in containers/containertoolbx.org@0db2950 because it wasn't central to the topic of the page.

    * "[_The development environment can be set up inside the container in the same way as on the host operating system. No longer will project environments clash with the host OS, nor will it be limited to a single OS version._](https://containertoolbx.org/use/#command-line-tools--libraries)"
      
      * But: installing _gdb_ inside the container **will** have that _gdb_ use my host system user's `~/.config/gdb/gdbinit` configuration file.
      * But: my host system's [_meson_ is installed at `~/.local/bin/meson`](https://mesonbuild.com/Getting-meson.html). It is therefore leaked into any toolbx container, albeit in a broken state.
    

    Clarified in containers/containertoolbx.org@81c1f77

  10. debarshiray commented on Jul 28, 2025

    @debarshiray
    Member

    We can certainly try to update the documentation to address concerns that users face, and it needs to be updated to keep up with Toolbx's code.

    Added a section on how the containers are configured to prominently mention the most important parts outside the manual pages for the create and init-container commands: containers/containertoolbx.org@ad9af82

  11. 16 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions