mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #4355] AppImage: automatically detect profile #2630
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#2630
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 @reinerh on GitHub (Jun 11, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/4355
When you want to start an AppImage with firejail, it currently loads the
default.profileby default (when you don't explicitely specify which profile to load).The default profile is in most cases not very helpful, so you have to manually specify
--profile=to load the right profile.It would be nice if firejail could automatically detect which profile to load.
@rusty-snake commented on GitHub (Jun 11, 2021):
I always thought that this is not possible because an AI can have any name and the notation often varies (e.g. KeePassXC vs. keepassxc). Do the most AI have a consistent name inside?
@reinerh commented on GitHub (Jun 11, 2021):
I don't know enough about AppImages. Maybe a profile name could be determined heuristically via the AppImage filename?
And we should maybe also mention in the manpage that probably a profile needs to be specified as well.(just noticed it has already been added to the manpage ind9458eb)Edit: But you are right, with mixed cases in the name, it's probably difficult to find the right profile. But maybe it could work for some cases. If
$name.profileexists orlowercase($name).profileexists, use that, otherwise fall back to default.profile...@kmk3 commented on GitHub (Jun 12, 2021):
I think that the only way to properly detect the declared program name would be
to read some sort of "manifest" inside of the AppImage (either in the image or
directly in the binary).
The good news is that the specification says that every image should
contain one (and only one) .desktop file in the root dir:
The name of this file could be used to determine the profile, just like
firejail currently already does with normal .desktop files.
But do note that an AppImage may have a .desktop file named in any way (and
this is invisible to the user), so a malicious AppImage could pretend to be a
different program, such as one which has a firejail profile with broad
permissions.
Now, the issue is in how to properly and reliably extract the contents of an
AppImage without running it. According to the documentation, it is a work
in progress:
According to the author in the issue above, it's already possible with
AppImageKit:
The problem with this approach is that it requires downloading and running
binaries outside of the distro repos, which I'd rather not do.
And AFAICT AppImageKit is not packaged on Arch/Artix, not even in the AUR,
which is a bummer. And I couldn't find it on Debian either.
So these are the alternatives that I thought of:
@kmk3 commented on GitHub (Jun 12, 2021):
So, I just found this:
From README.md:
From README:
The project at least exists in the AUR:
If this would be considered good enough for now, firejail could try detecting
if the
unsquashfscommand exists and use it if it does.@rusty-snake commented on GitHub (Jun 12, 2021):
Actually this does not really work because of names like org.gnome.Maps.desktop or mozilla-firefox.desktop. (#2624)
Can we parse the
Exec=line in it or is it just something likebin/app?AFAIK that is what we already do.
@kmk3 commented on GitHub (Jun 12, 2021):
@rusty-snake commented 13 hours ago:
In that case I'd consider adding profiles that redirect to the
normal/non-AppImage ones. Example:
The amount of extra redirect profiles could get rather unwieldly, but I suppose
that we could put them in a separate
etc/appimagedir to mitigate that.I also thought about parsing
Exec=, though considering that it's a commandline, I'd expect it to be a source of corner cases. Ideally, it would be done
using just the C equivalent of something like this:
Example:
But what if it's run using
sh -c? I have seen (or at least tried to do) thisbefore on normal .desktop files, as
Execdoes not support shell syntax, suchas environment variables; it just executes the arguments as is. Example:
I'm not sure how common that is in AppImages compared to normal .desktop files,
but still, considering that a shell can be used, anything is possible...
Additionally, I think that the
org.fooprogram name is meant to be somethingrather stable. As in, I'd expect it bo be changed once or twice at most, if at
all. And if it does change, we would just have to copy and paste a redirect
profile (kind of like
dbus-(user|system).*may have different filtersreferring to the same thing). Whereas if the
Execline changes from oneversion to the next (e.g.: from
Exec=footoExec=sh -c 'a=b foo'), howwould it be handled?
Nice; in that case ignore those suggestions.
@kmk3 commented on GitHub (Jun 12, 2021):
I just noticed this mentioned on the AppImageKit CONTRIBUTING.md:
To be clear, I consider that it's one thing to download and run the AppImage of
a GUI program (e.g.: Firefox) under firejail with a built-in whitelisting
profile, and that it's a rather different beast to download and run a tool
which is general-purpose (and thus might potentially need broad permissions)
and which currently has no firejail profile.
@netblue30 commented on GitHub (Jun 14, 2021):
OK, I went for @reinerh idea, checking the name of the archive (using strcasestr) against the list of programs in /usr/lib/firejail/firecfg.config. Try it out, if nothing else comes up we release it in one or two weeks.
e770ab6d85@rusty-snake commented on GitHub (Jun 14, 2021):
The name of 16 AIs randomly picked from AppImageHub:
I think the most users won't rename their AIs. They just download and move to e.g.
~/.appimages(and create a wrapper-script, symlink, .desktop, ...)@netblue30 commented on GitHub (Jun 17, 2021):
All these will end up using default.profile.
@rusty-snake commented on GitHub (Dec 10, 2021):
Do we want to improve the heuristic or close here?