[GH-ISSUE #3258] vscode: cannot isolate sandboxes (RUNUSER socket) #2046

Closed
opened 2026-05-05 08:43:03 -06:00 by gitea-mirror · 16 comments
Owner

Originally created by @pcrockett on GitHub (Mar 1, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3258

I'm trying to create some general-purpose sandboxes. I have a work and a personal profile, and I launch them like this:

firejail --profile=work openbox &
firejail --profile=personal openbox &

The problem is that programs in my two sandboxes still seem to be able to interact.

  1. In personal openbox instance, launch VSCodium. It runs, and everything looks ok so far.
  2. In work openbox instance, also launch VSCodium. A new window opens in my personal sandbox alongside the VSCodium instance that's already running there, not in my work sandbox.

VSCodium always seems to want to open new windows in the first environment it's started in, whether inside a sandbox or not. I'm not sure how VSCodium is working behind the scenes to be able to break out of its sandbox. How do I figure that out and fix it?

Here's my personal profile. My work profile is identical, except in a few places instead of "personal" it says "work".

# Copy/paste/modified from default.profile

# Persistent local customizations
include default.local
# Persistent global definitions
include globals.local

# generic gui profile
# depending on your usage, you can enable some of the commands below:

include disable-common.inc
# include disable-devel.inc
# include disable-interpreters.inc
include disable-passwdmgr.inc
# include disable-programs.inc
#include disable-xdg.inc

caps.drop all
ipc-namespace
netfilter
no3d
# nodbus
nodvd
nogroups
nonewprivs
noroot
# nosound
notv
# nou2f
# novideo
protocol unix,inet,inet6
seccomp
# shell none
x11

disable-mnt
private /home/phil/sandboxes/personal
# private-bin program
private-cache
private-dev
# private-etc none
# private-lib
private-tmp

# memory-deny-write-execute
# noexec /home/phil
noexec /tmp

net wlan0

hostname personal
machine-id
join-or-start personal
Originally created by @pcrockett on GitHub (Mar 1, 2020). Original GitHub issue: https://github.com/netblue30/firejail/issues/3258 I'm trying to create some general-purpose sandboxes. I have a work and a personal profile, and I launch them like this: ```bash firejail --profile=work openbox & firejail --profile=personal openbox & ``` The problem is that programs in my two sandboxes still seem to be able to interact. 1. In personal openbox instance, launch VSCodium. It runs, and everything looks ok so far. 2. In work openbox instance, also launch VSCodium. A new window opens in my _personal_ sandbox alongside the VSCodium instance that's already running there, not in my work sandbox. VSCodium always seems to want to open new windows in the first environment it's started in, whether inside a sandbox or not. I'm not sure how VSCodium is working behind the scenes to be able to break out of its sandbox. How do I figure that out and fix it? Here's my _personal_ profile. My _work_ profile is identical, except in a few places instead of "personal" it says "work". ```plaintext # Copy/paste/modified from default.profile # Persistent local customizations include default.local # Persistent global definitions include globals.local # generic gui profile # depending on your usage, you can enable some of the commands below: include disable-common.inc # include disable-devel.inc # include disable-interpreters.inc include disable-passwdmgr.inc # include disable-programs.inc #include disable-xdg.inc caps.drop all ipc-namespace netfilter no3d # nodbus nodvd nogroups nonewprivs noroot # nosound notv # nou2f # novideo protocol unix,inet,inet6 seccomp # shell none x11 disable-mnt private /home/phil/sandboxes/personal # private-bin program private-cache private-dev # private-etc none # private-lib private-tmp # memory-deny-write-execute # noexec /home/phil noexec /tmp net wlan0 hostname personal machine-id join-or-start personal ```
Author
Owner

@Vincent43 commented on GitHub (Mar 1, 2020):

nodbus

Try uncommenting it. You may also try whitelist things in ${RUNUSER}.

<!-- gh-comment-id:593083191 --> @Vincent43 commented on GitHub (Mar 1, 2020): > # nodbus Try uncommenting it. You may also try `whitelist` things in `${RUNUSER}`.
Author
Owner

@pcrockett commented on GitHub (Mar 1, 2020):

Unfortunately that seems to have no effect. Looks like VSCodium isn't using DBus for inter-process communication.

At least now I know what DBus is, and why I'd want to disable it!

What would whitelisting things in ${RUNUSER} achieve? I figured I'd need to blacklist stuff to get VSCodium to behave. And what specifically in ${RUNUSER} would I want to whitelist?

<!-- gh-comment-id:593085317 --> @pcrockett commented on GitHub (Mar 1, 2020): Unfortunately that seems to have no effect. Looks like VSCodium isn't using DBus for inter-process communication. At least now I know what DBus is, and why I'd want to disable it! What would whitelisting things in `${RUNUSER}` achieve? I figured I'd need to blacklist stuff to get VSCodium to behave. And what specifically in `${RUNUSER}` would I want to whitelist?
Author
Owner

@rusty-snake commented on GitHub (Mar 1, 2020):

Try

# wayland socket:
whitelist ${RUNUSER}/wayland-0
# Xauthority for Xorg-sessions started by gdm:
whitelist ${RUNUSER}/gdm/Xauthority
# pulseaudio
whitelist ${RUNUSER}/pulse
# DBus session-bus:
whitelist ${RUNUSER}/bus

What would whitelisting things in ${RUNUSER} achieve?

Only whitelisted files are visible.

<!-- gh-comment-id:593085830 --> @rusty-snake commented on GitHub (Mar 1, 2020): Try ``` # wayland socket: whitelist ${RUNUSER}/wayland-0 # Xauthority for Xorg-sessions started by gdm: whitelist ${RUNUSER}/gdm/Xauthority # pulseaudio whitelist ${RUNUSER}/pulse # DBus session-bus: whitelist ${RUNUSER}/bus ``` > What would whitelisting things in ${RUNUSER} achieve? Only whitelisted files are visible.
Author
Owner

@pcrockett commented on GitHub (Mar 1, 2020):

Ok, I gave that a try. Interesting results:

  • I couldn't whitelist ${RUNUSER}/pulse or ${RUNUSER}/bus; firejail gave me a "Error: invalid whitelist path" message
  • Still not sure why whitelisting would prevent VSCodium from escaping its jail
  • I did decide to take a look in the /run/user/1000 directory and found some vscode-blah-blah-random-stuff.sock files. I guess that's where the problem lies. Perhaps I need to do an overlay file system for ${RUNUSER} or something?
<!-- gh-comment-id:593086807 --> @pcrockett commented on GitHub (Mar 1, 2020): Ok, I gave that a try. Interesting results: * I couldn't whitelist `${RUNUSER}/pulse` or `${RUNUSER}/bus`; firejail gave me a "Error: invalid whitelist path" message * Still not sure why _whitelisting_ would prevent VSCodium from escaping its jail * I _did_ decide to take a look in the `/run/user/1000` directory and found some `vscode-blah-blah-random-stuff.sock` files. I guess that's where the problem lies. Perhaps I need to do an overlay file system for `${RUNUSER}` or something?
Author
Owner

@rusty-snake commented on GitHub (Mar 1, 2020):

Perhaps I need to do an overlay file system for ${RUNUSER} or something?

Thats what whitelist ${RUNUSER}/foo does.

ls /run/user/1000
firejail --noprofile '--whitelist=${RUNUSER}/systemd' ls /run/user/1000
<!-- gh-comment-id:593088098 --> @rusty-snake commented on GitHub (Mar 1, 2020): > Perhaps I need to do an overlay file system for ${RUNUSER} or something? Thats what `whitelist ${RUNUSER}/foo` does. ``` ls /run/user/1000 firejail --noprofile '--whitelist=${RUNUSER}/systemd' ls /run/user/1000 ```
Author
Owner

@pcrockett commented on GitHub (Mar 1, 2020):

Oh I get it! That makes so much more sense then.

With that command, I get this error message:

Error: invalid whitelist path /run/user/1000/systemd

Not a terribly helpful error message I must say. The file does exist.

<!-- gh-comment-id:593123062 --> @pcrockett commented on GitHub (Mar 1, 2020): Oh I get it! That makes so much more sense then. With that command, I get this error message: > Error: invalid whitelist path /run/user/1000/systemd Not a terribly helpful error message I must say. The file does exist.
Author
Owner

@pcrockett commented on GitHub (Mar 1, 2020):

From the profile man page about the whitelist setting:

A temporary file system is mounted on the top directory, and the whitelisted files are mount-binded inside. Modifications to whitelisted files are persistent, everything else is discarded when the sandbox is closed. The top directory could be user home, /dev, /etc, /media, /mnt, /opt, /srv, /sys/module, /usr/share, /var, and /tmp.

So it looks like anything under /run can't be whitelisted. It does look like tmpfs will do the trick, but sadly that requires running as root. 🙁

<!-- gh-comment-id:593124353 --> @pcrockett commented on GitHub (Mar 1, 2020): From the [profile man page][1] about the whitelist setting: > A temporary file system is mounted on the top directory, and the whitelisted files are mount-binded inside. Modifications to whitelisted files are persistent, everything else is discarded when the sandbox is closed. The top directory could be user home, /dev, /etc, /media, /mnt, /opt, /srv, /sys/module, /usr/share, /var, and /tmp. So it looks like anything under /run can't be whitelisted. It does look like `tmpfs` will do the trick, but sadly that requires running as root. :slightly_frowning_face: [1]: https://firejail.wordpress.com/features-3/man-firejail-profile/
Author
Owner

@Vincent43 commented on GitHub (Mar 1, 2020):

I did decide to take a look in the /run/user/1000 directory and found some vscode-blah-blah-random-stuff.sock files

yeah, this is where it leaks.

So it looks like anything under /run can't be whitelisted. It does look like tmpfs will do the trick, but sadly that requires running as root. 🙁

/run can't be whitelisted but /run/user/1000/ can and this is what you want to do (unless you run some older version of firejail), post firejail --version.

<!-- gh-comment-id:593126507 --> @Vincent43 commented on GitHub (Mar 1, 2020): > I did decide to take a look in the /run/user/1000 directory and found some vscode-blah-blah-random-stuff.sock files yeah, this is where it leaks. > So it looks like anything under /run can't be whitelisted. It does look like tmpfs will do the trick, but sadly that requires running as root. 🙁 `/run` can't be whitelisted but `/run/user/1000/` can and this is what you want to do (unless you run some older version of firejail), post `firejail --version`.
Author
Owner

@pcrockett commented on GitHub (Mar 1, 2020):

firejail version 0.9.58.2

So about a year old. This is the latest that comes with Parrot OS. I'll try upgrading and report back.

<!-- gh-comment-id:593127475 --> @pcrockett commented on GitHub (Mar 1, 2020): > firejail version 0.9.58.2 So about a year old. This is the latest that comes with Parrot OS. I'll try upgrading and report back.
Author
Owner

@pcrockett commented on GitHub (Mar 1, 2020):

Ok, I updated to the latest release (0.9.62) and kept getting the whitelist error message. But I tried something different this time: --whitelist=${RUNUSER}/*. That did the trick. My /run/user/1000 directory inside the sandbox is empty, and now VSCodium runs completely isolated instances in the correct sandboxes.

Here's my new full profile:

# Copy/paste/modified from default.profile

# Persistent local customizations
include default.local
# Persistent global definitions
include globals.local

# generic gui profile
# depending on your usage, you can enable some of the commands below:

include disable-common.inc
# include disable-devel.inc
# include disable-interpreters.inc
include disable-passwdmgr.inc
# include disable-programs.inc
#include disable-xdg.inc

caps.drop all
ipc-namespace
netfilter
no3d
nodbus
nodvd
nogroups
nonewprivs
noroot
# nosound
notv
# nou2f
# novideo
protocol unix,inet,inet6
seccomp
# shell none

disable-mnt
private /home/phil/sandboxes/personal
whitelist ${RUNUSER}/*
# private-bin program
private-cache
private-dev
# private-etc none
# private-lib
private-tmp

# memory-deny-write-execute
# noexec /home/phil
noexec /tmp

net wlan0

hostname personal
machine-id

xephyr-screen 1480x924
x11

join-or-start personal

Thanks all.

<!-- gh-comment-id:593132881 --> @pcrockett commented on GitHub (Mar 1, 2020): Ok, I updated to the latest release (0.9.62) and kept getting the whitelist error message. But I tried something different this time: `--whitelist=${RUNUSER}/*`. That did the trick. My `/run/user/1000` directory inside the sandbox is empty, and now VSCodium runs completely isolated instances in the correct sandboxes. Here's my new full profile: ```plaintext # Copy/paste/modified from default.profile # Persistent local customizations include default.local # Persistent global definitions include globals.local # generic gui profile # depending on your usage, you can enable some of the commands below: include disable-common.inc # include disable-devel.inc # include disable-interpreters.inc include disable-passwdmgr.inc # include disable-programs.inc #include disable-xdg.inc caps.drop all ipc-namespace netfilter no3d nodbus nodvd nogroups nonewprivs noroot # nosound notv # nou2f # novideo protocol unix,inet,inet6 seccomp # shell none disable-mnt private /home/phil/sandboxes/personal whitelist ${RUNUSER}/* # private-bin program private-cache private-dev # private-etc none # private-lib private-tmp # memory-deny-write-execute # noexec /home/phil noexec /tmp net wlan0 hostname personal machine-id xephyr-screen 1480x924 x11 join-or-start personal ``` Thanks all.
Author
Owner

@rusty-snake commented on GitHub (Mar 2, 2020):

But I tried something different this time: --whitelist=${RUNUSER}/*. That did the trick. My /run/user/1000 directory inside the sandbox is empty,

whitelist globbing is actually unsupported, once it is supported this will reintroduce this issue for you. IMHO something like whitelist ${RUNUSER}/__empty__ would be better.

<!-- gh-comment-id:593387231 --> @rusty-snake commented on GitHub (Mar 2, 2020): > But I tried something different this time: `--whitelist=${RUNUSER}/*`. That did the trick. My `/run/user/1000` directory inside the sandbox is empty, whitelist globbing is actually unsupported, once it is supported this will reintroduce this issue for you. IMHO something like `whitelist ${RUNUSER}/__empty__` would be better.
Author
Owner

@smitsohu commented on GitHub (Mar 2, 2020):

How about adding blacklist ${RUNUSER}/vscode-* (assuming that's the path) to disable-programs.inc or a comparable place?
This socket is possibly also a vector to escape from other sandboxes.

<!-- gh-comment-id:593390949 --> @smitsohu commented on GitHub (Mar 2, 2020): How about adding `blacklist ${RUNUSER}/vscode-*` (assuming that's the path) to disable-programs.inc or a comparable place? This socket is possibly also a vector to escape from other sandboxes.
Author
Owner

@pcrockett commented on GitHub (Mar 2, 2020):

Since this is meant to be a general-purpose sandbox, and not specifically for VS Code, I guess I'd want to do just blacklist ${RUNUSER}, is that correct?

Question: Doesn't blacklisting a directory cause permission errors? Or would it simply cause the directory to appear empty?

Sorry, I'd just try it out, but my PC isn't within reach at the moment.

<!-- gh-comment-id:593401760 --> @pcrockett commented on GitHub (Mar 2, 2020): Since this is meant to be a general-purpose sandbox, and not specifically for VS Code, I guess I'd want to do just `blacklist ${RUNUSER}`, is that correct? Question: Doesn't blacklisting a directory cause permission errors? Or would it simply cause the directory to appear empty? Sorry, I'd just try it out, but my PC isn't within reach at the moment.
Author
Owner

@rusty-snake commented on GitHub (Mar 2, 2020):

Permission errors

<!-- gh-comment-id:593407066 --> @rusty-snake commented on GitHub (Mar 2, 2020): Permission errors
Author
Owner

@pcrockett commented on GitHub (Mar 2, 2020):

👌 So it sounds like for my case, since I do want applications to be able to write to the directory without having an effect on other sandboxes, whitelist ${RUNUSER}/__empty__ is a better tool for the job that blacklist.

It would sure be nice if Firejail just had an empty-dir feature or something like that. Whitelisting a random file seems like a bit of a hack.

<!-- gh-comment-id:593413698 --> @pcrockett commented on GitHub (Mar 2, 2020): 👌 So it sounds like for my case, since I _do want_ applications to be able to write to the directory without having an effect on other sandboxes, `whitelist ${RUNUSER}/__empty__` is a better tool for the job that `blacklist`. It would sure be nice if Firejail just had an `empty-dir` feature or something like that. Whitelisting a random file seems like a bit of a hack.
Author
Owner

@rusty-snake commented on GitHub (Mar 2, 2020):

@smitsohu in general I think that we should do more whitelisting in RUNUSER, but we can do this ATM only for gtk3 and cli programs.

<!-- gh-comment-id:593417913 --> @rusty-snake commented on GitHub (Mar 2, 2020): @smitsohu in general I think that we should do more whitelisting in RUNUSER, but we can do this ATM only for gtk3 and cli programs.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#2046
No description provided.