Skip to content

Adding support for PMA 5.1 and up#5

Merged
fzipi merged 50 commits into
coreruleset:masterfrom
azurit:v51support
Dec 22, 2023
Merged

Adding support for PMA 5.1 and up#5
fzipi merged 50 commits into
coreruleset:masterfrom
azurit:v51support

Conversation

@azurit
Copy link
Copy Markdown
Member

@azurit azurit commented Aug 5, 2022

Changes in this PR:

  • configurable support for old and new URL format
  • removed check for PMA cookies existance as it's no longer needed (plugin should be activated only on vhosts where PMA is running, not globally)
  • renumbering IDs (as a consequnce of changes above)

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Aug 27, 2022

Any reviewers / testers?

Copy link
Copy Markdown

@williamdes williamdes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No rules for the other endpoints: url.php and the setup/ folder ?

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Sep 5, 2022

@williamdes Currently no, have you encountered any problems with that endpoints while using CRS? False positives or so.

@WaleedMortaja
Copy link
Copy Markdown

WaleedMortaja commented Oct 3, 2022

Any reviewers / testers?

I have not heavy-tested it, however, the basic usage of PMA does not give false positives anymore.
Thank you!

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 3, 2022

@WaleedMortaja Thank you very much! Which version of PMA are you using?

@WaleedMortaja
Copy link
Copy Markdown

@azurit PMA 5.2.0

@WaleedMortaja
Copy link
Copy Markdown

@azurit I was testing some configs and decided to try PMA setup feature. I found some false positives on the setup "export" page with URL /setup/index.php?page=form&formset=Export. The same for "import" and "Main Panel" pages.
Just clicking the "Apply" button in these pages gives the false positive.

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 4, 2022

@WaleedMortaja Can you, please, upload logs from ModSecurity?

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 4, 2022

@WaleedMortaja Can you try current version? Thank you.

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 4, 2022

@williamdes As you wished, now we have few rules also for /setup/ folder. :)

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 4, 2022

Old URL format can be considered as tested.

ctl:ruleRemoveTargetById=933210;ARGS:prev_sql_query,\
ctl:ruleRemoveTargetById=942110;ARGS:sql_delimiter,\
ctl:ruleRemoveTargetByTag=attack-sqli;ARGS:sql_query,\
ctl:ruleRemoveTargetByTag=attack-xss;ARGS:sql_query,\
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not an expert, but curious about why are we removing XSS rules from a SQL query parameter? Did XSS cause any problems already?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sql_query parameter holds the whole SQL command, including the data which can contain anything, for example HTML code (which is triggering XSS rules).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks!

@WaleedMortaja
Copy link
Copy Markdown

@WaleedMortaja Can you try current version? Thank you.

@azurit It still has false postivies. I tried the setup's "export" page only, and got this log.
Note: some of the log is truncated or replaced with placeholders indicated by ##
Please inform me if there is a better way to provide the log.
For now, here is the log for "export":

--##PLACEHOLDER##-C--
##truncated##&Export-csv_separator=%2C&Export-csv_separator-userprefs-allow=on&Export-csv_enclosed=%22&Export-csv_enclosed-userprefs-allow=on&Export-csv_escaped=%22&Export-csv_escaped-userprefs-allow=on&Export-csv_terminated=AUTO&Export-csv_terminated-userprefs-allow=on&Export-csv_null=NULL&Export-csv_null-userprefs-allow=on&Export-csv_removeCRLF-userprefs-allow=on&Export-csv_columns-userprefs-allow=on&##truncated##
--##PLACEHOLDER##-F--
HTTP/1.1 403 Forbidden
Content-Length: 199
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

--##PLACEHOLDER##-E--

--##PLACEHOLDER##-H--
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_separator. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_separator: export-csv_separator"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_separator-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_separator-userprefs-allow: export-csv_separator-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_enclosed. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_enclosed: export-csv_enclosed"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_enclosed-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_enclosed-userprefs-allow: export-csv_enclosed-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_escaped. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_escaped: export-csv_escaped"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_escaped-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_escaped-userprefs-allow: export-csv_escaped-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_terminated. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_terminated: export-csv_terminated"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_terminated-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_terminated-userprefs-allow: export-csv_terminated-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_null. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_null: export-csv_null"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_null-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_null-userprefs-allow: export-csv_null-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_removeCRLF-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_removeCRLF-userprefs-allow: export-csv_removecrlf-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_columns-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_columns-userprefs-allow: export-csv_columns-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Access denied with code 403 (phase 2). Operator GE matched 5 at TX:anomaly_score. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "93"] [id "949110"] [msg "Inbound Anomaly Score Exceeded (Total Score: 63)"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-generic"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_separator. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_separator: export-csv_separator"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_separator-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_separator-userprefs-allow: export-csv_separator-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_enclosed. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_enclosed: export-csv_enclosed"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_enclosed-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_enclosed-userprefs-allow: export-csv_enclosed-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_escaped. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_escaped: export-csv_escaped"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_escaped-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_escaped-userprefs-allow: export-csv_escaped-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_terminated. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_terminated: export-csv_terminated"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_terminated-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_terminated-userprefs-allow: export-csv_terminated-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_null. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_null: export-csv_null"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_null-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_null-userprefs-allow: export-csv_null-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_removeCRLF-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_removeCRLF-userprefs-allow: export-csv_removecrlf-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]
Apache-Error: [file "apache2_util.c"] [line 273] [level 3] [client ##SRC_IP_PALACEHOLDER##] ModSecurity: Warning. Matched phrase "Export-CSV" at ARGS_NAMES:Export-csv_columns-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Export-CSV found within ARGS_NAMES:Export-csv_columns-userprefs-allow: export-csv_columns-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "##SERVER_IP_PALACEHOLDER##"] [uri "/##PMA_LOCATION_PLACEHOLDER##/setup/index.php"] [unique_id "##UNIQUE_ID_PALCEHOLDER##"]

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 5, 2022

@WaleedMortaja Thanks! Can you try it with current version?

@WaleedMortaja
Copy link
Copy Markdown

@azurit the setup/export is working now!
The other pages still has problems.

Here is the log for setup/import (URL: /setup/index.php?page=form&formset=Import)

Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_replace-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_replace-userprefs-allow: import-csv_replace-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_ignore-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_ignore-userprefs-allow: import-csv_ignore-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_terminated. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_terminated: import-csv_terminated"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_terminated-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_terminated-userprefs-allow: import-csv_terminated-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_enclosed. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_enclosed: import-csv_enclosed"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_enclosed-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_enclosed-userprefs-allow: import-csv_enclosed-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_escaped. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_escaped: import-csv_escaped"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_escaped-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_escaped-userprefs-allow: import-csv_escaped-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]
Message: Warning. Matched phrase "Import-CSV" at ARGS_NAMES:Import-csv_col_names-userprefs-allow. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "329"] [id "932120"] [msg "Remote Command Execution: Windows PowerShell Command Found"] [data "Matched Data: Import-CSV found within ARGS_NAMES:Import-csv_col_names-userprefs-allow: import-csv_col_names-userprefs-allow"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "language-powershell"] [tag "platform-windows"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]

Here is the log for setup/Main Panel (URL: /setup/index.php?page=form&formset=Main)

Message: Warning. Matched phrase "dev/null" at ARGS:DefaultTransformations-External. [file "/etc/httpd/modsecurity.d/activated_rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "500"] [id "932160"] [msg "Remote Command Execution: Unix Shell Code Found"] [data "Matched Data: dev/null found within ARGS:DefaultTransformations-External: 0 -f/dev/null -i -wrap -q 1 1"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.0"] [tag "application-multi"] [tag "language-shell"] [tag "platform-unix"] [tag "attack-rce"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"]

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 5, 2022

@WaleedMortaja Thanks, try now!

@WaleedMortaja
Copy link
Copy Markdown

@azurit All the setup pages are working now.
I am not aware of any more FP currently.

Thank you for your efforts 😄

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Oct 5, 2022

@WaleedMortaja Thank you very much for testing!

ctl:ruleRemoveTargetById=942200;REQUEST_COOKIES:pma_console_config,\
ctl:ruleRemoveTargetById=942260;REQUEST_COOKIES:pma_console_config"

SecMarker "END-PHPMYADMIN-RULE-EXCLUSIONS-PLUGIN-V51-URL-FORMAT"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you limit the URLs that can be called to only the endpoints that 5.1 has?
https://github.com/phpmyadmin/phpmyadmin/blob/QA_5_1/index.php
https://github.com/phpmyadmin/phpmyadmin/blob/QA_5_1/url.php
https://github.com/phpmyadmin/phpmyadmin/blob/QA_5_1/show_config_errors.php
https://github.com/phpmyadmin/phpmyadmin/blob/QA_5_1/js/messages.php
PHP files in https://github.com/phpmyadmin/phpmyadmin/tree/QA_5_1/setup

See my nginx regex https://github.com/sudo-bot/gh-deployer-container/blob/04b50cde53ac13f71c444b09dd31dcecaca3eee2/docker/nginx-default.conf#L29

location ~ ^(?!(\/favicon\.ico|\/robots\.txt|\/index\.php|\/url\.php|\/show_config_errors\.php|\/js\/messages\.php|\/js\/dist|\/js\/vendor|\/doc\/html|\/setup|\/themes|\/)) {
        deny all;
    }

Copy link
Copy Markdown
Member Author

@azurit azurit Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@williamdes Not sure about this. What exactly do you expect from it?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it limits the urls that can be visited adding more security by 403 everything else

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dune73 What do you think about this? Should it be part of CRS RE plugin? For me, it sounds like it's out of scope.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating an allow-list is a useful security measure, but it's out of scope for a rule exclusion plugin.

If you guys think there is wider interest for such a configuration, I suggest to create a separate allow-list plugin.

ctl:ruleRemoveTargetById=941120;REQUEST_COOKIES,\
ctl:ruleRemoveTargetById=942100;REQUEST_COOKIES:auto_saved_sql,\
ctl:ruleRemoveTargetById=942200;REQUEST_COOKIES:pmaAuth-1,\
ctl:ruleRemoveTargetById=942340;REQUEST_COOKIES:pmaAuth-1,\
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this assume there is only one server on the configuration?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. Can you show how cookies looks like for multiple server setup?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 is the server ID, any unsigned integer should be allowed
You can view cookies for a multi server setup on our demo server 5.2.x-dev

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this apply for both pmaAuth-X and pmaUser-X?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Dec 28, 2022

@williamdes pls what's difference between routes /database/export and /export?

@williamdes
Copy link
Copy Markdown

@williamdes pls what's difference between routes /database/export and /export?

https://github.com/phpmyadmin/phpmyadmin/blob/f6a03d405d5c4d4ad6e356ed654917a79418207c/libraries/routes.php#L63

https://github.com/phpmyadmin/phpmyadmin/blob/f6a03d405d5c4d4ad6e356ed654917a79418207c/libraries/routes.php#L216

It seems that one is more for tables and the other for databases
I am not sure there is much different code between them
Do you need some deeper information on those routes?

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Dec 29, 2022

It seems that one is more for tables and the other for databases

For tables, there seems to be a /table/export route.

Do you need some deeper information on those routes?

No, i just need to know if i should:

  • add this route for database export rule
  • add this route for table export rule
  • create completely new rule

It's more or less a philosophical question. :)

@williamdes
Copy link
Copy Markdown

It seems that one is more for tables and the other for databases

For tables, there seems to be a /table/export route.

Do you need some deeper information on those routes?

No, i just need to know if i should:

* add this route for database export rule

* add this route for table export rule

* create completely new rule

It's more or less a philosophical question. :)

@MauricioFauth you created the controllers, maybe you could better answer this question?

But I would say that since it is not prefixed it could be used in different ways, so maybe a new rule?

@MauricioFauth
Copy link
Copy Markdown

MauricioFauth commented Jan 9, 2023

@williamdes pls what's difference between routes /database/export and /export?

Initially the routes were a direct map with the files. For example:

  • server_export.php => /server/export
  • db_export.php => /database/export
  • tbl_export.php => /table/export
  • export.php => /export

Now, more routes are been added as we are extracting then from the controllers. As a lot of routes are doing too much.

Basically, /server/export, /database/export and /table/export only renders the related export page, and the /export route is the one doing the actual export.

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Jan 11, 2023

@MauricioFauth Thanks, that helped a lot!

@MauricioFauth @williamdes What about this? What action it was?

POST /index.php?route=/

=== POST ARGUMENTS ===
ajax_request: true
server: 3
db: information_schema
guid: <censored>
access_time: 414
check_timeout: 1
_nocache: <censored>
token: <censored>

@williamdes
Copy link
Copy Markdown

@MauricioFauth Thanks, that helped a lot!

@MauricioFauth @williamdes What about this? What action it was?

POST /index.php?route=/

=== POST ARGUMENTS ===
ajax_request: true
server: 3
db: information_schema
guid: <censored>
access_time: 414
check_timeout: 1
_nocache: <censored>
token: <censored>

I guess it's the ping pong to check if the session expired?

@williamdes
Copy link
Copy Markdown

Hi @azurit
We started development of 6.0 instead of 5.3. One breaking change is that we will have everything from 5.2 rules in a public directory

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Mar 3, 2023

@williamdes Thanks for the info!

To all: New URL format can be considered as tested.

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Dec 19, 2023

Just in case, please use Squash and merge here.

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Dec 20, 2023

@azurit To the best of my knowledge, I think I've fixed the conflict. Let me know if this is ready before merging.

@azurit
Copy link
Copy Markdown
Member Author

azurit commented Dec 22, 2023

@fzipi Thank you! Should be ready to merge.

@fzipi fzipi merged commit 5fa5a2c into coreruleset:master Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants