[GH-ISSUE #459] Patch to bind user home directories #325

Open
opened 2026-05-05 05:36:18 -06:00 by gitea-mirror · 12 comments
Owner

Originally created by @lepasserby on GitHub (Apr 19, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/459

Hi!
Perhaps a silly question, but it was mentioned that --x11 is not available for root.

Would it work for cases where firejail is called like

sudo firejail --x11 --user=non-root-user --net=br1 program-name
?

Reason for sudoing: need to bind a "host" directory into the sandbox at startup (so the jailed program's output is available to certain processes at host), thus plan to have whitelist directory directive in the profile and it requires root.

program that needs to be jailed can run as non-root (hence --user=non-root-user)

Originally created by @lepasserby on GitHub (Apr 19, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/459 Hi! Perhaps a silly question, but it was mentioned that --x11 is not available for root. Would it work for cases where firejail is called like _sudo firejail --x11 --user=non-root-user --net=br1 program-name_ ? Reason for sudoing: need to bind a "host" directory into the sandbox at startup (so the jailed program's output is available to certain processes at host), thus plan to have whitelist directory directive in the profile and it requires root. program that needs to be jailed can run as non-root (hence --user=non-root-user)
gitea-mirror added the
enhancement
label 2026-05-05 05:36:18 -06:00
Author
Owner

@netblue30 commented on GitHub (Apr 20, 2016):

The order Firejail applies the commands will prevent you from doing it. This is something that will work:

Start with a naked root sandbox where you apply the bind:

$ sudo firejail --noprofile --bind=t1,t2

Switch to your user:

# sudo netblue

Start the real x11 sandbox using --force:

$ firejail --force --x11 --net=eth0 xterm

Or you can do all in one line:

$ sudo firejail --noprofile --bind=t1,t2 sudo -u netblue firejail --force --net=eth0 --x11 xterm
<!-- gh-comment-id:212403570 --> @netblue30 commented on GitHub (Apr 20, 2016): The order Firejail applies the commands will prevent you from doing it. This is something that will work: Start with a naked root sandbox where you apply the bind: ``` $ sudo firejail --noprofile --bind=t1,t2 ``` Switch to your user: ``` # sudo netblue ``` Start the real x11 sandbox using --force: ``` $ firejail --force --x11 --net=eth0 xterm ``` Or you can do all in one line: ``` $ sudo firejail --noprofile --bind=t1,t2 sudo -u netblue firejail --force --net=eth0 --x11 xterm ```
Author
Owner

@lepasserby commented on GitHub (Apr 20, 2016):

I assume if I want to apply secomp filters or something like that, I'd best do that in the "last" firejail (the --force one) ?

Should first firejail come with --noprofile, or could it have one?

If "naked" firejail is started with a specific profile, would the second (--force) one honor the profile (esp whitelist directive) ?

<!-- gh-comment-id:212409186 --> @lepasserby commented on GitHub (Apr 20, 2016): I assume if I want to apply secomp filters or something like that, I'd best do that in the "last" firejail (the --force one) ? Should first firejail come with --noprofile, or could it have one? If "naked" firejail is started with a specific profile, would the second (--force) one honor the profile (esp whitelist directive) ?
Author
Owner

@netblue30 commented on GitHub (Apr 20, 2016):

Yes, seccomp is applied to the second sandbox. If you put it in the first sandbox, the second one will not start.

And yes, you can use also use a profile for the first sandbox, but don't put in anything that might prevent the second sandbox from starting, such as seccomp, caps etc. Whitelisting should work in the first profile.

<!-- gh-comment-id:212421364 --> @netblue30 commented on GitHub (Apr 20, 2016): Yes, seccomp is applied to the second sandbox. If you put it in the first sandbox, the second one will not start. And yes, you can use also use a profile for the first sandbox, but don't put in anything that might prevent the second sandbox from starting, such as seccomp, caps etc. Whitelisting should work in the first profile.
Author
Owner

@lepasserby commented on GitHub (Apr 20, 2016):

Okay, thanks!

Last (maybe) question (tangentially related, but might deserve own issue)

Let's say I want to run program in a "hollow" non-persistent homedir (as achieved by --private) but want to make one specific directory in the new homedir available to host and/or persistent.

What profile and command line directives and in what order would achieve that ?

<!-- gh-comment-id:212445423 --> @lepasserby commented on GitHub (Apr 20, 2016): Okay, thanks! Last (maybe) question (tangentially related, but might deserve own issue) Let's say I want to run program in a "hollow" non-persistent homedir (as achieved by --private) but want to make one specific directory in the new homedir available to host and/or persistent. What profile and command line directives and in what order would achieve that ?
Author
Owner

@netblue30 commented on GitHub (Apr 21, 2016):

You would use --whitelist. Example:

$ firejail --whitelist=~/somedir

will create a "hollow" /home/user directory with /home/user/somedir imported form the filesystem and it will be persistent.

<!-- gh-comment-id:213065538 --> @netblue30 commented on GitHub (Apr 21, 2016): You would use --whitelist. Example: ``` $ firejail --whitelist=~/somedir ``` will create a "hollow" /home/user directory with /home/user/somedir imported form the filesystem and it will be persistent.
Author
Owner

@djfd commented on GitHub (Dec 13, 2016):

just a couple of cents,

there is a patch allowing to mount a few home subdirectories in bind mode, thus their content is fully synchronized between a host and sandbox.

I do not know how secure it is, is it possible to escape somehow using such kind of binding or not...
Experts advises and thoughts related to this approach are very welcome!

binding-home-subdir.patch.txt

<!-- gh-comment-id:266639745 --> @djfd commented on GitHub (Dec 13, 2016): just a couple of cents, there is a patch allowing to mount a few home subdirectories in bind mode, thus their content is fully synchronized between a host and sandbox. I do not know how secure it is, is it possible to escape somehow using such kind of binding or not... Experts advises and thoughts related to this approach are very welcome! [binding-home-subdir.patch.txt](https://github.com/netblue30/firejail/files/648035/binding-home-subdir.patch.txt)
Author
Owner

@netblue30 commented on GitHub (Dec 13, 2016):

Thanks, I'll look into it.

<!-- gh-comment-id:266760941 --> @netblue30 commented on GitHub (Dec 13, 2016): Thanks, I'll look into it.
Author
Owner

@chiraag-nataraj commented on GitHub (Jul 15, 2018):

Isn't --force deprecated now? So how would one do this with the newer firejail versions?

<!-- gh-comment-id:405118264 --> @chiraag-nataraj commented on GitHub (Jul 15, 2018): Isn't `--force` deprecated now? So how would one do this with the newer `firejail` versions?
Author
Owner

@tonsimple commented on GitHub (Sep 12, 2018):

@netblue30 @chiraag-nataraj

I too have an interest in launching firejailed apps from a limited user, but in a firejail environment that was initially set up using "root-stuff"

"--force" still works for me (version 0.9.44.8 Debian 8) but if it is "on its way out" that may cause issues for me later on so I would like to know what's best practice is for the kind of thing I'm doing

P.S.:
Also, I would like to humbly request the return of --user command line switch. I realize there are probably practical reasons for its removal, but it was so comfy

<!-- gh-comment-id:420644211 --> @tonsimple commented on GitHub (Sep 12, 2018): @netblue30 @chiraag-nataraj I too have an interest in launching firejailed apps from a limited user, but in a firejail environment that was initially set up using "root-stuff" "--force" still works for me (version 0.9.44.8 Debian 8) but if it is "on its way out" that may cause issues for me later on so I would like to know what's best practice is for the kind of thing I'm doing P.S.: Also, I would like to humbly request the return of --user command line switch. I realize there are probably practical reasons for its removal, but it was so comfy
Author
Owner

@Vincent43 commented on GitHub (Sep 12, 2018):

It was removed due to security concerns so I doubt it will be ever restored.

<!-- gh-comment-id:420778910 --> @Vincent43 commented on GitHub (Sep 12, 2018): It was removed due to security concerns so I doubt it will be ever restored.
Author
Owner

@tonsimple commented on GitHub (Sep 22, 2018):

@Vincent43
Woah, that sounds bad.

@netblue30 , is running firejail "as someone else" unsafe in principle, or is it just --user implementation that was not very safe?

I'm currently doing

run firejail as root, set up environment, then use daemonize binary (easy to build on most platforms) to run another firejail with --force and proper profile (including seccomp and capability filters) . Seems to be working fine and daemonize offers a few neat bells and whistles.

using su to launch second firejail also works, I just kind of like daemonize more.

Is such a methodology somehow bad?

<!-- gh-comment-id:423737399 --> @tonsimple commented on GitHub (Sep 22, 2018): @Vincent43 Woah, that sounds bad. @netblue30 , is running firejail "as someone else" unsafe in principle, or is it just --user implementation that was not very safe? I'm currently doing run firejail as root, set up environment, then use daemonize binary (easy to build on most platforms) to run another firejail with --force and proper profile (including seccomp and capability filters) . Seems to be working fine and daemonize offers a few neat bells and whistles. using su to launch second firejail also works, I just kind of like daemonize more. Is such a methodology somehow bad?
Author
Owner

@rusty-snake commented on GitHub (Jan 25, 2020):

Something like --bind-home=s,t would allow a lot of workarounds, I'm thinking #3139, …

<!-- gh-comment-id:578390169 --> @rusty-snake commented on GitHub (Jan 25, 2020): Something like `--bind-home=s,t` would allow a lot of workarounds, I'm thinking #3139, …
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#325
No description provided.