Control Web Panel

WebPanel => Information => Topic started by: Vinayak on July 28, 2023, 08:04:51 AM

Title: Roundcube big security issue.
Post by: Vinayak on July 28, 2023, 08:04:51 AM
How do we secure these logs

https://cpanel.domain.com/roundcube/logs/errors.log
https://cpanel.domain.com/webmail/logs/errors.log

And all other files withing the logs folder.

Any one visiting above URLs (replace domain.com with your actual domain) can download these log files and use them for exploitation.

I can see there is one .htaccess file, but it's not being honoured by the cwp webserver, in my case Apache.
Title: Re: Roundcube big security issue.
Post by: Starburst on July 28, 2023, 09:32:39 AM
Just checked a couple domains.
Got either a permission denied by cwpsrv or a 403.

Hop into the CLI via SSH or Terminal

cd /scripts
./mail_roundcube_update
exit


Then in CWP, goto User Accounts -> Fix Permissions

Select the user (domain)
Check -> Fix Permissions
Check -> Internal Server Error
Title: Re: Roundcube big security issue.
Post by: sva260 on July 28, 2023, 04:31:03 PM
yup confirm
Title: Re: Roundcube big security issue.
Post by: Vinayak on July 28, 2023, 08:34:40 PM
Just checked a couple domains.
Got either a permission denied by cwpsrv or a 403.

Hop into the CLI via SSH or Terminal

cd /scripts
./mail_roundcube_update
exit


Then in CWP, goto User Accounts -> Fix Permissions

Select the user (domain)
Check -> Fix Permissions
Check -> Internal Server Error

Followed above suggestion to the letter, but no use.

Some additional info.

Quote
cd /scripts
./mail_roundcube_update
Last metadata expiration check: 0:13:24 ago on Sat Jul 29 01:45:42 2023.
Dependencies resolved.
Nothing to do.
Complete!


###############################
Roundcube is already up-to-date
###############################

AlmaLinux release 8.8
CWPpro version: 0.9.8.1160
Title: Re: Roundcube big security issue.
Post by: Vinayak on July 28, 2023, 08:52:22 PM
Some additional information

This too is not secure
https://host.domain.com:2031/roundcube/logs/errors.log

And is this Owner/Group correct? Because whatever domain is used, same errors.log get downloaded.
Quote
Owner: cwpsvc
Group: cwpsvc
/usr/local/cwpsrv/var/services/roundcube/logs/errors.log

And this is happening in multiple servers, not just one.
Title: Re: Roundcube big security issue.
Post by: overseer on July 28, 2023, 10:17:10 PM
cd /scripts
./mail_roundcube_update
Note that you don't want to do this if you've manually updated to roundcube 1.5.3 (http://"https://www.alphagnu.com/topic/33-update-cwp-roundcube-mail-version-153-%E2%80%93-control-web-panel/") per Sandeep's instructions. The "logic" of the roundcube update script does not take into account the currently installed version and will merrily blow away a newer 1.5.x install and install 1.4.11 instead.
Title: Re: Roundcube big security issue.
Post by: Vinayak on July 28, 2023, 11:17:19 PM
cd /scripts
./mail_roundcube_update
Note that you don't want to do this if you've manually updated to roundcube 1.5.3 (http://"https://www.alphagnu.com/topic/33-update-cwp-roundcube-mail-version-153-%E2%80%93-control-web-panel/") per Sandeep's instructions. The "logic" of the roundcube update script does not take into account the currently installed version and will merrily blow away a newer 1.5.x install and install 1.4.11 instead.

Thanks for the heads up, but mine is default setup, webmail is running fine.

As per my earlier post result of
cd /scripts
./mail_roundcube_update
Was
Roundcube is already up-to-date

Current version is
Roundcube Webmail IMAP Client
Version 1.4.11

And these URLs are not secure, all servers are exposed.
https://cpanel.domain.com/roundcube/logs/errors.log
https://cpanel.domain.com/webmail/logs/errors.log

https://host.domain.com:2031/roundcube/logs/errors.log
https://webmail.domain.com//logs/errors.log

Entry in /usr/local/cwpsrv/var/services/roundcube/logs/.htaccess

# deny webserver access to this directory
<ifModule mod_authz_core.c>
    Require all denied
</ifModule>
<ifModule mod_authz_core.c>
    Deny from all
</ifModule>

Owner & group for /usr/local/cwpsrv/var/services/roundcube/logs/ and all files within.
Owner: cwpsvc
Group: cwpsvc
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 03, 2024, 05:00:31 PM
This issue still persists with CWPpro version: 0.9.8.1174 and no working solution to fix it.
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 03, 2024, 05:19:14 PM
Same issue on fresh install

CentOS Linux release 7.9.2009 (Core)
CWPpro version: 0.9.8.1174
Title: Re: Roundcube big security issue.
Post by: Starburst on February 03, 2024, 05:30:23 PM
Check out:
https://www.alphagnu.com/topic/33-update-cwp-roundcube-mail-version-156-%E2%80%93-control-web-panel/

That will get you RoundCube 1.5.6


And check out ELevate, that will get you away from the EOL CentOS 7.
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 03, 2024, 08:57:15 PM
I did a CentOS 7 install just to check if the issue is there too.

I understand that issue is with the version of RoundCube, but then other panels have not shown same behaviour.

Solution must come from CWP officially, else patch work may break things in future.

Any idea, how CWP future update will handle the scenario if update is applied today using Sandeep B's solution?

Also, any one tested this solution on AlmaLinux release 8.x and up ?
Title: Re: Roundcube big security issue.
Post by: Starburst on February 04, 2024, 12:19:40 AM
That link from AlphaGNU is about as 'official' as it gets.
It's not a patch that will get broken. I've gone thru multiple CWP updates, and it's still working.

I'm running RoundCube 1.5.6 using that method on AlmaLinux 8.x, and you can see my questions if you scroll down on that page about 1.6.x.

I think @overseer is as well, but he'll have to chime in to say if he is or not.
Title: Re: Roundcube big security issue.
Post by: overseer on February 04, 2024, 05:39:57 PM
Yes, Roundcube 1.5.6 (updated from Sandeep's 1.5.3 instructions, linked above). You can't get to the 1.6 branch with our current CWP kit; hopefully when EL9 support rolls out.
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 04, 2024, 05:55:12 PM
So, I applied the Roundcube 1.5.6 update on my CentOS 7 test server as per Sandeep's instructions, update was seamless and without errors, but the issue of exposed log files is still there.

These URLs are still not secure, they are still exposed to public.
https://cpanel.domain.com/roundcube/logs/errors.log
https://cpanel.domain.com/webmail/logs/errors.log

https://host.domain.com:2031/roundcube/logs/errors.log
https://webmail.domain.com//logs/errors.log
Title: Re: Roundcube big security issue.
Post by: Starburst on February 04, 2024, 06:30:08 PM
Weird. I can't duplicate what you are seeing, and I'm accessing the server from a Whitelisted IP.
When I try those URL's using our domain, I get 404 Not Found errors or Forbidden.

BTW, https://webmail.domain.com//logs/errors.log
Has 2 // after the domain name. I know it's just a type-o.

But by default those are not accessible, at least not on a AlmaLinux 8.x install with CWPpro.
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 04, 2024, 07:24:10 PM
My production versions where I found this issue initially were

AlmaLinux release 8.8
CWPpro version: 0.9.8.1160

Current versions
Distro Name: AlmaLinux release 8.9 (Midnight Oncilla)
CWPpro version: 0.9.8.1174

I will apply update on one of these server, let's see if the issue is fixed or not.
Title: Re: Roundcube big security issue.
Post by: Starburst on February 04, 2024, 08:58:31 PM
Let us know.

I'm testing on AL 8.9 with CWPpro 0.9.8.1174
Title: Re: Roundcube big security issue.
Post by: Starburst on February 05, 2024, 03:41:30 AM
@Vinayak If you haven't updated your AlmaLinux servers in awhile, you had mentioned 8.8.

You will need to install the new AlmaLinux GPG Keys first: https://almalinux.org/blog/2023-12-20-almalinux-8-key-update/
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 05, 2024, 05:40:24 AM
As I mentioned in my previous post, on my production servers AlmaLinux is updated to release 8.9 (Midnight Oncilla)
 & CWPpro version to 0.9.8.1174. I update my servers on regular basis.

For AlmaLinux GPG Keys, below is the result of command "rpm -q gpg-pubkey-ced7258b-6525146f"

gpg-pubkey-ced7258b-6525146f

This shows latest GPG Keys are installed & trusted.



Title: Re: Roundcube big security issue.
Post by: Vinayak on February 08, 2024, 09:04:14 PM
As I am still trying to fix this, I am wondering whether cwpsrv/nginx is blocking access to these log and other crucial files or not.

Any idea where to check the configuration/directives for cwpsrv/nginx to make sure on this issue?

Or some other mechanism is in use to secure such files and path?
Title: Re: Roundcube big security issue.
Post by: Netino on April 26, 2024, 06:32:48 PM
Yes, ModSecurity.
I have Como rules installed with ModSecurity, and it is blocking these access.

Regards,
Netino
Title: Re: Roundcube big security issue.
Post by: Starburst on April 26, 2024, 07:38:17 PM
We are running ModSecurity with Comodo ruleset 1.241 with no problems.

Not a ModSecurity and/or Comodo issue.
Title: Re: Roundcube big security issue.
Post by: tomkolp on February 19, 2025, 10:20:04 PM
I have the same problem? Have you found a solution yet?
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 20, 2025, 03:12:24 AM
No official solution yet.
Title: Re: Roundcube big security issue.
Post by: rcschaff on February 20, 2025, 04:09:16 AM
nano /usr/local/cwpsrv/conf/cwp_services.conf

find location /roundcube {


Add:
location /roundcube/logs/ {
        deny all;
    }

Example:
Code: [Select]
location /roundcube {
    root /usr/local/cwpsrv/var/services;
    index  index.html index.htm index.php;
    location /roundcube/logs/ {
        deny all;
    }
    location ~ \.php$ {
Title: Re: Roundcube big security issue.
Post by: Vinayak on February 20, 2025, 04:24:59 AM
Won't this get overwritten on CWP updates?
Title: Re: Roundcube big security issue.
Post by: rcschaff on February 20, 2025, 07:22:13 PM
Won't this get overwritten on CWP updates?

Most likely.  But it's a solution that the coders can implement when they see it on the forum ;)
Title: Re: Roundcube big security issue.
Post by: Starburst on February 21, 2025, 12:58:34 AM
All of our CWP installation didn't have this issue.

Logs where not accessible, the screen up up with the generic permission denied screen.

But a working ModSecurity properly configured seems to block it, along with updating to RoundCube 1.5.9, which is a LTS version.
Title: Re: Roundcube big security issue.
Post by: cyberspace on February 21, 2025, 05:54:41 PM
The extra step is necessary to close the breach. In other case the logs can be accessed over the URLs like:

https://webmail.DOMAIN.COM/logs/errors.log
https://webmail.DOMAIN.COM:2096/logs/errors.log

Add the following "location":
Code: [Select]
    location ~ \.log$ {
        deny all;
    }

into the both "server" sections of the file /usr/local/cwpsrv/conf.d/webmail.conf.

Example:

Code: [Select]
    location ~ \.log$ {
        deny all;
    }
    location / {

then restart cwpsrv:

Code: [Select]
service cwpsrv restart
Title: Re: Roundcube big security issue.
Post by: Starburst on February 23, 2025, 10:42:47 PM
So neither fix did anything on a system without the Comodo ruleset.

Interesting.

Followed what @rcschaff, and @cyberspace posted.

Both /usr/local/cwpsrv/conf/cwp_services.conf & /usr/local/cwpsrv/conf.d/webmail.conf where updated.

https://webmail.DOMAIN.COM/logs/errors.log still allowed the error log to be downloaded.

Port 2095 & 2096 have to be public also.

The team who builds Roundcube is blaming this on a deleted .htaccess file, which are confirmed there with proper permissions like @Vinayak posted.
So the webserver should be looking at those rule denying access as well.
Title: Re: Roundcube big security issue.
Post by: cyberspace on February 24, 2025, 12:20:24 AM
.htaccess is server by the webservers Apache and Litespeed. CWP panel uses nginx to handle all requests coming to the panel and included services (webmail, phpmyadmin, etc). That is why .htaccess is ignored by CWP.

Anyway, if I remove the rule from:
/usr/local/cwpsrv/conf.d/webmail.conf
then I can access the logs using:
https://webmail.domain.com/logs/errors.log
same is applied for the rule from @rcschaff.

Do you have some test system and can you provide me with access to it ?
Title: Re: Roundcube big security issue.
Post by: Starburst on February 24, 2025, 01:12:04 AM
Sent you a DM.

Just out of curiosity I deleted the /usr/local/cwpsrv/var/services/roundcube/logs/errors.log, and it's still trying to download it form somewhere.

Not sure how I got sucked into this blackhole, it's 0113...
Title: Re: Roundcube big security issue.
Post by: 6Sense on February 27, 2025, 03:45:38 AM
Thanks  :)

It now presents '403 Forbidden'.