Peertube user creating nginx process with 200% cpu usage (6.2.1)

hi!

recently (last half week or so) my vps has started to max out cpu, so I looked into it and I saw the peertube user had an nginx process that had fully utilised all cpu!

when I stop this process (kill pid) the prrocess restarts and goes to full cpu usage straight away.

this is affecting other services on the server.

any advice would be appreciated.

I could not see any notable errors in the logs for either peertube or nginx.

—edit—

I saw there was a second nginx process for peertube running, so when I stopped that the cpu-intensive process stopped restarting (it looks like) so at least my vps is not at full cpu currently. however why this is occurring and how to address it I do not know.


thanks!

Greetings, try updating Nginx to version 1.27 by adding the official repository, this should solve the problem. I think you have 1.22 or 1.24

hallo @bestperson thanks for the suggestion! I upgraded my nginx to the new version however the issue did not resolve.

if I kill the (two) nginx processes started by peertube the server appears to function (they do not restart)

however they are started on boot.

any further advice would be appreciated!

thanks!

—edit—

the two nginx processes do restart! then vps goes to high resource usage.

Hello, I would do it this way, I would completely reinstall peertube on a new server, copy it via rsync, and see how it goes. Ngnix is a regular proxy, it can’t raise the load, and have you changed the nginx config? And also as an option I would update peertube to the latest version as written in version 6.3.1

Is there anything suspicious in the nginx access logs? In the nginx error logs?
Is there many requests?

hallo, thanks for the suggestion. after viewing the peertube.access and peertube.error logs, I did not see any detail that looked like an issue, though I do not know exactly what I am looking for.

can you give me any advice on how too see an error in these logs?

thanks!

hi, I am not able to start a new instance on another server, I only have this one. I will look at updating peertube to newest version and see if that helps.

/var/log/nginx

If there are thousands of requests per second, it could explain a high CPU load.

If it is nginx that is using CPU, I don’t think Peertube is the problem.

The question is « what the **** is nginx doing?! ». You can maybe try to use lsof -p 123 (where 123 is the PID - Process ID - of the nginx process that uses 100%).
This will show you the list of opened file descriptors for the nginx process (files and even network streams).
It could be hard to read when you are not familiar, but maybe you could see some unusual files opened (for example, if you see hundreds of similar files, it could help you understand what is happening).

Just a question: have you any other service than Peertube on this server?

I run an akkoma instance, an owncast server, peertube and a static html site.

peertube ran fine for the last four months or so, upgraded it once, however now it starts to do this with nginx.

here is the lsof output for the two nginx processes:

https://pastebin.com/raw/gt0HtL4b

there are no big lists of similar files like you say, I do not know enough to understand what I am looking at.

Nginx has a .redtail file open. This is not normal.

A quick web search seems on « .redtail file » give some results about a malware that is mining crypto currencies.

First link i found (i haven’t read it fully): https://www.akamai.com/blog/security-research/2024-redtail-cryptominer-pan-os-cve-exploit

I think your server was compromised.
(not necessarely throught Peertube, could be another software, a compromised password or ssh key, …)

oh wow!

so after a little reading I could not find a guide to removing this malware, so I rm’d the .redtail binary from the peertube directory. should I change my passwords or is this a vulnerability with the peertube software itself?

thanks forr the support!

—edit— if removed the miner binary is replaced and re-run within six hours or so. I do not know how to address this issue, so any help would be appreciated.

I don’t think it is related to Peertube: i manage several instances, and i never had any malware.
Maybe a malicious Peertube plugin?

But there is no single response to such question. There are litteraly thousands of way a server can be infected.
Could be a compromised software, a brute force attack on your ssh password (if you have enabled connection using passwords), an exploit if your server is not up-to-date with the latest security fix, …
It could even be your personnal computer that is compromised (for example by a cracked video game) and propagated the malware to your servers using your ssh keys.

The first question is « how the attacker was able to install the malware ». Unfortunately, i can’t give you an exact walkthrough in a forum post to find this. Could be very difficult :confused:

(if you don’t find and block the entry point of this attack, the attacker will always be able to re-install a malware).

One way to proceed, if you have backups of your data:

  • completly re-install the server from scratch
  • Re-install all used applications (in same version as previously)
  • Restore applications data (and only data).

And even by doing so, there is a risk that the malware comes back: if any of your application can run code from its data, then there is a risk that the malware is hidden in the data.

hallo. thank you for your reply. the virus could have installed from a peertube plugin, since I added that recently or is it possible that php on this system (debian bookworm) is vulnerable.

I do not know how to back up all my services and lack the hard disk space to do so if I did know how.

I will look around to see if there is support for removing this particular virus, though I could not see a guide when I first looked.

should the peertube user be running any of the following processes:

cron
sd-pam
node
systemd

thanks for your support.

Peertube as only one running process at startup.
It can then launch ffmpeg, ytb-dlp. If you have the livechat plugin, you could also see some child process (prosody, node, …).

But the peertube user should not have process like cron or sd-pam.

The crontab is an usual trick for malware to hide them: i saw many times malwares creating files in /var/spool/cron/crontabs/, to re-install them when deleted.
So, you can start by looking in this directly, and other crontab dir (/etc/cron.d, /etc/crontab, …).

If all malware file you found are owned by the peertube user, this might be because of a plugin. Can you share the list of plugin you installed, so we could check?
(please note that it is not 100% sure… it could also be a brute force on the peertube user login/password, if you have set a password and allowed ssh connections using passwords).

You can try to read /var/log/auth.log (and rotated files, /var/log/auth.log.1, …), to see if you can find any authent attempt for the peertube user. (you should not have such attempts).

If you have installed Bookworm directly, maybe these files does not exists. In such case, you have to use journalctl to find such logs (read the documentation to see how).

Greetings, I think there is no need to get into drama. I would do this

  1. Bought a new VDS
  2. installed Peertube
  3. Moved the storage, config, database folder there as written in the migration guide
  4. I enjoyed the fact that there are no viruses
  5. Transferred it back to the formatted disk/server/well, where was it?
  6. Profit)

hallo. thank you for your reply.

there was a file in /var/spool/cron/crontabs, which is replaced if I remove it, however I changed the write permissions on the directory which appears to hhave prevented the virus from recreating the cron file.

I only had thhe livechat plugin, which I since disabled.
from what I saw viewing top, all cpu-intensive tasks were being run by the peertube user account. this suggests the virus was from a vulnerability in the peertube software, or the plugin I had installed.

I read there were other files this virus modifies, however since changing permissions on the /var/spool/cron/crontabs folder it has not restarted.

appreciate the support.