Skip to content

modif: allow userns in firejail-default apparmor profile#7080

Draft
cobratbq wants to merge 2 commits intonetblue30:masterfrom
cobratbq:grant-userns-to-firejail
Draft

modif: allow userns in firejail-default apparmor profile#7080
cobratbq wants to merge 2 commits intonetblue30:masterfrom
cobratbq:grant-userns-to-firejail

Conversation

@cobratbq
Copy link
Copy Markdown
Contributor

@cobratbq cobratbq commented Feb 25, 2026

Add userns to the AppArmor profile for firejail, such that with AppArmor enforcing restrictions, firejail is granted sufficient permissions to exert full control over the capabilities and permissions it is managing.

Fixes: #7078

  • question: Is the child-process of firejail already properly handled w.r.t. the AppArmor profile? Already before this patch, the spawned firejail child-process would likely be subjected to some influence from apparmor, or not?

The open question should not matter more/less specifically for this patch.

@cobratbq cobratbq marked this pull request as draft February 25, 2026 20:27
@cobratbq cobratbq force-pushed the grant-userns-to-firejail branch from 5967565 to 9c7189d Compare February 25, 2026 20:28
@cobratbq cobratbq marked this pull request as ready for review February 25, 2026 20:29
@kmk3 kmk3 changed the title AppArmor: grant userns to firejail process modif: allow userns in firejail-default apparmor profile Feb 25, 2026
Copy link
Copy Markdown
Collaborator

@kmk3 kmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cobratbq on Feb 25:

IIUC, adding userns to 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 to
firejail to determine whether to continue to allow it.

Nice, since this makes the profile work the same as in AppArmor 3, sounds
good to me.

Assuming that this abi/4.0 indicates 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.)

Judging by #6675, AppArmor 4 seems to be relatively recent, so I'd expect many
systems to still be using AppArmor 3.x.

If the current profiles work in AppArmor 3.x but fail with this change, then it
might be better to avoid it for now.

Can you test with AppArmor 3.x to confirm what happens?

@kmk3
Copy link
Copy Markdown
Collaborator

kmk3 commented Feb 25, 2026

Is the child-process of firejail already properly handled w.r.t. the AppArmor
profile? Already before this patch, the spawned firejail child-process
would likely be subjected to some influence from apparmor, or not?

AIUI firejail itself uses a very permissive apparmor profile
("firejail-base"?), then after setting up the sandbox, it applies a more
restrictive one ("firejail-default" I believe) right before starting the
program.

@cobratbq
Copy link
Copy Markdown
Contributor Author

cobratbq commented Feb 25, 2026

Judging by #6675, AppArmor 4 seems to be relatively recent, so I'd expect many systems to still be using AppArmor 3.x.

If the current profiles work in AppArmor 3.x but fail with this change, then it might be better to avoid it for now.

Can you test with AppArmor 3.x to confirm what happens?

I'll see if I can check a couple of things.

We may be able to define profiles with a include <abi/3.0> or include <abi/4.0> as distinguisher. It depends on whether AppArmor understands to silently skip the incompatible profile. It seems firejail-default does not currently include any definition of an ABI, thus making it compatible with older versions.

Converted to draft to reflect the open issue.

@cobratbq cobratbq marked this pull request as draft February 25, 2026 21:24
@kmk3
Copy link
Copy Markdown
Collaborator

kmk3 commented Feb 25, 2026

Judging by #6675, AppArmor 4 seems to be relatively recent, so I'd expect
many systems to still be using AppArmor 3.x. If the current profiles work
in AppArmor 3.x but fail with this change, then it might be better to avoid
it for now. Can you test with AppArmor 3.x to confirm what happens?

I'll see if I can check a couple of things.

We may be able to define profiles with a include <abi/3.0> or include <abi/4.0> as distinguisher. It depends on whether AppArmor understands to
silently skip the incompatible profile. It seems firejail-default does not
currently include any definition of an ABI, thus making it compatible with
older versions.

Good catch.

Maybe AppArmor 4 assumes abi/4.0 by default (such as by implicitly including
<abi/4.0> if no other <abi/x> is included).

So if we just add include <abi/3.0> and target 3.x, maybe it would allow user
namespaces by default, just like with AppArmor 3.x.

Edit: That is, just for the sake of fixing the user namespace support (and the
profile in general, as other things could be broken as well).

Then we could add a specific profile for 4.x, etc.

@cobratbq
Copy link
Copy Markdown
Contributor Author

cobratbq commented Feb 25, 2026

Some AppArmor notes:

@netblue30
Copy link
Copy Markdown
Owner

Thanks @cobratbq. It seems to be working fine on Debian stable, but let's wait until next week. We have a new release coming over the weekend, we'll merge it in after that.

@cobratbq
Copy link
Copy Markdown
Contributor Author

cobratbq commented Feb 26, 2026

Thanks @cobratbq. It seems to be working fine on Debian stable, but let's wait until next week. We have a new release coming over the weekend, we'll merge it in after that.

So, I'm not sure what the desired solution is for the profiles? I don't think you can write one profile version, so you would have to conditionally package one conditional on AppArmor version. That's been bugging me a bit.

On another note:

Well, if that's in place. Any chance you can check out running Firefox without apparmor-replace? I got asked, so I was curious and checked just now. I think it just works:

  • Firefox apparmor-profile enables userns in unconfined mode;
  • Firejail in enforcing mode for me;
  • running firejail with --apparmor and --ignore=apparmor-replace.

Apparmor ends up in a mixed-mode setup of Firejail enforcing and Firefox unconfined. (I think)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

AppArmor profile does not grant userns permissions

3 participants