mirror of
https://github.com/konstruktoid/hardening.git
synced 2026-04-26 01:05:56 +03:00
[GH-ISSUE #29] [auditd] kernel panics after installation #10
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 @frederikbosch on GitHub (Aug 7, 2018).
Original GitHub issue: https://github.com/konstruktoid/hardening/issues/29
First of all, great package! I have a question around auditd. Directly after installation my VM was rebooting all the time. The reason was the audit log limit exceeded and that caused a kernel panic. I found out this was caused by our backup application that was installed before I ran the hardening script.
In order to get back control of the VM I changed the failure mode from 2 to 0 in recovery mode. Now, I want to prevent the kernel panics by adding a rule to auditd. Only I have no idea what that rule should be. I already saw in the logs that the backup program (running from /usr/sbin) was doing al kinds of operations (e.g. cp, key=tmp).
What rule should I add to prevent the Kernel panic?
@konstruktoid commented on GitHub (Aug 7, 2018):
Hi and thanks @frederikbosch!
The reason for the rebooting might be that auditd is configure to halt the system if running low on disk space.
Change the various
left_actionandmax_log_file_actionoptions fromhaltorsuspendtoadmin_space_left_action = ignore,space_left_action = ignore,max_log_file_action = rotatein the/etc/audit/auditd.conffile.@konstruktoid commented on GitHub (Aug 7, 2018):
Oh, and the auditd rules are very verbose and might be necessary to trim down in your environment depending on your ability to parse and analyze the data.
@frederikbosch commented on GitHub (Aug 7, 2018):
@konstruktoid Thanks for your replies. I am struggling with all the rules applied to my VM, auditd and others. I would really like to work with a hardened server. But am I running against all kinds of walls. At the moment I am not even able to execute
sudo nano /etc/audit/auditd.conf. I am only able to change things to the system in recovery mode. No idea why. I guess I am not experienced enough to have them.@konstruktoid commented on GitHub (Aug 7, 2018):
Try removing the auditd packages from the system when you're in single user/recovery mode, too see if that's the issue.
@frederikbosch commented on GitHub (Aug 7, 2018):
That does not bring back the possibility to execute a command with sudo. I am on Ubuntu 18.04.
/var/log/auth.logis telling me the following.The last command that I was able to execute with
sudowas the hardening script. I have removed auditd in the meanwhile, no success.@frederikbosch commented on GitHub (Aug 7, 2018):
And the password is correct, because I am able to login and change the password. I also tried to read the password from a file
sudo -S apt-get update <~/passwd.txt. Failed too.@frederikbosch commented on GitHub (Aug 7, 2018):
@konstruktoid It seemed that I fixed both issues, not being able to run
sudocommands and kernel panics because of auditd. Thanks for your help.However, I am having the
sudoproblem again. As it seems, I hit the limit of 5 password failures (deny=5from /etc/pam.d/common-auth). When I get exited from the shell, e.g. because of non-activity due to long running script, this also counts as a deny. At least that is what I am guessing. I find this in the logs.machine sudo: pam_tally2(sudo:auth): user genkgo (1000) tally 8, deny 5.In order to fix it. I have to run recovery mode again, remove /var/log/faillog and then reboot. I have no clue how to fix it otherwise.
@frederikbosch commented on GitHub (Aug 7, 2018):
I am on Ubuntu 18.04 btw.
@konstruktoid commented on GitHub (Aug 8, 2018):
Great too hear that removing
auditdfixed it; reducing the number of audit rules, using syslog/journald to send the logs to a remote server and replacing auditd halt actions with ignore might be an option as well.You can reset the pam_tally2 locks with
pam_tally2 --user=genkgo --reset, but this should reset automatically when you enter the correct username and password.@frederikbosch commented on GitHub (Aug 8, 2018):
Well, that simply does not seem to be the case. The only thing that is working is removing
/var/log/faillog.What did I do.
pam_tally2 --user genkgo --reset. But that has no consequences. You can find this out by requesting the number of failurespam_tally2 --user genkgo. That says 0, while at login I getAccount locked due to 9 failed logins./var/log/faillog, logging in worked again.@frederikbosch commented on GitHub (Aug 8, 2018):
And that confirms the behaviour I got yesterday on my VM, which was exactly the same.
pam_tally2 --user genkgo --resetsays OK andpam_tally2 --user genkgosays 0. Login saysAccount locked due to 9 failed logins.@konstruktoid commented on GitHub (Aug 8, 2018):
You're correct, but the issue is that i use
which changes the default pam_tally2 log from
/var/log/tallylogto/var/log/faillog(which is the pam_tally default...)Appending
--file /var/log/faillogto your reset will fix this issue.Will fix so default file location is used.
@frederikbosch commented on GitHub (Aug 8, 2018):
Thanks!
@frederikbosch commented on GitHub (Aug 9, 2018):
I think I am able to manage. Thanks for your swift replies and help!
@frederikbosch commented on GitHub (Aug 10, 2018):
@konstruktoid I am still playing with the audit backlog issue. For instance, when I ran the command
docker container prunethe audit backlog limit exceeded again. This was when I already had the number at524288. I guess this is due to the watch/var/lib/docker.So I am wondering what the best thing to do is. Increase the number even further? Change
-f? Why would you even want to have it at 2 (panic when a failure occurs)?@frederikbosch commented on GitHub (Aug 20, 2018):
I have asked a question regarding this topic at the Auditd mailing list. I will let you know the outcome or maybe I can create a PR to improve some configuration if necessary.
@konstruktoid commented on GitHub (Aug 21, 2018):
Thanks @frederikbosch for the post to the mailing list, interesting discussion indeed, and you and Steve Grubb (https://www.redhat.com/archives/linux-audit/2018-August/msg00029.html) are both correct.
The rules are agressive, but they are also a catch all solution and if you don't need that kind of logging the auditd settings and rules should be changed accordingly.
@frederikbosch commented on GitHub (Aug 21, 2018):
@konstruktoid Clear. But I would suggest to decrease some of the aggressiveness, because my system became almost immediately unusable. As soon as systemd started my backup app, it hit the backlog limit and consequently restarted. With another machine I also used this hardening package and while I was installing an updated kernel I hit the same limit during the update. I guess we should prevent that, even if the rules are aggressive by default.
Maybe we can split the rules:
hardening.rules,hardening-aggressive.rulesandhardening-docker.rules? I guess auditd initializes these rules in order of filename, so that would makehardening.rulesfirst and the others would be supplementary. What do you think about that?@frederikbosch commented on GitHub (Aug 22, 2018):
The command
aureport --start today --key --summarygives me the following.My suggestion would to move docker rules to a specific
hardening-docker.rulesand at least the following the keys tohardening-aggressive.rules: tmp, delete and admin_user_home. Maybe we can tighten the delete key a little bit more. I will create a PR for this.@konstruktoid commented on GitHub (Aug 23, 2018):
Ref the PR #30
@frederikbosch commented on GitHub (Aug 23, 2018):
@konstruktoid Based on the suggestion of the audit mailing list I also updated
/tmpand/var/tmpto be mounted withnoexec. Then the rules for keytmpare not necessary anymore.It only gave trouble with docker/compose of which I found a solution.
Is that something you want in this package too,
noexecfor tmp?@frederikbosch commented on GitHub (Aug 23, 2018):
Sorry, I see you already suggest it in the systemd document. Maybe we should delete watching the tmp folders in the audit rules, even in the aggressive rules. The number of logs are beyond comprehension in my opinion. I doubt if that is a good thing.
@konstruktoid commented on GitHub (Aug 23, 2018):
I would love to mount
/tmpand/var/tmpwithnoexec, but that would break any upgrades and package installations without also modifying the behavior ofdpkgandapt.@konstruktoid commented on GitHub (Aug 23, 2018):
And (after reading the new messages in the RedHat thread) the Docker rules are based on the CIS Docker Community Edition Benchmark v1.1.0.
@konstruktoid commented on GitHub (Aug 23, 2018):
Will mess around with managing
/tmpet al.@frederikbosch commented on GitHub (Aug 23, 2018):
@konstruktoid I investigated this too. At least in Ubuntu 18.04 there is no problem anymore with
noexecon tmp filesystems. I have done some updates/upgrades with apt, including new kernel installation, that works fine.I read that on previous versions, 14.04 for instance, there were problems with apt, dpkg and specifically
initramfs, and that you had to remount the tmpfs in order to install updates/upgrades. I cannot tell you unfortunately which version fixed that. I have no idea.@frederikbosch commented on GitHub (Aug 23, 2018):
Yes, I found that out too. I read version 1.13.0 and leaves me with some questions on auditing
/var/lib/docker. It leads to so many log entries. I wonder how that can be useful. Every single change a container makes will be logged because of watching/var/lib/docker/containers. Therefore I applied yesterday to the CIS Workbench so I can ask a question around that topic over there.@konstruktoid commented on GitHub (Aug 23, 2018):
Interesting about
noexecin 18.04 and you're correct, however I added the Pre/Post dpkg configuration "just in case":github.com/konstruktoid/hardening@f86b0c1233But I haven't seen anything regarding when this behavior changed.
@frederikbosch commented on GitHub (Aug 23, 2018):
@konstruktoid Did you test commit
f86b0c1? When I was investigating I tried to execute themountcommands manually on my Ubuntu 18.04 system. That failed because/tmpand/var/tmpare not in fstab. I did not find out how to (re)mount a tmpfs mounted through systemd.@konstruktoid commented on GitHub (Aug 23, 2018):
You should be able to use the
mountcommand as you normally do.@frederikbosch commented on GitHub (Aug 23, 2018):
Ah, cool, I misunderstood the remount within the
mountcommand. Now I get it. My bad. Thanks!@frederikbosch commented on GitHub (Aug 30, 2018):
Fixed by #30
@frederikbosch commented on GitHub (Sep 3, 2018):
For your info, I have opened a discussion at the CIS Workbench regarding the Docker audit rules, especially auditing
/var/lib/docker.