server icon indicating copy to clipboard operation
server copied to clipboard

Mod Security blocks the domain on receiving errors from NextCloud

Open shifulegend opened this issue 8 years ago • 3 comments

Steps to reproduce

  1. Install Contacts
  2. Click on create contact and get the error 'contact cannot be created'
  3. Your domain is blocked

Alternatively the same thing happens when

  1. Install Mail
  2. Configure Mail
  3. Receive an email with images
  4. Click on show images Both the above steps gets my access revoked temporarily

I contacted my shared hosting provider and got the below response: Upon checking we found that mod security rule was blocking your website.

ModSecurity is one of the apache server modules that provides a complete website protection by defending hackers and other malicious attacks. It is a set of rules with regular expressions that helps to instantly ex-filtrate the commonly known exploits.Modsecurity obstructs the processing of invalid data (code injection attacks) to reinforce and nourish server's security

We found following error logs for your domain :

[Wed Aug 01 17:11:32.085823 2018] [:error] [pid 3576774:tid 139707807471360] [client 117.247.150.204:56238] [client 117.247.150.204] ModSecurity: Warning. Operator GE matched 5 at TX:inbound_anomaly_score. [file "/etc/apache2/conf.d/modsec_vendor_configs/OWASP3/rules/RESPONSE-980-CORRELATION.conf"] [line "37"] [id "980130"] [msg "Inbound Anomaly Score Exceeded (Total Inbound Score: 5 - SQLI=0,XSS=0,RFI=0,LFI=0,RCE=0,PHPI=0,HTTP=0,SESS=0): Request content type is not allowed by policy"] [tag "event-correlation"] [hostname "www.agarwalsaraogi.com"] [uri "/files/index.php"] [unique_id "W2Hpw2qYgH-ApXjN@UZ3cQAAABE"]

Please note that we can not white list this rule because white listing the above mentioned rule will leave the server vulnerable so Please contact your web developer to check the code.

Expected behaviour

The contact should be created or the error should not have any impact on the access rights and the mail should show images. Plus, there are times when this has happened and I am unsure what triggered it.

Actual behaviour

Tell us what happens instead My access to the top level domain gets revoked temporarily

Server configuration

Operating system: Linux Web server: CPanel Database: mySQL PHP version: 7.1 Nextcloud version: (see Nextcloud admin page) 13.0.5 Updated from an older Nextcloud/ownCloud or fresh install: 13.0.4 Where did you install Nextcloud from: Softaculous Signing status:

Signing status
Login as admin user into your Nextcloud and access 
http://example.com/index.php/settings/integrity/failed 
No errors have been found.

List of activated apps:

App list Mail Contacts Notes
If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder

Nextcloud configuration:

Config report
If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your Nextcloud installation folder

or 

Insert your config.php content here. 
Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …)
'xx', 'passwordsalt' => 'xxx', 'secret' => 'xxx', 'trusted_domains' => array ( 0 => 'www.com', ), 'datadirectory' => '/xx/nextclouddata', 'overwrite.cli.url' => 'xx/files', 'dbtype' => 'mysql', 'version' => '13.0.5.2', 'dbname' => 'xx', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'dbuser' => 'axx21', 'dbpassword' => 'xx', 'installed' => true, 'maintenance' => false, 'theme' => '', 'loglevel' => 2, 'memcache.local' => '\\OC\\Memcache\\APCu', 'app.mail.accounts.default' => array ( 'email' => '%USERID%@axx.com', 'imapHost' => 'XX.com', 'imapPort' => 993, 'imapSslMode' => 'ssl', 'smtpHost' => 'XXcom', 'smtpPort' => 465, 'smtpSslMode' => 'ssl', ), 'mail_smtpmode' => 'smtp', 'mail_smtpauthtype' => 'LOGIN', 'mail_from_address' => 'admin', 'mail_domain' => 'XX', 'mail_smtpauth' => 1, 'mail_smtphost' => 'XX', 'mail_smtpport' => '465', 'mail_smtpsecure' => 'ssl', 'mail_smtpname' => 'XX', 'mail_smtppassword' => 'XX', );
**Are you using external storage, if yes which one:** local/smb/sftp/... **Are you using encryption:** yes/no **Are you using an external user-backend, if yes which one:** LDAP/ActiveDirectory/Webdav/... #### LDAP configuration (delete this part if not used)
LDAP config ``` With access to your command line run e.g.: sudo -u www-data php occ ldap:show-config from within your Nextcloud installation folder Without access to your command line download the data/owncloud.db to your local computer or access your SQL server remotely and run the select query: SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap'; Eventually replace sensitive data as the name/IP-address of your LDAP server or groups. ```
### Client configuration **Browser:** Chrome **Operating system:** Windows 7 ### Logs #### Web server error log
Web server error log ``` Insert your webserver log here ```
#### Nextcloud log (data/nextcloud.log)
Nextcloud log [nextcloud.log](https://github.com/nextcloud/server/files/2252400/nextcloud.log) ```
#### Browser log
Browser log ``` Insert your browser log here, this could for example include: a) The javascript console log b) The network log c) ... ```

shifulegend avatar Aug 02 '18 06:08 shifulegend

GitMate.io thinks possibly related issues are https://github.com/nextcloud/server/issues/6018 (nextcloud Content-Security-Policy problem), https://github.com/nextcloud/server/issues/5056 (nextcloud 12 upgrade error), https://github.com/nextcloud/server/issues/9541 (Nextcloud 13 - since upgrade from NC12, there are a lot of "Trusted domain errors"), https://github.com/nextcloud/server/issues/4670 (Apps_paths are blocking nextcloud upgrades), and https://github.com/nextcloud/server/issues/237 (503 Error after nextcloud runs a time).

nextcloud-bot avatar Aug 02 '18 06:08 nextcloud-bot

There was a repo with some modified rules to run ownCloud: https://github.com/owncloud/mod_security

It is known that it doesn't run with the default setup. In general you have to modify rules that they suit your security policy and catch potential problems of a script. Ideally you would go through each failing rule, check what it does exactly and check why Nextcloud does not match this rule and if that is really necessary. Perhaps it is just a module or app that you don't really need. On a shared host, you can only try to make it work with an existing rule set.

tflidd avatar Aug 15 '18 09:08 tflidd

I'm closing this ticket because it hasn't received any updates in a long time. If this is still relevant, feel free to re-open or file a new ticket.

Thank you.

ChristophWurst avatar Apr 30 '19 07:04 ChristophWurst