mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #1620] Enforcing directory structure with permissive parts for web virtual hosts with SSH access #1086
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#1086
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tomsseisums on GitHub (Oct 26, 2017).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1620
I am on Ubuntu 16.04 LTS, therefore using the LTS version of firejail 0.9.38.10.
I am looking for a way to enforce a specific/strict structure for web virtual hosts on a somewhat shared hosting server.
My idea is to serve from each users home, where each user acts as a single vhost/domain. This is necessary because the virtual hosts also require SSH access, but I don't want to give them too much freedom to roam around. Otherwise I could, for example, set up sftp-chroot's through openssh.
So, with directory structure like this:
/home/<user>/home/<user>/web/home/<user>/web/log/home/<user>/web/www/home/<user>/web/www/publicIs it possible to configure permissions such that:
/home/<user>— remains as homes are by default, though, I may restrict it even more in future./home/<user>/web— isn't deletable/writable/editable, including contents./home/<user>/web/log— isn't deletable/writable/editable, but contents have to be up to date from actual system./home/<user>/web/www— isn't itself deletable/editable, but contents can be freely created/edited/deleted./home/<user>/web/www/public— isn't itself deletable/editable (being more restrictive than parent directory), but contents can be freely created/edited/deleted.Web server daemons (nginx, php-fpm) in return has to be able to:
/home/<user>/web/log/home/<user>/web/wwwand/home/<user>/web/www/public- and the user has to be able to see the changesI've got this far (
virtual-webhost.profile):But this is not a good starting point, because whole of
${HOME}is hidden only the obvious whitelisted parts are available. Though, I need those.bash_historyand.mysql_historyfiles and will need others after I will be settled with~/webstruture.Is this possible with firejail? (if it is, but only above LTS release, I could switch this package out to a more recent one)
P.S. I'm not a system administrator, nor a Linux specialist. I'm a web developer tasked to set up our in-house server, though, I am looking for a more refined setup - want some more security/isolation.
@netblue30 commented on GitHub (Oct 29, 2017):
You can definitely build something like this. Let's say this is the directory structure:
/home/<user>/home/<user>/web/home/<user>/web/log/home/<user>/web/wwwAs root, you start the server:
For somefile.profile use server.profile as a starting point. You will also have to use --net and --ip on the command line or in the profile to give him a network namespace, so all users have a webserver on the regular 80 tcp port.
The only thing missing in this moment is
/home/<user>/web/loghandling. Currently /var/log goes in a tmpfs accessible only from inside the sandbox. We can add support to have it as a mount-bin in user home directory.As for the user, you can sandbox him when he logs in over ssh, look at man firejail-login.
@tomsseisums commented on GitHub (Oct 29, 2017):
I'm not looking to sandbox nginx, was pointing the necessities for nginx so that the settings for SSH sandboxing do not clash with the underlying system.
I guess, I overshot a little with the question details.
My main concern is to enforce the structure for the SSH session.
@netblue30 commented on GitHub (Oct 29, 2017):
You keep a single SSH server running on the system without any sandboxing, and sandbox strictly the user session at login time. In /etc/firejail/login.users you can add any firejail command line options, including a --profile command. By default it picks up default.profile.
Parts of user home directory are shared between the sandboxed SSH login session and the sandboxed web server - if I understand your question.
@tomsseisums commented on GitHub (Oct 29, 2017):
But how do I prevent some of the parts of the home directory to be modified by the sandboxed user?
Like, to enforce these "laws":
/home/<user>/web— isn't deletable/writable/editable, including contents./home/<user>/web/log— isn't deletable/writable/editable, but contents have to be up to date from actual system./home/<user>/web/www— isn't itself deletable/editable, but contents can be freely created/edited/deleted./home/<user>/web/www/public— isn't itself deletable/editable, but contents can be freely created/edited/deleted.@netblue30 commented on GitHub (Oct 29, 2017):
/home/<user>/web/logwill owned actually by root, so the user cannot write to it.This is a little bit difficult. You can make
/home/<user>/web/wwwowned by root, and a directory/home/<user>/web/www/htmlowned by the user. The user won't be able to delete/home/<user>/web/www/htmlor add new files in/home/<user>/web/www, but he will be able to add or modify anything inside/home/<user>/web/www/html.