mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #5079] On the fly, request/permission based profile building #2871
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#2871
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 @romelsalwi on GitHub (Mar 28, 2022).
Original GitHub issue: https://github.com/netblue30/firejail/issues/5079
I have been using firejail for couple of months. At first it was quite impressive and was exactly what I was looking for building restriction around applications. But what I lack is the way of finding the exact resource which the application requires and doing my own due diligence to solve various tweaks.
For instance, keepassxc, if jailed causes issues for chromium; jailing free tube restricts usage of external player like mpv; restricting mpv won't allow me to use btfs and stream and watch on the fly.
What I would like to see is building permissions for a jailed app. If I'm trying to do something which is in conflict with the rules, ask, and update the profile or local file depending on my choice. In this way, building profile would be easy, like using uBO on hard mode, and I don't mind that cumbersome effort as much as how much intuitive it is!
@ghost commented on GitHub (Mar 28, 2022):
Please open separate issues for these problems you're facing. It helps us improve the profiles for all users, even if your use cases are very personal. The freetube profile for example is designed for using the internal player. So you would need to add mpv to private-bin to support that. This is just one example, but it's worth the effort IMO.
You can use the
--buildor--build=profile-fileoptions to create a whitelisting profile for any app you want. Based on the result this can be hardenend further to get it as tight as possible without loosing functionality. Have you looked into that workflow yet?@romelsalwi commented on GitHub (Mar 28, 2022):
First of all, thanks for responding! It means a lot!
I might understand that you guys are trying to build a library for the application. But there are so many of them. My intend wasn't to post an issue but to illustrate how you can enhance upon the profiling aspect of firejail.
They don't work as intended. As a refresher I just tried building new profiles with it. Ultimately I had to copy the template and make the profile from scratch. But then I was expecting to refine the profile through build, which didn't go so well. I'm sure I'm doing something wrong.
For instance:
I made a profile for Joplin
firejail --profile=~/.config/firejail/joplin.profile --appimage ~/Downloads/appImages/Joplin-2.7.15.AppImageWhich works.
But then doing this:
firejail --build=~/.config/firejail/joplin.profile --appimage ~/Downloads/appImages/Joplin-2.7.15.AppImageGives an error:
Error: cannot open profile file.P.S.: For some unknown reason only absolute path for appimages is working. Interestingly below mentioned command didn't even read my globals.local
@ghost commented on GitHub (Mar 28, 2022):
Fair enough, no problem.
Noticing your examples are using AppImages, it might be worthwhile to check your Firejail version. The build options got appimage support only recently via https://github.com/netblue30/firejail/pull/4878. Not sure OTOH if that made it into the latest release. To make sure you could give building from git a try.
Regarding your Joplin examples. You can create your own custom profiles in ~/.config/firejail, no problem doing so. But the --build=foo option is not intended to use an already existing profile AFAIK. At least that doesn't make much sense, as its purpose is to create one from scratch. So I'd go for something like;
$ firejail --build=~/Downloads/build-joplin.profile --appimage ~/Downloads/appImages/Joplin-2.7.15.AppImageand then start comparing the output of ~/Downloads/build-joplin.profile with what you already have in ~/.config/firejail/joplin.profile to see if/what you can add to harden it according to your needs. Documentation might be unclear on this I guess.
@romelsalwi commented on GitHub (Mar 28, 2022):
I'm using firejail version 0.9.68
https://archlinux.org/packages/community/x86_64/firejail/
I tried out your step:
Then ran the appimage with the created profile:
@romelsalwi commented on GitHub (Mar 28, 2022):
I also tried using the firetools configuration wizard. No luck
@romelsalwi commented on GitHub (Mar 28, 2022):
Hmm, KeePassXC-2.7.0-x86_64.AppImage worked! But the profile created is barely restricted.
EDIT:
After few mods, and loading with the generated profile, the application gives an error
Access error for config file /home/*/.config/keepassxc/keepassxc.ini@rusty-snake commented on GitHub (Mar 28, 2022):
TBH It is out of dated and hasn't seen much development for a long time. IMHO we should just remove it from firejail (the binary) and develop an external tool for profile building (in a language which has friendlier support for string parsing & co like python.
@rusty-snake commented on GitHub (Mar 28, 2022):
What I mean is something like
firejail-profile-builder.py@romelsalwi commented on GitHub (Mar 28, 2022):
Nice 👍
Is it possible to ask the user before stracer updates the profile?
@rusty-snake commented on GitHub (Mar 29, 2022):
Python is really much much better than C for tasks like this.
https://github.com/rusty-snake/firejail-profile-builder
@romelsalwi commented on GitHub (Mar 30, 2022):
Hi @rusty-snake !
I tried out the script. It didn't created the desired effect. It started out at ease while building but when used as a profile it didn't worked out. I used it on turtlapp https://turtlapp.com/
When you use
buildto create profile, firejail gives access to file during the process../firejail-profile-builder.py -o turtl.profile turtl@romelsalwi commented on GitHub (Mar 30, 2022):
This is the profile I created for scratch:
@rusty-snake commented on GitHub (Mar 31, 2022):
It's still in development.
It will never get the quality of a handwritten profile.
is an electron app, this will need special handling. We will need to detect this.
@rusty-snake commented on GitHub (Apr 2, 2022):
If you did not disable unprivileged userns, it may work now with electron programs.
@romelsalwi commented on GitHub (Apr 8, 2022):
Here's something I found relevant:
https://gitlab.com/apparmor/apparmor/-/wikis/AppArmor_Core_Policy_Reference
Apparmor uses a profile language, and with the help of auditd, you can trace what the confined app is trying to access.
The interesting and the interactive part I found was globbing. You can glob the directory and tell apparmor how much access the application has, and apply it to the profile using
logprof.By far I have tried it on Firefox and few other frequently used applications and the process when implemented correctly can provide finer result
I followed these pages:
https://wiki.archlinux.org/title/AppArmor#Configuration
https://wiki.archlinux.org/title/Audit_framework#Adding_rules
During the profile generating process
genprof, apparmor is going through the audit reports. It notifies (throughaa-notify) what files were accessed, and when you are finished, it creates a profile. It is not compulsive for the application to run as expected and that is why it allows you to run the application in complain mode so that you can refine those edges. When convinced, you can make the rules strict by enabling enforce mode.@sudoAlphaX commented on GitHub (Feb 26, 2025):
@glitsj16 this doesnt work for me. I have added mpv and yt-dlp to private-etc in freetube.local. Any recommendations?