-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full System Policy (FSP) #252
Comments
This looks very good! You actually improved my amateur profile massively. There are some minor details I do not understand. This section:
Why did you add this back? What do you mean by "Required by stacked profiles"? Phasing these out worked pretty well for me, normally. It seems you changed the approach of changing profiles. This, I presume, is to prevent the problems that might occur with nonewprivs. How does this stacking solve the problems with nonewpriv? That I do not understand unfortunately. It seems to be, reading the canonical documentation, that this should still be problematic, but I guess it is not. Also the default and default-user profiles. I am assuming we would call these whenever we are normally using pUx or something similar. So maybe phasing out more things is more suited in these profiles and not in the systemd profile? I am assuming. So my understanding is, the 'actual' full system policy is going to be these default and default-user profiles. But again, it is not clear to me how we would fallback to these profiles. We can fallback to inherit or unconfined, but there is no fallback to some other profile option. How will this be implemeted? |
A lot of service are configured with nnp options. Sometime, I use the stacking as workaround. Stacking the parent profile (systemd) with a child (see It is also good to mention that the systemd profile has It may evolve, but the current plan for the fallback (and therefore, the full policy) should work as follows:
The security benefic of such a structure is multiple:
As for right now, I am going to have a look at our main |
Default profiles added (mostly wip, expect some issue). It should be good enough for GUI programs. More advanced privileged programs are expected to have a profile. In conjunction, I am currently adding about 100 new profiles to ensure neither the In a similar way, a flatpak integration is in progress.
The solution is quite simple. The default profile attachment is: |
I see what you are doing and I don't understand how we can possibly manage this many default profiles. Two of them can be managable, for root and non root. But since the default profiles are only going to be called from other profiles, how do we know when to call default-app or default-bwrap or just default? |
Depending on users with pam is doable, but how to distinguish default-app from default? |
For now, we don't have In
In
Pam is different. On user logging, the pam role would transition the user under a given profile. See pam_roles & mappings |
On full system policy, use the new bwrap profile (and bwrap-app) to confine sandboxed application. It is not enabled by default as the sandbox profile is quite large. Also integrate with the gnome app that use bwrap as sandbox manager. Update other related profiles See Full system policy #252
- Add flatpak profile - Add flatpak-bwrap subprofile: it manage the sandbox creation & has some larger access. - Add flatpak-app, default profile for sandboxed app. See Full system policy #252
@monsieuremre full system policy should be better now. Can you test it on Whonix and report any issue? |
Debian and Kicksecure results in no unexpected behavior on Gnome with almost all the profiles enforcing even. I can do casual browsing, send emails, install stuff and run them. Xfce and KDE seem to break completely when enforcing most stuff, but I don't think this is unexpected anyway. All the testing I did was using KVM and not VirtualBox, so there is a slight chance Whonix might behave differently. I did the testing with the manual installation with make install and not by building the whonix deb package, so that will need seperate testing. I suspect the bigger problem here would be on Whonix on Qubes tho. I am in no position to test this. But I think this is looking very very good and is ready for testing by more people. @adrelanos what do you think is the way to start testing? I think you should have a look at this for yourself first. It might be a little too early to add anything to the official testing repositories of Whonix, but I think you asking people in the forums would still help massively. |
Adding a package (that is supposedly easily built) to the Kicksecure (and thereby by extension also to the Whonix) repository is doable but might be too early. I can probably do that quite soon if requested. Unfortunately, I don't have time to initially test this on Whonix, Qubes. I suppose issues could be as big as an unbootable system, broken networking and whatnot. Then me copying here apparmor denied messages, try new profiles, rinse and repeat a few times doesn't seem to be an efficient process either. General thoughts:
What other options are there?
Fixable? Might be too much of a personal question. No interest in Whonix? No problem. There's also Kicksecure for Qubes. Interested, usable? If not usable because...? Lack of hardware? I might be able to monetarily donate hardware. Otherwise would a CI server be useful? Qubes is already running a OpenQA server. Might be doable for Qubes to run OpenQA builds with full system profile. If the boot breaks, there would be logs. Then the package could be improved, merged, uploaded and check CI result again. Github Actions (CI) an option? chroot / systemd-nspawn a suitable environment to do testing? Could also rent a server in the cloud that could be used for Qubes / Whonix testing. |
Yes it is too early for that, but that should be the goal at some point I think.
When not enforcing some select profiles xfce works. So some profiles have to be in complain mode, which they actually are by default unless the user manually enforces them.
Actually I quite disagree. It would not be efficient if you were the only one doing it. But if several people could try this out, I am sure most of the possible errors would be directly apparent very fast and could then be fixed. So even if only a handful of people installed these all in complain mode and provided their apparmor logs, I am very positive this would help @roddhjav quite a lot in further developing/adjusting the full system policy. I can theoretically test for qubes with the current hardware I have, but this will require some preparation on my end to back up my current system, set up and install qubes, extensively test things and restore my old system afterwards and so on. So realistically I can't do this kind of testing any time soon due to time limitations unfortunately. |
I loove to see full system policy inside your project. And hope it will be stable and more restricted than before for enforcers like us .-) Thanks and i wish everyone else good luck. |
I agree. Once again, your work is amazing here @roddhjav. I have a literal full-system MAC policy in my system that actually functions. There is no desktop operating system that can achieve this, apart from Chrome OS, which also does it still in a rather uncomplete way compared to something like this or selinux on android. It is so amazing that we are now more close than ever to having a fine-grained, fully functioning and non-debiltating full-system MAC policy for desktop GNU/Linux. This project is the only accessible way to achieve this on any desktop os ever and it is the only way to achieve this with apparmor anywhere ever (because android does this on mobile with selinux already). This is quite literally massive. I would hope to see this implemented by general linux distributions by default also for non techy users in general with time. I am sure Whonix/Kicksecure will be the pioneer in this as they are the primary distribution focused on security. I will continue testing and try to contribute to the best of my ability. |
I hope someone can write in future method for other init systems than systemd. Because, security ppl like me dont using systemd . Dinit is btw fastest init system with less LOC than systemd 2.1 million LOC. Or devuan runit. I hope it will possible to confine these init systems. Thanks and Best regards |
It is too early to add the package to Kicksecure/Whonix. It needs testing first.
As Kicksecure/Whonix is pretty much a Debian, it should not be too hard to do knowing that Debian already works fine. My concern is more regarding the DE.
On the contrary, as long as you are testing on complain mode and report log with
I haven't tested this project with Xfce. I doubt it will even boot (even in complain mode) as too many profiles/rules would be missing. At minimum, this will require adding a lot of new profiles. It seems you are considering moving to KDE (Kicksecure/security-misc#168). If you are serious with this, it would be easier to only apply apparmor.d once the move is effective as KDE is already supported.
Biggest limitation is lack of time (as in: this project does not pay my rent, so the time I can spend in it is limited)
There is already a full CI pipeline that build the package and do basic test on both Gitlab & Github. The difficulties are that:
@monsieuremre can you share the log you got on xfce? @osevan beware, it is only supposed to work on Gnome or KDE under a distribution fully supported in this project. By design, the
I won't have time to support any other init system than systemd. However, there is a solution to have similar setup outside systemd. In apparmor 4 (in alpha) there is a new |
I want to test and debug the systemd-user profile to find out what stops it from functioning with DE's. Can not conduct tests anymore, cannot build with full and after install it.
|
Good point, I forgot to push some files. Should be fixed with 18dbc60 |
Ok initial test results. First test was to make sure that the problem was caused because of the systemd-user profile indeed. It was the case but I had my doubts that this was not the only problem. Anyway, intuitively I thought maybe it's a dbus thing, so did the following test. Adding the following lines to the profile:
Result: Successfully boots on DE, slow boot.
Seems like an issue with the other profiles. |
@roddhjav Can not reproduce everything working without any desktop environment, if this is what you meant. The same profiles, bubblewrap and so on, break the boot sequence still. Apparmor service still seems to not start properly on boot. Profiles are still enforced after the fact (somehow, no idea how). So the same behavior as with a desktop environment. Tested on debian stable, so might be version related of some package. |
This should be fixed now. I added a test in CI to ensure FSP mode always compile without issue.
That's because the fallback profile was not loaded (as it had an issue). And Apparmor breaks when it cannot find the profile to transition (this is a feature, not a bug) |
Also, to test it with the |
I have done some more tests and I can report the following. The problem is not in systemd-user. The following is the results on debian 12 gnome desktop.
Following these results I draw tthe conclusion that the problem lies within the default profile. After having booted wiht all profiles in enforce mode and default in complain mode, running ```sudo aa-status returns these as the complain mode paths:
These units are run under default, eventhough they should not be doing that. This might the root. In fact, the line
suggests the profile systemd-user is not used at all. The problem is with the transition from default. You tell me what might be the reason these select programs do not run in their profiles. |
I also have to mention, when everything is enforced but the default profile: true that it doesn't break and boots. But during shutdown, gnome session thing hangs and does not shut down properly, we wait for timeout. It boots without any issue tho. |
Do not try it in enforce mode yet, it is not ready for this (most of the profiles should stay in complain mode anyway). It seems that everything is run in the default profile, this is not supposed to work this way at all. On what system (distribution & |
No, not everything. Everything runs in their own profile with no problems. Only the ones I sent are running under default. These are the problematic profiles. This is tested in Debian 12 gnome wayland session on kvm. Default installation on everything. All I did was I downloaded the repo, then i did a |
No actually never mind. It also broke after second reboot even with default in complain mode. |
You will have to share some logs here... |
Yessir of course. But before that I want to also share this
Pipewire and systemd is now fixed doing what you suggested, but these programs still run under default. Doesn't seem right. |
Yeah so doing the same thing, I can report the following.
Problems I can tell for certain:
|
Ok I am sorry seems like everything works just fine, because there is no profile for avahi daemon. What does remove avahi daemon as it already exists mean? Where does it exist upstream? Why was avahi daemon deleted from this project? |
When all profiles are in complain and only the systemd profile is in enforce mode, boot fails no matter what. Specifically, this happens:
Everything else starts with no problems everything is green. Only these ones fail. Enforcing systemd profile only is enough. Giving all permissions apart from file execution paths won't change the result. Conclusion: the problem lies within the path and profile transmission rules in the systemd profile. It may also be due to something else, but then why does it persist even with everything allowed, apart from execute rules? No idea. |
Please, do not enforce anything yet on FSP. That is totally expected for now. Also, when you report issue, please profile aa-log too, otherwise there is nothing I can do. |
Here are some logs of what the systemd profile wants to deny normally.
|
Also, I do not want to create a separate issue just to ask this. Why was the profile for avahi daemon removed? |
Thanks, I found the solution regarding system-user. Without big surprise, it was dbus... it is always dbus (same than in #74, #80 & #235). The other log concern audio stacking, that going to be moved in
It is part of the default apparmor profile set. You should have it in |
The
|
Well that sounds about right. I have done some testing myself. The full system policy still works without the systemd-user profile still. So, what does that mean? The two are fine but they just don't work when together? How do we know that systemd user.service drop in config file is enough to make user services run under that profile? We enforce the FSP with a hook. So maybe it somehow takes prescedence? Like how else would this work? I do not think the problem lies within the systemd-user profile. No matter what changes in that, it still blocks boot. Also, it breaks on complain mode, so what does that mean? Also, why do we have a path for the sytemd-user profile? Isn't that like problematic because it is the same path as the normal systemd profile is supposed to have? |
I do agree that The
I don't think anything more should be needed here.
|
I can tell you this much, the problem very specifically lies in the line But good news. There is a way. If you change the line to Also the avahi daemon profile is not included by default in debian, you need to install the apparmor profiles or whatever package. So you might consider restoring that profile just to be included in debian builds, until the next stable comes out. |
Is it possible to extend the base abstraction for the whonix build? Because I would like to add a whonix specific abstraction that explicitly denies and forbids certain activities. There will be a file |
Dam, it seems you are right. The solution seems so simple... and I have wasted so many time on it. Thanks !
Yes, that is possible (and purposely easy):
Now, let me warn you: most of the stuff you want to block would most likely break everything if you do it for every profile. Only testing can says, what will work and what won't. So good luck I guess... |
So for the systemd profile. We have mount and umount. Which is a little too slack. So can we replace it with the following?
A little long but covers everything a system needs. Also covers 99% of all legit user specific use cases. It still blocks a lot of things compared to allowing mount all together tho. So it is a giant improvement. I am pretty sure some of these rules are not needed here but rather some other profile optimally. If that is the case point them out. |
monsieuremre:
Is it possible to extend the base abstraction for the whonix build? Because I would like to add a whonix specific abstraction that explicitly denies and forbids certain activities. There will be a file ```whonix``` under ```/etc/apparmor.d/abstractions```. This will only be installed when the target is selected as whonix when building. The abstraction will explicitly deny writing to hardware, reading raw data, reading from devices directly, reading or changing kernel parameters, executing anything under /tmp and some other directories, restrictricts access to sys and proc and their sensitive subdirectories explicitly, hides various hardware information by explicitly denying access to various paths, modifying boot parameters, among other things. This will ensure that the full system policy still protects various things even when unconfined. This is meant for whonix. Whonix implements these measures manually by other means that are much weaker. This will enable whonix to implement the measures in a mac policy, even when some parts are in complain mode. I have draft of the abstraction. I will create a pull based on your feedback. As I said, this is for the whonix target only. If there is a better way for this than universally altering the base abstraction, please let me know. I think @adrelanos would support this too.
I wouldn't want this to be Whonix specific. Perhaps Kicksecure specific?
But even better if neither specific to Whonix nor Kicksecure but a
generic feature that other users are free to re-use.
Best to keep specificity to any projects as low as possible. Possible?
|
Possible. Anyone can choose to include the abstraction with a one liner makefile modification. Having it default for the whonix target is ultimately the goal tho. |
100% agree, current |
Also the current default profile is too strict. At least read privileges are necessary for some system directories. For the root user it should be even further expanded. How does the pam integration stuff work actually? There are no solid examples and the wiki is just like, old. What can we achieve here? There is already pam_binareis and other files among your profiles but these are really not worked on. |
You can check this one from the list by the way:
And also I want to ask,
which specific profiles and profiles do we need to add manually? Can you create the dummy empty profiles so that I can test & post the logs here? |
I need to expand the documentation, security model, architecture of FSP (See: https://apparmor.pujol.io/full-system-policy/#fallback). However the basic idea is that, in FSP mode:
I still need to integrate pam into FSP. But, this is closely related to the security model and what kind of security you want to get. See https://fedoraproject.org/wiki/SIGs/ConfinedUsers |
Last addition. So the drop in files to disable no new privileges are https://github.com/roddhjav/apparmor.d/tree/main/systemd/full/system. You say we can stack profiles and not disable no new privs. Well, we do profile stacking for polkitd but we still disable no new privileges. So what's up with that? What exactly do we need to have so that we won't need to disable no new privileges? |
I was testing stuff. Disabling nnp in system drop in for a lot of programs seems a bad idea (it may require disabling much more than nnp as a lot of options imply it, and thus it is a pain to test/maintain). Meanwhile stacking is not possible for all profiles (but fine for systemd one) as it require to add all content of the profile into the parent one. I am currently cleaning this a bit... |
monsieuremre:
Possible. Anyone can choose to include the abstraction with a one liner makefile modification. Having it default for the whonix target is ultimately the goal tho.
Yes. The derivative specific opt-in then is hopefully then just a one
liner with all the complexities and features available to all
non-derivative users who wish to use it too.
|
Well you don't say. I'm on it, will have a pull very soon. But before that, imma have a pull with the mount stuff. @roddhjav did you test what you have pushed? It seems a little missing to me. First of all i think it is better to add the fstype constraints to most stuff. There is no legit reason to mount /dev with something other than udev. Same applies for a lot of things. I think /media and /mnt stuff should be added for more user convenience. To cover most anything. I do not understand the namespace thing as the target but I will after I test it. Seems like a better option than what I had for constraints. Also, I wanna ask again @roddhjav, what profiles are missing for user services? Can you at least make a list to start working on. I think these will be easier to profile than system services, which you have already done. I just want to get everything ready on the checklist's essential list before trying to test and learn integrating the pam stuff. |
Also big time problem: After installing with the full option, why does the early policy not get configured automatically? How does this make any sense? this can be automated in the makefile easily. Should create a pull request or is there a specific reason you keep it this way? |
As much as I understand you... it is more complex than this. There are multiple version of apparmor and apparmor-profiles arround. apparmor.d uses as reference the latest available (and upstream some directly into apparmor-profiles). However, as Debian is always a bit behind, apparmor.d needs to manually include some resources that are already upstreamed (see https://github.com/roddhjav/apparmor.d/tree/main/dists/ubuntu/abstractions) as well as patch the profiles for older version of apparmor. This is actually going to be a big step as apparmor 4.0 is going to be released soon. To sum up they will always be some sort of patch for some distribution.
Yes, this is tested... there is no fstype or src for some part, because the rules were not working with it. I still need to add rules regarding the
I still need to make the list, but you can have a look yourself with
and:
As it changes depending of the distribution (and the program installed), for Whonix, it will be your job to ensure everything is handled with a profile. We might be about 95% here in term of profile (and it might take more time to ensure we have everything than to write the missing - usually very simple - profiles).
early policy needs to be configured in |
Following #249, this issue aims to keep tracks on progress on full system policy (FSP) integration.
The architecture overview can be found on the documentation: https://apparmor.pujol.io/full-system-policy/
Minimal feature set for FSP
systemd
profile using early policy load.ix
) from thesystemd
profile.systemd/full
@{systemd}
variable used in rules such assignal
andptrace
set tounconfined
orsystemd
on prebuild timeservice
, to confine some systemd unit service (only)default
/default-user
Security Enhancement
systemd-user
preventssystemd --user
to start on desktop (works fine on server).The text was updated successfully, but these errors were encountered: