mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #7078] AppArmor profile does not grant userns permissions #3479
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#3479
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 @cobratbq on GitHub (Feb 25, 2026).
Original GitHub issue: https://github.com/netblue30/firejail/issues/7078
Description
Is AppArmor not granted
usernsprivileges when running within AppArmor?Newer AppArmor versions have a
usernspermission that allows access to user-namespaces when these are otherwise restricted. The profilefirejail-defaultdoes not set this permission.I suspect this inhibits the capabilities of
firejailitself. The issue, but specifically for firefox, is also discussed in #6675.Steps to Reproduce
/usr/bin/firejail --debug /usr/bin/firefox --no-remote(without making any changes)[56] Sandbox: CanCreateUserNamespace() clone() failure: EACCESS.Expected behavior
No error-message.
Actual behavior
Application starts, but is restricted from anything concerning user-namespaces even if not restricted by firejail options/profiles, because firejail itself is restricted.
Behavior without a profile
Not tested. Adding
usernsto/etc/apparmor.d/firejail-defaultalready solves the problem, i.e. makes the difference.Additional context
From reading other information, i.e. #6675, I gather this is a recent change/feature in AppArmor 4, which I guess is in Debian.
This effectively weakens Firefox's inherent sandboxing capabilities because they are restricted from using user-namespaces. It also seems that user-namespaces provide value with Firefox's sandboxing capacity.
Also, given that subsequently capabilities are dropped, there should be reduced risk even if user-namespaces are in use.(?)
Environment
6.12.73+deb13-amd64firejailChecklist
firejail /usr/bin/vlcinstead offirejail vlc; seehttps://github.com/netblue30/firejail/issues/2877)/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.--profile=PROFILENAMEto set the right profile. (Only relevant for AppImages)Log
N/A
@cobratbq commented on GitHub (Feb 25, 2026):
Possible fix: add
usernsto beginning offirejail-defaultprofile. This grants firejail access to user-namespaces which can then choose to delegate as profile/options ddecide.IIUC, adding
usernsto the AppArmor-profile for firejail is effectively the same as previous AppArmor without this addition, because it only recent got to being managed. It effectively allows user-namespaces thus deferring tofirejailto determine whether to continue to allow it.@kmk3 commented on GitHub (Feb 25, 2026):
Nice, since this makes the profile work the same as in AppArmor 3, sounds good
to me.
Would you like to open a PR?
Also, would that change remove the need for
apparmor-replaceinfirefox-common.profile (see #5475)?
Edit: I see now that this is a much older issue, so probably not.
@kmk3 commented on GitHub (Feb 25, 2026):
(Feel free to ignore this until after the fix)
Since you're already looking into this, as a potential improvement, do you know
if it's possible to have an apparmor profile (such as "firejail-userns") with
just
userns(plus whatever boilerplate is needed) and then conditionallystack it (with
aa_stack_onexec())?For example, if
restrict-namespacesis not used, we could just stack anuserns apparmor profile in src/firejail/sandbox.c.
Then a profile with
restrict-namespaceswould get both a firejail andapparmor restriction on user namespaces and a profile without that can just use
them normally.
@cobratbq commented on GitHub (Feb 25, 2026):
Assuming that this
abi/4.0indicates a "language" version, thus available keywords, then AppArmor 3 would likely reject the profile, but would do so already. (I'm guessing as to its meaning, so I'm not 100% sure.)I'll do that.
I don't know exactly. I haven't looked into the reason for why
apparmor-replacewas necessary in the first place.@cobratbq commented on GitHub (Feb 25, 2026):
I don't think you should want to. Firejail is intended to manage capabilities, restrictions, etc. Do you not trust it to drop
usernsrestrictions when--restrict-namespacesis (correctly) applied?I wonder if the added complexity is even desirable.
This is
firejailprotecting itself from itself, primarily. Don't you agree?They're effectively the same restrictions, but managed by a different program, isn't it? They're the same underlying capabilities or restrictions or syscalls.
@kmk3 commented on GitHub (Feb 25, 2026):
From looking at the code, I don't think it would be a notable increase in
complexity code-wise (assuming it works with apparmor 3.x).
AIUI the "firejail-default" apparmor profile applies to the sandboxed program,
not to firejail itself.
So it's more about defense-in-depth.
Assuming that firejail is less than perfect and that its attempt to restrict
user namespaces could fail (such as due to a new change causing a bug, etc),
then the user would still have the apparmor restriction.
The user namespace restrictions in firejail and apparmor have the same intent,
but I don't think that their implementations are equivalent.
The one in firejail seems to be done through seccomp BPF (with fseccomp), which
is not as simple as calling a function or a path-based restriction (as is done
for some firejail commands).
Also, judging by the multiple CVEs related to unprivileged user namespaces and
the lengthy discussion in #6675, it seems like the extra assurance would be
welcomed.
Lastly, if the user believes that apparmor is redundant, they can just use
ignore apparmorand they would be unaffected by this either way.@cobratbq commented on GitHub (Feb 28, 2026):
I am not familiar enough with the code, and haven't looked into it, so I'll go by your feedback.
Hmm... actually, you are correct. I am mistaken and also my description. Effectively, it matters little, but indeed
firejailitself is not constrained using/etc/apparmor.d/firejail-defaultand I should've realized because I looked into this and didn't see the pattern for/usr/bin/firejail.Yes. Clear.
But conversely, if the apparmor-profile
firejail-defaultis applied withoutuserns, then firejail can no longer decide to allow user-namespaces. Sure, then choosing an appropriate profile makes sense.But, then my question is: What about blocking access to network protocols? Those are also in AppArmor 4.0 (possibly earlier, not sure). Would you also make separate profiles for those for the same reason of defense-in-depth? I.e. do you have a rationale for where you draw the line?
Likely, AppArmor has more direct influence, given that it is a kernel security module, but then so does the capabilities framework. Even then, it could still function for defense-in-depth against edge-cases.
How about the capabilities? Because, to my knowledge, those are a registered security module in
/sys/kernel/security/lsm, so it would have more direct influence.That is true. However, I've read about needing
CAP_SYS_ADMINin user-namespaces, which is more restricted/crippled, and then break out to then acquire un-neuteredCAP_SYS_ADMINprivileges in the system namespace (or however that instance is called). Similarly, the recent user-namespace vulnerabilities in Ubuntu, IIUC, required "hitch-hiking" on liberal AppArmor-profiles such as ofbusyboxusingaa-execor something alike. I can bring little expertise apart from being somewhat informed from news articles.Yes, this is true. However, e.g. web browsers use it to apply more granular compartmentalization (I think) and you remove that ability entirely, which may mean that you provide smaller surface area for vulnerabilities to break out of the isolated environment as a whole, but may increase vulnerability for various compartmentalized regions inside the program. (Again, in my limited understanding.)
I was thinking about the case for development environments with LSPs, processes and agents. Those run quite a few foreign processes, so compartmentalization may be (or become) more important, which is where user-namespaces would help. Otherwise they would need to resort to SUID-executables to set up sandboxed (internal) (sub-)processes.
edit the last response, i.e. directly preceding this note, was written under the mistaken assumption that firejail would invariably be restricted by
firejail-defaultapparmor-profile. This is an incorrect assumption on my part. (https://github.com/netblue30/firejail/pull/7080#issuecomment-3962047923)