-
Notifications
You must be signed in to change notification settings - Fork 521
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
Inotify resource exhaustion #10
Comments
hey, thanks for your feedback! absolutely true. in almost all cases it will be enough to monitor maybe the best way to go would be monitoring of 10 to 15 standard directories, possibly depending on distro. using the existing flags you could add other directories as needed. |
Live an we learn an we code to create better |
Hello,
Thank you for making such a useful tool :)
So recently I noticed that when running
pspy
, that it was not very well picking up some short livedcron
scripts. After more investigation, I realised the issue was related to running multiple copies of the tool. The first instance works fine, but the second instance misses lots of short lived processes. This is because in its default configuration it attempts to useinotify
on almost every directory it has access to, exhausting the users supply of inotify watches. Then the second instance is unable to get notified in a timely fashion when a process start.Linux limits the number of inotify watches with the value in
/proc/sys/fs/inotify/max_user_watches
. From the Debian based machines I've looked at this is set to8192
. Thus, on the machine I was testing on (fairly basic Ubuntu 18.04 with Python and PHP) the number of directories are:Thus, just running once instance of this tool completely exhausts the limit for inotify watches. Also, this could also be unfair to other CTF players.
Moreover, I tested watching different directories. It appears that probably the only file that needs to be watched to provide a good user experience is
/etc/ld.so.cache
. I suspect that the vast majority of the time the processes that will be of interest are dynamic.Probably, the better solution is to replace the attempt at blanket inotify watches to the whole file system and instead use a short list of directories. E.g. something like (with bin directories to catch any static binary executions):
/etc
/bin
/usr/bin
/usr/local/bin
Possibly, it could print a warning of the
ld.so.cache
if is not found in one of the directories.Of course, the user will always be free to configure the tool as they want, but in a default config I dont think it should inadvertently perform a resource exhaustion attack!
I hope this is of some use, it took a while to properly identify. Also, while tracking down the issue, I came across some other minor improvements that I'll submit a PR for you to consider.
The text was updated successfully, but these errors were encountered: