mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #4716] firefox: cannot save files with the File Chooser Portal (dbus) #2764
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#2764
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 @WhyNotHugo on GitHub (Nov 26, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/4716
Description
I've set the Firefox setting
widget.use-xdg-desktop-portaltotrue, so that it uses the File Chooser Portal.When saving a file, the file is not persisted to disk.
Steps to Reproduce
Steps to reproduce the behavior
about:configwidget.use-xdg-desktop-portaltotrueExpected behavior
File should be saved.
Actual behavior
File isn't saved.
Behavior without a profile
It works. It also works with Firefox's flatpak.
I mostly tested the Flatpak since the native Firefox has permissions to write there anyway, whereas the Flatpak does not. This makes me suspect it's a firejail profile issue and not Firefox itself misusing the portal.
Additional context
I'm very new to firejail (jumped to using it yesterday), so hope I haven't missed anything obvious.
Environment
firefox.localandglobals.local.Checklist
/usr/bin/vlc) "fixes" it).https://github.com/netblue30/firejail/issues/1139)browser-allow-drm yes/browser-disable-u2f noinfirejail.configto allow DRM/U2F in browsers.@rusty-snake commented on GitHub (Nov 26, 2021):
Which DE (or better which portal implementation+version) do you use? Some implementation dislike
noroot. Doesignore norootwork?Quite obvious. The distro and version is more interesting.
@ghost commented on GitHub (Nov 26, 2021):
I'm a bit confused. Our Firefox profile is designed as a 'whitelist' profile. This implies that access is blocked to all paths that are not explicitly whitelisted, like ~/tmp. So IMO this is expected behavior. Can you save files in ~/tmp if you add a
whitelist ${HOME}/tmpto yourfirefox.local?@kmk3 commented on GitHub (Nov 26, 2021):
@rusty-snake commented on Nov 26:
AFAIK "-arch" is what Arch Linux uses.
On Artix:
@glitsj16 commented on Nov 26:
I think the intent here is to make the file portal work so that the user can
save files anywhere regardless of the whitelist (i.e.: bypass the sandbox
through dbus).
@ghost commented on GitHub (Nov 26, 2021):
@kmk3 Thanks for explaining. I'm not at all familiar with (the inner workings of) these
portals, and don't have any of the xdg-desktop-portal{,-*} packages installed on my Arch Linux boxes. More stuff to experiment with :-)@WhyNotHugo commented on GitHub (Nov 26, 2021):
I'm using swaywm, and using the xdg-desktop-portal-gtk as a file picker portal.
Adding
ignore noroottofirefox.localdid not make it work.Sorry for not being clearer, it's Arch (rolling release).
https://github.com/netblue30/firejail/issues/4716#issuecomment-980090168 is correct, my intent is to use the portal to allow reading / writing files outside whitelisted locations. For reference, I can open a file in
~/tmp, but writing does not work.@rusty-snake commented on GitHub (Nov 26, 2021):
@WhyNotHugo are you sure
widget.use-xdg-desktop-portalis supposed to work (=read/write is performed via portal)? I testedfirejail --private --net=none --noprofile /usr/bin/firefox --no-remote(+flip pref on about:config) andbwrap --dev-bind / / --tmpfs $HOME/Downloads --tmpfs $HOME/.mozilla /usr/bin/firefox --new-instance, and it can neither read nor write through portals.@WhyNotHugo commented on GitHub (Nov 26, 2021):
Yeah, apparently reading doesn't work either -- I can pick a file, but it's not read correctly.
Sorry, it seems I tested this wrong a bit. The file chooser portal actually exposes the file via the document portal, which, in turn, uses a fuse mount, so I guess I'd have to whitelist that path too.
I'll give that a shot and report back.
@rusty-snake commented on GitHub (Nov 26, 2021):
I don't think so.
firejail --private --net=none --noprofile /usr/bin/firefox --no-remoteallows this path, my guess is more that firefox did not implemented IO via portal. Thewidget.use-xdg-desktop-portalbugs (at bugzilla) only talk about native vs. custom file-chooser.@WhyNotHugo commented on GitHub (Nov 26, 2021):
I'm experimenting with Firefox in Flatpak too, to understand what's implemented and what isn't.
With
widget.use-xdg-desktop-portalset tofalse, I cannot read any files from~/tmp, nor does it show up in the file picker (as expected).With
widget.use-xdg-desktop-portalset totrue, I can open a file in~/tmp, and the path that firefox shows in the URL bar isfile:///run/user/1000/doc/320b8f7f/wallhaven-pkw6y3.jpg, leading me to think that the reading did happen via the portals.@rusty-snake commented on GitHub (Nov 26, 2021):
Maybe the flatpak as a special patch which isn't in firefox yet? Or these code paths are only used if you run inside flatpak?
@WhyNotHugo commented on GitHub (Nov 26, 2021):
I believe there are no special patches, but at this point, I think it's best to report this on the Firefox side just to make sure there's nothing else necessary on their side.
Thanks for the guidance thus far.
@rusty-snake commented on GitHub (Dec 7, 2021):
🎉 I made my non-flatpak fox perform reading through document portal:
Portals look for/at
/proc/{PID}/root/.flatpak-info.Writing still doesn't work.
@WhyNotHugo commented on GitHub (Dec 7, 2021):
This example doesn't work for me. I set
widget.use-xdg-desktop-portal=true, and Firefox uses the File Chooser portal, but fails to open files (apparently, it gets back the original file paths and not the document-portal paths).Also tried adding
--setenv GTK_USE_PORTAL 1, but no luck either.@WhyNotHugo commented on GitHub (Dec 14, 2021):
The portal handles flatpake'd applications different from native ones. See https://github.com/flatpak/xdg-desktop-portal/issues/680#issuecomment-992895749
So I guess for this to work, a portal needs to be spawn in a specific way. I'll follow up as I learn more, but it's possible that a firejail-specific-portal-launcher is needed (or something similar; kinda like how xdg-dbus-portal is integrated).
This probably isn't as simple as I original expected, but I still think it's worth it since it allows further restricting how much access applications have, and this applies to a lot of other things other than Firefox.
@rusty-snake commented on GitHub (Dec 15, 2021):
Yes, I know, that's why I did
above.
@WhyNotHugo commented on GitHub (Dec 16, 2021):
Yeah, but the portal doesn't run inside the sandbox, so it won't detect that file.
Or am I missing something?
@rusty-snake commented on GitHub (Dec 16, 2021):
Do they for flatpak? (rhetorical question)
AFAIK portals look at
/proc/PID/root/.flatpak-info.@WhyNotHugo commented on GitHub (Dec 20, 2021):
You're very right, I'd misinterpreted both your message and the one in the linked issue.
I ran chromium via flatpak, and opened
file:///. It includes additional information that I the portal relies on:@WhyNotHugo commented on GitHub (Dec 20, 2021):
The portal seems to use this to read additional metadata from Flatpak:
0c3d8fddc4/src/xdp-utils.c (L1838)It behaves differently with Flatpak vs non-Flatpak applications, and won't expose its regular functionality to applications that are not Flatpaks, even if they're sandboxed.
At this point, I suspect writing a new portal is more feasible than trying to leverage that one.
@rusty-snake commented on GitHub (Oct 30, 2022):
Unless someone wants to bring firejail support into x-d-p this will be wontfix.
Closing for now.
@WhyNotHugo commented on GitHub (Nov 3, 2022):
I do believe a potential fix is possible; I've outlined an idea in https://github.com/netblue30/firejail/discussions/5318
@rusty-snake commented on GitHub (Nov 3, 2022):
In which comment?