Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olifI-0006YZ-F2 for pgsql-general@arkaria.postgresql.org; Fri, 21 Oct 2022 03:25:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olifH-0006CZ-19 for pgsql-general@arkaria.postgresql.org; Fri, 21 Oct 2022 03:25:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olifG-0006CP-Gb for pgsql-general@lists.postgresql.org; Fri, 21 Oct 2022 03:25:42 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1olifE-0006uQ-5D for pgsql-general@lists.postgresql.org; Fri, 21 Oct 2022 03:25:41 +0000 Received: by mail-qk1-x72a.google.com with SMTP id b25so1281392qkk.7 for ; Thu, 20 Oct 2022 20:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=jqjCVuGzukN5gECAQoT3FV3vZsQvLSBuYQ+OHMdQMPM=; b=CDI5JzMvGB+T1IzkR2s4o3mZBxYV0SWVwm0UTwY+rSyw6TBcalVRcZmuaWbYN1d5su wkOvjmuh1tIYpjYt9Og/o+gIgsnGLKJ4Q5puAJ7GuE7yjMcNdAbRanfZbQrh4DnZZwg3 4ogVAsFSqik05WWG/Cz+dPsB4FAympyWroDQy/TqGldPDUFdcZR1osiZbnyDBn3N6ZQC OvQTt5SUirCMnY/vGgP2dV1IIS+unvW312/J0Llw4KAcaQrUmlMFw+iP/hL1KJZ5YrVk kccCFESWVX/c9Ymy4uZt3vEFVjjs4KCxSPW6H/NoSCA+R/aYaj1dGOF1tRh6Vr/aiB6D +C7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jqjCVuGzukN5gECAQoT3FV3vZsQvLSBuYQ+OHMdQMPM=; b=aXXPe1yRCWSTGxJMAJQrQIyOdjWXDI9YBSNH6nw5B4sJrXXnEaEiAoAecifmFRXhML BbJ/kRwL9bq0tWWMwcsQ/d8cPN6QJ8ZhyVfrQyYfVvT4x80NbS3Qbr0XtQtclJ4Tt0Xg hzBVxvN3qsWTjDlbE7CgVt7BHPCjuDobHNnEd6+MQ1F7B9obZVpDQpjMqGLGj/x6k4gY Y3duL0HTEQXnkOE9386mkFGOf1ACAisJDIUsYaCVCGSB0kVCuIFKWVJCuUEQnPyJ36Ho tu+wzU8r4nzCl/k0kBbvV2IR8U4zQD4ATXl4wVs8W1YHjZel43VWiFX6fvEdZU3APYja lg0g== X-Gm-Message-State: ACrzQf2n9LZNlhQsAgeCBepbIpmhRypcwNXvR13jaSS45S8Lg6yw+8Ov g0s3ZTDRvSHDI8y5XVONGt383Z6fIWHY9A== X-Google-Smtp-Source: AMsMyM7ko0dyU+hpbK9Nwar2udnPgvyVe8L7+Te6JD8REejXa2hgsGf35N9/C71z9/EWZM8MWhJvnA== X-Received: by 2002:a37:ef02:0:b0:6e4:9fd5:ba76 with SMTP id j2-20020a37ef02000000b006e49fd5ba76mr11847680qkk.405.1666322739032; Thu, 20 Oct 2022 20:25:39 -0700 (PDT) Received: from ?IPV6:2605:2a00:8000:dead:55a4:52ad:2bdc:5b8c? ([2605:2a00:8000:dead:55a4:52ad:2bdc:5b8c]) by smtp.gmail.com with ESMTPSA id h4-20020a05620a400400b006e702033b15sm8971606qko.66.2022.10.20.20.25.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Oct 2022 20:25:38 -0700 (PDT) Message-ID: <6f47c3b9-27db-2116-0c45-fcd5a17e3b37@gmail.com> Date: Thu, 20 Oct 2022 23:25:37 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: en-US To: ertan.kucukoglu@1nar.com.tr, pgsql-general@lists.postgresql.org References: <005e01d8e4be$6a516cf0$3ef446d0$@1nar.com.tr> From: Thomas Guyot Subject: Re: High CPU usage In-Reply-To: <005e01d8e4be$6a516cf0$3ef446d0$@1nar.com.tr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-10-20 15:59, ertan.kucukoglu@1nar.com.tr wrote: > Hello, > > I am using PostgreSQL v14.5 on Linux Debian 11.5. I recently observe very > high CPU usage on my Linux system as below > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ > COMMAND > 2357756 postgres 20 0 2441032 2,3g 4 S 298,7 67,9 2114:58 > Tspjzj2Z > > I could not find any file named Tspjzj2Z on the file system. I could not > find PID number using below SQL Hi, I'm not an expert in PostgreSQL but that looks like a rogue app, if you're lucky just a miner running as the prostgres user, likely the result of a postgres RCE exploited successfully... The more worring case would be a program exfiltrating and/or encrypting the database in a ransomware attack. The executable has most likely been removed to hide traces, or cleaned up automatically from ex. /tmp, however if the process is still running you should be able to cat the executable, and any other open files, directly from /proc// (look for exe and fd/*). I strongly recommend you check other postgres servers you have, make a copy of any process file found (for later investigation), then isolate or shutdown these servers and proceed with a proper investigation from a livecd or revovery OS. > There is no replication of any kind. This is a single instance server which > alows certification login only. Is is even available from the outside world? Else you should likely audit any internal hosts that could have accessed your postgresql server. If you have firewall logs looks for unusual connection attempts, any evidence of scanning, etc. Hackers will often spend quite some time once inside to gather as much information as possible before doing any real damage, although if this is effectively a miner it would be less likely to be that kind of attack as they would probably not risk getting discovered with something that will at best make them pennies... If you see the process having any open database files, it's possible it's either compressing them to exfiltrate the data or encrypting them, or both.... Hope this helps... -- Thomas