[GH-ISSUE #380] Programs start without sandbox if /proc is mounted with hidepid #273

Closed
opened 2026-05-05 05:28:42 -06:00 by gitea-mirror · 14 comments
Owner

Originally created by @ghost on GitHub (Mar 24, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/380

If the /proc file system is mounted with hidepid=1 or hidepid=2, firejail reports to have detected an existing sandbox (as it can't see the kernel processes), starting the program in a normal /bin/sh shell. While this can be avoided using --force, it looks like a security problem to me as the warning can't be seen unless firejail is started in a terminal, making it seem like the program is sandboxed when it really isn't.

  1. Would it be possible to detect an existing sandbox without checking for kernel processes?
  2. Instead of starting programs in an insecure /bin/sh shell, the default behavior in my opinion should be not to start the program unless a special command-line flag is used. Otherwise, people might restrict access to kernel processes, not realizing that their sandbox isn't being used anymore.
Originally created by @ghost on GitHub (Mar 24, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/380 If the `/proc` file system is mounted with `hidepid=1` or `hidepid=2`, firejail reports to have detected an existing sandbox (as it can't see the kernel processes), starting the program in a normal `/bin/sh` shell. While this can be avoided using `--force`, it looks like a security problem to me as the warning can't be seen unless firejail is started in a terminal, making it seem like the program is sandboxed when it really isn't. 1. Would it be possible to detect an existing sandbox without checking for kernel processes? 2. Instead of starting programs in an insecure `/bin/sh` shell, the default behavior in my opinion should be not to start the program unless a special command-line flag is used. Otherwise, people might restrict access to kernel processes, not realizing that their sandbox isn't being used anymore.
gitea-mirror 2026-05-05 05:28:42 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ghost commented on GitHub (Mar 26, 2016):

Would you accept a pull request that changes the default behavior to require an --allow-no-sandbox option (or similar) for firejail to use an insecure /bin/sh shell, so that, when an existing sandbox is detected:

  • --allow-no-sandbox uses a normal, insecure /bin/sh shell
  • --force uses a sandbox (no change necessary)
  • Both options given: use a sandbox (--force takes precedence)
  • None of the options given: show an error message asking the user to specify one of the options; then exit
<!-- gh-comment-id:201759964 --> @ghost commented on GitHub (Mar 26, 2016): Would you accept a pull request that changes the default behavior to require an `--allow-no-sandbox` option (or similar) for firejail to use an insecure `/bin/sh` shell, so that, when an existing sandbox is detected: - **`--allow-no-sandbox`** uses a normal, insecure `/bin/sh` shell - **`--force`** uses a sandbox (no change necessary) - **Both options given**: use a sandbox (`--force` takes precedence) - **None of the options given**: show an error message asking the user to specify one of the options; then exit
Author
Owner

@netblue30 commented on GitHub (Mar 28, 2016):

I would leave it as is for now, probably there will be more changes in the future.

The question is this: you are in a sandbox, and you try to start another sandbox, what should happen? For Mozilla Thunderbird users this happens every time when they click a link in an email. So far the only idea I had was to start Firefox in the existing sandbox.

<!-- gh-comment-id:202365458 --> @netblue30 commented on GitHub (Mar 28, 2016): I would leave it as is for now, probably there will be more changes in the future. The question is this: you are in a sandbox, and you try to start another sandbox, what should happen? For Mozilla Thunderbird users this happens every time when they click a link in an email. So far the only idea I had was to start Firefox in the existing sandbox.
Author
Owner

@ghost commented on GitHub (Mar 28, 2016):

You're right, I didn't think about that.
Do you have any idea how a sandbox could be detected other than by kernel processes? If not, let's close this issue?

<!-- gh-comment-id:202485008 --> @ghost commented on GitHub (Mar 28, 2016): You're right, I didn't think about that. Do you have any idea how a sandbox could be detected other than by kernel processes? If not, let's close this issue?
Author
Owner

@netblue30 commented on GitHub (Mar 28, 2016):

Probably there are other ways. The kernel gives out some inode numbers in /proc/self/ns, you can compare these numbers with a regular process and detect the namespaces.

<!-- gh-comment-id:202575069 --> @netblue30 commented on GitHub (Mar 28, 2016): Probably there are other ways. The kernel gives out some inode numbers in /proc/self/ns, you can compare these numbers with a regular process and detect the namespaces.
Author
Owner

@Sidnioulz commented on GitHub (May 30, 2016):

@netblue30 not sure what exactly is the mechanics behind the Thunderbird situation, but on my fork I expect all my Xfce apps to use libxfce4ui's spawning function, and that function will detect if it is in a sandbox and then run "unsandboxed" (as in, not prepend firejail to the arguments being executed, resulting in the newly executed app being in the same container as its parent).

Assuming that you refer to Thunderbird running a .desktop file that does "firejail firefox", then the issue is that the .desktop file should embed that information another way (.desktop files have a special key in my fork indicating that Xfce should sandbox them) and the spawning utility used should be compatible (so that the initial run of the .desktop file in an unsandboxed environment properly runs it in a sandbox, and runs inside existing sandboxes put the new app inside that existing sandbox).

This is reliable and, as I see it, allows legitimate use of program helpers without raising security issues. But then again I have window decorations that clearly indicate the domain in which a windowed program is, you'd need that too to avoid user errors (using Thunderbird's firefox rather than another sandboxed firefox, when both are running).

<!-- gh-comment-id:222499169 --> @Sidnioulz commented on GitHub (May 30, 2016): @netblue30 not sure what exactly is the mechanics behind the Thunderbird situation, but on my fork I expect all my Xfce apps to use libxfce4ui's spawning function, and that function will detect if it is in a sandbox and then run "unsandboxed" (as in, not prepend firejail to the arguments being executed, resulting in the newly executed app being in the same container as its parent). Assuming that you refer to Thunderbird running a .desktop file that does "firejail firefox", then the issue is that the .desktop file should embed that information another way (.desktop files have a special key in my fork indicating that Xfce should sandbox them) and the spawning utility used should be compatible (so that the initial run of the .desktop file in an unsandboxed environment properly runs it in a sandbox, and runs inside existing sandboxes put the new app inside that existing sandbox). This is reliable and, as I see it, allows legitimate use of program helpers without raising security issues. But then again I have window decorations that clearly indicate the domain in which a windowed program is, you'd need that too to avoid user errors (using Thunderbird's firefox rather than another sandboxed firefox, when both are running).
Author
Owner

@deathtrip commented on GitHub (Jul 31, 2016):

I have /proc mounted with hidepid=2, and when i start a sandboxed program from the terminal, everything seems ok.
No report of an existing sandbox.
However no sandbox can be seen by using "firemon --list" or by firetools.

<!-- gh-comment-id:236425097 --> @deathtrip commented on GitHub (Jul 31, 2016): I have /proc mounted with hidepid=2, and when i start a sandboxed program from the terminal, everything seems ok. No report of an existing sandbox. However no sandbox can be seen by using "firemon --list" or by firetools.
Author
Owner

@netblue30 commented on GitHub (Jul 31, 2016):

How do you mount /proc with hidepid=2?

<!-- gh-comment-id:236432524 --> @netblue30 commented on GitHub (Jul 31, 2016): How do you mount /proc with hidepid=2?
Author
Owner

@deathtrip commented on GitHub (Jul 31, 2016):

here's the fstab entry:
proc /proc procfs hidepid=2,gid=proc 0 0

and the group file entry:
proc26:polkitd

<!-- gh-comment-id:236436262 --> @deathtrip commented on GitHub (Jul 31, 2016): here's the fstab entry: proc /proc procfs hidepid=2,gid=proc 0 0 and the group file entry: proc:x:26:polkitd
Author
Owner

@netblue30 commented on GitHub (Aug 1, 2016):

I'll give it a try, thanks.

<!-- gh-comment-id:236560979 --> @netblue30 commented on GitHub (Aug 1, 2016): I'll give it a try, thanks.
Author
Owner

@deathtrip commented on GitHub (Nov 9, 2016):

any progress on this?

<!-- gh-comment-id:259306877 --> @deathtrip commented on GitHub (Nov 9, 2016): any progress on this?
Author
Owner

@netblue30 commented on GitHub (Nov 9, 2016):

However no sandbox can be seen by using "firemon --list" or by firetools

Are you talking about this?

<!-- gh-comment-id:259440133 --> @netblue30 commented on GitHub (Nov 9, 2016): > However no sandbox can be seen by using "firemon --list" or by firetools Are you talking about this?
Author
Owner

@deathtrip commented on GitHub (Nov 9, 2016):

Yes.

<!-- gh-comment-id:259471390 --> @deathtrip commented on GitHub (Nov 9, 2016): Yes.
Author
Owner

@netblue30 commented on GitHub (Nov 10, 2016):

I'll try to bring in a fix.

<!-- gh-comment-id:259697366 --> @netblue30 commented on GitHub (Nov 10, 2016): I'll try to bring in a fix.
Author
Owner

@netblue30 commented on GitHub (Nov 12, 2016):

Fixed!

<!-- gh-comment-id:260120877 --> @netblue30 commented on GitHub (Nov 12, 2016): Fixed!
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#273
No description provided.