-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodsecurity_plugins_configmap.yaml
3126 lines (2864 loc) · 115 KB
/
modsecurity_plugins_configmap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
apiVersion: v1
kind: ConfigMap
metadata:
labels:
grafana_dashboard: "1"
name: modsecurity-plugins
data:
empty-after.conf: |
# no data
empty-before.conf: |
# no data
empty-config.conf: |
# no data
argocd-rule-exclusions-before.conf: |
# -------------------------------------------------------------------------
# allow deletions from the argocd web ui
# TODO: can maybe prune the methods here a bit more
# -------------------------------------------------------------------------
SecRule REQUEST_FILENAME "@beginsWith /api/v1/applications/" \
"id:30005,\
phase:1,\
ver:'argocd-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=GET HEAD POST PUT DELETE'"
grafana-rule-exclusions-before.conf: |-
# -------------------------------------------------------------------------
# allow exceptions for rules 933210, 942100, 932110 for using datasources
# loki and prometheus via grafana, should try to make these more granular later
# -------------------------------------------------------------------------
# needs tuning
# for catching grafana QL passed as ARGS:json.queries.array_0.expr in grafana
SecRule REQUEST_URI "@beginsWith /api/ds/query?ds_type" \
"id:20013,\
phase:1,\
ver:'grafana-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
ctl:ruleRemoveTargetById=932125;ARGS:json.queries.array_0.expr,\
ctl:ruleRemoveTargetById=942100;ARGS:json.queries.array_0.expr,\
ctl:ruleRemoveById=933210,ctl:ruleRemoveById=942100,ctl:ruleRemoveById=932110"
# for catching grafana QL passed as ARGS:json.queries.array_0.expr in grafana
SecRule REQUEST_URI "@beginsWith /api/query-history" \
"id:20030,\
phase:1,\
ver:'grafana-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
ctl:ruleRemoveTargetById=932125;ARGS:json.queries.array_0.expr"
# needs tuning
SecRule REQUEST_URI "@beginsWith /api/datasources/uid/prometheus/resources/api/v1/label" \
"id:20017,\
phase:1,\
pass,\
ver:'grafana-rule-exclusions-plugin/1.0.0',\
nolog,\
ctl:ruleRemoveById=932110"
# this avoids issues when users change the default dashboard view
SecRule REQUEST_URI "@rx /api/user/helpflags/.*$" \
"id:20012,\
phase:1,\
ver:'grafana-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
setvar:'tx.allowed_methods=PUT'"
# this is for when a user tries to hit the explore link in a prometheus alert link
SecRule REQUEST_URI "@beginsWith /explore?orgId=" \
"id:20029,\
phase:1,\
ver:'grafana-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
ctl:ruleRemoveTargetById=932125;ARGS:left"
home-assistant-rule-exclusions-before.conf: |
# -------------------------------------------------------------------------
# home assistant rule exclusions
# -------------------------------------------------------------------------
# allow content type of text/plain, but process the body as JSON
SecRule REQUEST_URI "@beginsWith /auth/login_flow" \
"id:20023,\
phase:1,\
ver:'home-assistant-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
t:none,\
ctl:requestBodyProcessor=JSON,\
setvar:'tx.allowed_request_content_type=|text/plain|'"
# Allow PUT method to login endpoint
SecRule REQUEST_URI "@beginsWith /auth/login_flow" \
"id:20024,\
phase:1,\
ver:'home-assistant-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
t:none,\
setvar:'tx.allowed_methods=PUT POST DELETE'"
# this is a legit endpoint for home assistant for some reason
SecRule REQUEST_URI "@rx /frontend_latest/.*.js$" \
"id:20025,\
phase:1,\
ver:'home-assistant-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveById=930130"
# register sensor
SecRule REQUEST_URI "@beginsWith /api/webhook/" \
"id:20033,\
phase:1,\
ver:'home-assistant-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=933150;ARGS:json.data.unique_id"
matrix-rule-exclusions-before.conf: |-
# -------------------------------------------------------------------------
# allow uploads for matrix via element web and mobile
# to avoid rule 920420 which doesn't allow |application/octet-stream|
# -------------------------------------------------------------------------
# allow octet-stream content type for uploads
# url should be like /_matrix/media/v3/upload or /_matrix/media/r0/upload
SecRule REQUEST_URI "@rx ^/_matrix/media/(?:v3|r0)/upload.*$" \
"id:20015,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_request_content_type=|application/octet-stream| |image/jpeg| |image/png| |image/gif|'"
# allow PUT, OPTIONS to allow uploads
# url should be like /_matrix/media/v3/upload or /_matrix/media/r0/upload
SecRule REQUEST_URI "@rx ^/_matrix/media/(?:v3|r0)/upload.*$" \
"id:20016,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=POST PUT OPTIONS'"
# allow PUT, OPTIONS to allow sending all sorts of user/room/device data:
# /_matrix/client/v3/user/username/account_data/im.vector.setting.breadcrumbs
# /_matrix/client/v3/sendToDevice/m.room.encrypted
# /_matrix/client/v3/room_keys/keys?version=1
# /_matrix/client/v3/profile
# /_matrix/client/v3/directory/room/
# /_matrix/client/v3/register
# /_matrix/client/v3/pushrules/global/room
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:v3|r0)/(?:rooms|user|devices|account|pushrules|profile|sendToDevice|room_keys|register|directory)/.*$" \
"id:20018,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=GET POST PUT DELETE OPTIONS'"
# allow updating presense indicator
SecRule REQUEST_URI "@beginsWith /_matrix/client/r0/presence/" \
"id:20040,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=PUT'"
# allow creating new rooms
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:v3|r0)/createRoom$" \
"id:20032,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=933150;ARGS_NAMES:json.is_direct"
# allow prometheus alerts to be posted
# also allows key verification with weird keys
# /_matrix/client/r0/rooms/.*/send/m.room.message/.*
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:v3|r0)/rooms/.*/send/m.room.message/.*$" \
"id:20027,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveById=920420,\
ctl:ruleRemoveTargetById=933210;ARGS:json.formatted_body,\
ctl:ruleRemoveTargetById=930120;ARGS:json.formatted_body"
# also allow edits to messages in encrypted rooms
# /_matrix/client/r0/rooms/.*/send/m.room.encrypted/.*
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:v3|r0)/rooms/.*/send/m.room.encrypted/.*$" \
"id:20034,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=933150;ARGS:json.ciphertext"
# allow users to push up their keys from mobile or desktop
# /_matrix/client/r0/pushers/set
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:r0|v3)/pushers/set$" \
"id:20026,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=930120;ARGS_NAMES:json.profile_tag"
# allows mautrix bridges to send things like:
# "Unknown command, use the `help` command for help."
# or
# "This is your management room: prefixing commands with `!discord` is not required.\n"
# which are responses from a bridge bot to a matrix user with admin access to the bot
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:v3|r0)/rooms/.*/send/m.room.message/mautrix-go_.*$"\
"id:20019,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=942190;ARGS:json.body,\
ctl:ruleRemoveTargetById=942360;ARGS:json.body,\
ctl:ruleRemoveTargetById=932100;ARGS:json.body"
# allow PUT, OPTIONS to allow sending room key data:
# /_matrix/client/unstable/room_keys/keys?version=1
SecRule REQUEST_URI "@beginsWith /_matrix/client/unstable/room_keys/keys" \
"id:20020,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=GET POST PUT DELETE OPTIONS',\
ctl:ruleRemoveById=930120"
# this is for users forwarding room keys
# /_matrix/client/v3/room_keys/keys?version=1
SecRule REQUEST_URI "@rx ^/_matrix/client/(?:v3|r0)/room_keys/keys.*$" \
"id:20031,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveById=930120"
# allow PUT method for sending read recipets
SecRule REQUEST_URI "@beginsWith /_matrix/federation/v1/send/" \
"id:20021,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=GET POST PUT OPTIONS'"
# this is actually for a local s3 server that you have dedicated to matrix
# can be commented out if not running local s3 server such as seaweedfs
# /matrix/local_thumbnails/.*/32-32-image-jpeg-crop
SecRule REQUEST_URI "@rx ^/matrix/(?:local_thumbnails|local_content)/.*$" \
"id:20022,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
t:none,\
setvar:'tx.allowed_methods=GET HEAD POST PUT'"
SecRule REQUEST_URI "@rx ^/matrix/local_content/.*$" \
"id:20028,\
phase:1,\
ver:'matrix-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
t:none,\
ctl:ruleRemoveById=920340"
postgres-s3-rule-exclusions-before.conf: |-
# -------------------------------------------------------------------------
# allow postgresql to upload wal archives to s3
# allow PUT, DELETE, and POST methods for base backups
# -------------------------------------------------------------------------
SecRule REQUEST_URI "@rx ^/(?:matrix|zitadel|nextcloud)-postgres/(?:matrix|zitadel|nextcloud)-postgres/(?:wals|base)/.*$" \
"id:20000,\
phase:1,\
ver:'postgres-rule-exclusions-plugin/1.0.0',\
pass,\
nolog,\
t:none,\
ctl:ruleRemoveById=920340,\
ctl:ruleRemoveById=921110,\
ctl:ruleRemoveById=920440,\
setvar:'tx.allowed_methods=DELETE GET POST HEAD PUT'"
zitadel-rule-exclusions-before.conf: |
# Enable grpc parsing for zitadle only, avoids hitting ruleID 920420"
SecRule REQUEST_URI "@beginsWith /zitadel.auth.v1.AuthService" \
"id:30001,\
phase:1,\
ver:'zitadel-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_request_content_type=|application/grpc-web+proto|'"
SecRule REQUEST_URI "@beginsWith /zitadel.admin.v1.AdminService" \
"id:30002,\
phase:1,\
ver:'zitadel-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_request_content_type=|application/grpc-web+proto|'"
SecRule REQUEST_URI "@beginsWith /zitadel.management.v1.ManagementService" \
"id:30003,\
ver:'zitadel-rule-exclusions-plugin/1.0.0',\
phase:1,\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_request_content_type=|application/grpc-web+proto|'"
# zitadel sends a __Host-zitadel.useragent cookie that sometimes has a = in it
SecRuleUpdateTargetById 941120 "!REQUEST_COOKIES:__Host-zitadel.useragent"
nextcloud-rule-exclusions-before.conf: |-
# Gadgetbridge.db is a valid backup file
SecRule REQUEST_URI "@rx ^/index.php/apps/files/api/v1/thumbnail/[0-9]+/[0-9]+/Gadgetbridge.db$" \
"id:30004,\
phase:1,\
ver:'nextcloud-small-hack-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=920440;TX:EXTENSION"
# to allow occ federation:sync-addressbook
SecRule REQUEST_URI "@beginsWith /ocm/shares" \
"id:30006,\
phase:1,\
ver:'nextcloud-small-hack-rule-exclusions-plugin/1.0.0',\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=GET HEAD POST PUT DELETE'"
# ------------------------------------------------------------------------
# OWASP CRS Plugin
# Copyright (c) 2021-2024 CRS project. All rights reserved.
#
# The OWASP CRS plugins are distributed under
# Apache Software License (ASL) version 2
# Please see the enclosed LICENSE file for full details.
# ------------------------------------------------------------------------
# OWASP CRS Plugin
# Plugin name: nextcloud-rule-exclusions
# Plugin description:
# Rule ID block base: 9,508,000 - 9,508,999
# Plugin version: 1.2.0
# Documentation can be found here:
# https://github.com/coreruleset/nextcloud-rule-exclusions-plugin
# Generic rule to disable plugin
SecRule TX:nextcloud-rule-exclusions-plugin_enabled "@eq 0" "id:9508099,phase:1,pass,nolog,ctl:ruleRemoveById=9508100-9508999"
# These exclusions remedy false positives in a default Nextcloud install.
# They will likely work with OwnCloud too, but you may have to modify them.
#
# To relax upload restrictions for only the php files that need it,
# you put something like this in crs-setup.conf:
#
# SecRule REQUEST_FILENAME "@rx /(?:remote\.php|index\.php)/" \
# "id:9508600,\
# phase:2,\
# t:none,\
# nolog,\
# pass,\
# ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
# setvar:'tx.restricted_extensions=.bak/ .config/ .conf/'"
#
# Large uploads can be modified with SecRequestBodyLimit. Or they
# can be more controlled by using the following:
#
# SecRule REQUEST_URI "@endsWith /index.php/apps/files/ajax/upload.php" \
# "id:9508610,\
# phase:1,\
# t:none,\
# nolog,\
# ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
# ctl:requestBodyLimit=1073741824"
#
# ctl:requestBodyLimit is not supported in libmodsecurity3, Nginx users can increase max upload size
# by using the following:
# location /index.php/apps/files/ajax/upload.php { modsecurity_rules 'SecRequestBodyLimit 1073741824'; }
#
# Apache libmodsecurity3 Example:
# <location "/index.php/apps/files/ajax/upload.php">
# modsecurity_rules 'SecRequestBodyLimit 1073741824'
# </location>
#
#
# The Nextcloud desktop client occasionally sends large request bodies not containing any uploaded files.
# ModSecurity will block request bodies larger than 131KB, adjusting SecRequestBodyNoFilesLimit to
# 141KB works for all scenarios tested.
#
# Nginx libmodsecurity3 Example:
# location /remote.php/dav/files/ { modsecurity_rules 'SecRequestBodyNoFilesLimit 144384'; }
#
# Apache modsecurity2 Example:
# <location "/remote.php/dav/files/">
# SecRequestBodyNoFilesLimit 144384
# </location>
#
# Apache libmodsecurity3 Example:
# <location "/remote.php/dav/files/">
# modsecurity_rules 'SecRequestBodyNoFilesLimit 144384'
# </location>
# [ Local CRS initialization ]
#
# We need to initialize some of the CRS variables also here because plugin setup runs before
# CRS initialization (this is a known limitation of the current plugin architecture). Must be
# kept in sync with CRS default setting.
# Copy of CRS rule 901160.
SecRule &TX:allowed_methods "@eq 0" \
"id:9508100,\
phase:1,\
pass,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
setvar:'tx.allowed_methods=GET HEAD POST OPTIONS'"
# Copy of CRS rule 901162.
SecRule &TX:allowed_request_content_type "@eq 0" \
"id:9508101,\
phase:1,\
pass,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
setvar:'tx.allowed_request_content_type=|application/x-www-form-urlencoded| |multipart/form-data| |multipart/related| |text/xml| |application/xml| |application/soap+xml| |application/json| |application/cloudevents+json| |application/cloudevents-batch+json|'"
#
# [ File Manager ]
#
# The web interface uploads files, and interacts with the user.
SecRule REQUEST_FILENAME "@contains /remote.php/webdav" \
"id:9508102,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveById=920420,\
ctl:ruleRemoveById=920440,\
ctl:ruleRemoveById=941000-942999,\
ctl:ruleRemoveById=951000-951999,\
ctl:ruleRemoveById=953100-953130,\
ctl:ruleRemoveByTag=attack-injection-php"
# Skip PUT parsing for invalid encoding / protocol violations in binary files.
SecRule REQUEST_METHOD "@streq PUT" \
"id:9508105,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_FILENAME "@rx /remote\.php/(?:webdav|dav)" \
"t:none,\
ctl:ruleRemoveById=921150,\
ctl:ruleRemoveById=930110,\
ctl:ruleRemoveById=930120,\
ctl:ruleRemoveById=920000-920999,\
ctl:ruleRemoveById=932000-932999"
# Fix for Nextcloud Desktop Client / Allow sending source code
SecRule REQUEST_METHOD "@pm PROPFIND PUT" \
"id:9508106,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_FILENAME "@rx /remote\.php/(?:webdav|dav/files)" \
"t:none,\
ctl:ruleRemoveById=921110"
# Allow the data type 'text/vcard'
# Allow path traversal characters like /../ in file paths.
# Allow all filetypes.
# Allow source code.
# Allow arbitrary filenames.
# Allow upload of files containing code
SecRule REQUEST_FILENAME "@contains /remote.php/dav/files/" \
"id:9508110,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveById=920440,\
ctl:ruleRemoveById=930100-930110,\
ctl:ruleRemoveById=951000-951999,\
ctl:ruleRemoveById=953100-953130,\
ctl:ruleRemoveTargetById=921110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=933210;REQUEST_FILENAME,\
ctl:ruleRemoveTargetById=944120;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944130;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944240;REQUEST_BODY,\
setvar:'tx.allowed_request_content_type=%{tx.allowed_request_content_type} |text/plain| |text/vcard|'"
# File manager: versioning
# Allow the data type 'text/plain'
# Since the content is actually XML, we switch on the XML parser
SecRule REQUEST_FILENAME "@beginsWith /remote.php/dav/versions/" \
"id:9508111,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_HEADERS:Content-Type "@beginsWith text/plain" \
"t:none,\
ctl:requestBodyProcessor=XML,\
setvar:'tx.allowed_request_content_type=%{tx.allowed_request_content_type} |text/plain|'"
# File manager: system tags
# Allow the data type 'text/plain'
# Since the content is actually XML, we switch on the XML parser
SecRule REQUEST_FILENAME "@rx /remote\.php/dav/systemtags(?:-relations/files/[0-9]+|-assigned/image)?/$" \
"id:9508112,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_HEADERS:Content-Type "@beginsWith text/plain" \
"t:none,\
ctl:requestBodyProcessor=XML,\
ctl:ruleRemoveTargetById=921110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=920272;REQUEST_BODY,\
ctl:ruleRemoveTargetById=920273;REQUEST_BODY,\
setvar:'tx.allowed_request_content_type=%{tx.allowed_request_content_type} |text/plain|'"
# Allow the data type 'application/octet-stream'
SecRule REQUEST_METHOD "@pm PUT MOVE" \
"id:9508115,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_FILENAME "@rx /remote\.php/dav/(?:files|uploads)/" \
"setvar:'tx.allowed_request_content_type=%{tx.allowed_request_content_type} |application/octet-stream| |application/pdf|'"
# Allow data types like video/mp4
SecRule REQUEST_METHOD "@streq PUT" \
"id:9508116,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_FILENAME "@rx /(?:public\.php/webdav|remote\.php/dav/uploads)/" \
"t:none,\
ctl:ruleRemoveById=920340,\
ctl:ruleRemoveById=920420"
# Allow REPORT requests without Content-Type header (at least the iOS app does this)
SecRule REQUEST_METHOD "@streq REPORT" \
"id:9508121,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_FILENAME "@contains /remote.php/dav/files/" \
"t:none,\
ctl:ruleRemoveById=920340"
# FP when NextCloud default app "Text" detects text files in file manager.
# PUT - When the "Text" app tries to create a session in file manager.
# Opening/creating a text file
# Nextcloud 28 and newer will include the document ID after session
SecRule REQUEST_FILENAME "@rx /apps/text/(?:public/)?session(?:/[0-9]+)?/create$" \
"id:9508122,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
setvar:'tx.allowed_methods=%{tx.allowed_methods} PUT'"
# FP while trying to open text files in file manager
# Adding/editing comments to files
# The content of comments could be anything
SecRule REQUEST_FILENAME "@rx /remote\.php/dav/comments/files(?:/[0-9]+)+$" \
"id:9508123,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:message,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:json.message,\
setvar:'tx.allowed_request_content_type=%{tx.allowed_request_content_type} |text/plain|'"
# When trying to change the "Show recommendations" option in file settings
SecRule REQUEST_FILENAME "@endsWith /apps/recommendations/settings/enabled" \
"id:9508124,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
setvar:'tx.allowed_methods=%{tx.allowed_methods} PUT'"
# Autosaving/syncing a text document, content could be anything
# Manually saving a text document
# As of Nextcloud 28, the document ID is included in the URL path
SecRule REQUEST_URI "@rx /apps/text/(?:public/)?session(?:/[0-9]+)?/(?:sync|save)$" \
"id:9508126,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=920272;REQUEST_BODY,\
ctl:ruleRemoveTargetById=920273;REQUEST_BODY,\
ctl:ruleRemoveTargetById=921110;REQUEST_BODY,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:autosaveContent,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:json.autosaveContent"
# Text app content can be anything
# We disable CRS for all ARGS since the paramater keeps on changing and can't be predicted
SecRule REQUEST_FILENAME "@rx /apps/text/(?:public/)?session/push$" \
"id:9508128,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS"
# Viewing files within the trashbin
# Content is XML so the XML parser is switched on
SecRule REQUEST_FILENAME "@rx /remote\.php/dav/trashbin/[^/]+/trash/" \
"id:9508170,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_HEADERS:Content-Type "@beginsWith text/plain" \
"t:none,\
chain"
SecRule REQUEST_METHOD "@streq PROPFIND" \
"t:none,\
ctl:requestBodyProcessor=XML,\
setvar:'tx.allowed_request_content_type=%{tx.allowed_request_content_type} |text/plain|'"
# Entering a password for a password protected share
SecRule REQUEST_FILENAME "@rx /s/[^/]+/authenticate/showShare$" \
"id:9508171,\
phase:1,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:password,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0'"
# Sharing a file/folder
# Fix FP when creating a share with a password
SecRule REQUEST_FILENAME "@rx /ocs/v[0-9]\.php/apps/files_sharing/api/v[0-9]/shares(?:/[0-9]+)?$" \
"id:9508172,\
phase:1,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=930120;ARGS:json.path,\
ctl:ruleRemoveTargetById=930120;ARGS:path,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:password,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:json.password,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
setvar:'tx.allowed_methods=%{tx.allowed_methods} PUT DELETE'"
# Syncing files with Nextcloud desktop app
# Matches:
# - /remote.php/dav/files/username/
# - /remote.php/dav/files/path/to/example.txt (does not assume that
# all files must have an extension)
SecRule REQUEST_FILENAME "@contains /remote.php/dav/files/" \
"id:9508173,\
phase:3,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule RESPONSE_STATUS "@rx ^50[023]$" \
"t:none,\
ctl:ruleRemoveById=950100"
# Uploading files to Nextcloud
# This FP is usually triggered when uploading via the mobile app
SecRule REQUEST_FILENAME "@rx /remote\.php/dav/uploads/[^/]+/[a-z0-9]+/[0-9]+$" \
"id:9508174,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveById=920341,\
ctl:ruleRemoveTargetById=921110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944100;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944120;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944130;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944200;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944240;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944250;REQUEST_BODY"
# Uploading files in bulk
SecRule REQUEST_FILENAME "@endsWith /remote.php/dav/bulk" \
"id:9508175,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveById=921422,\
ctl:ruleRemoveTargetById=920260;REQUEST_BODY,\
ctl:ruleRemoveTargetById=921110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=931110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944100;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944110;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944120;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944130;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944240;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944210;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944250;REQUEST_BODY,\
ctl:ruleRemoveTargetById=944260;REQUEST_BODY"
# Uploading files via Windows desktop client
SecRule REQUEST_FILENAME "@rx /remote\.php/dav/uploads/[^/]+/[0-9]+/\.file$" \
"id:9508176,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule &REQUEST_HEADERS:if "@eq 1" \
"t:none,\
ctl:ruleRemoveById=920450"
# 200002 will trigger if a request with a content type is sent with an empty request body.
# This typically happens when creating a file/folder in a public share.
SecRule REQUEST_FILENAME "@contains /public.php/dav/files/" \
"id:9508177,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule REQUEST_HEADERS:Content-Type "@beginsWith text/plain" \
"t:none,\
chain"
SecRule REQUEST_BODY_LENGTH "@eq 0" \
"t:none,\
ctl:ruleRemoveById=200002"
# When uploading files via public shares, the content type header will be set to whatever file type is being uploaded.
# This rule allows all content types for public shares since it could be anything.
# Rules 920420, 920480, and 920530 should catch any injection attacks on the content-type header.
SecRule REQUEST_FILENAME "@contains /public.php/dav/files/" \
"id:9508178,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveById=920420"
#
# [ Searchengine ]
#
# Nextcloud uses a search field for filename or content queries.
SecRule REQUEST_FILENAME "@contains /index.php/core/search" \
"id:9508125,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=941000-942999;ARGS:query,\
ctl:ruleRemoveTargetById=932000-932999;ARGS:query,\
ctl:ruleRemoveTargetByTag=attack-injection-php;ARGS:query"
# Searching for files, folders, contacts, tasks, emails, etc.
SecRule REQUEST_FILENAME "@rx /ocs/v[0-9]\.php/search/providers(?:/[^/]+/search)?$" \
"id:9508132,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=920230;ARGS:from,\
ctl:ruleRemoveTargetById=932190;ARGS:from,\
ctl:ruleRemoveTargetById=932200;ARGS:from,\
ctl:ruleRemoveTargetById=942200;ARGS:from,\
ctl:ruleRemoveTargetById=942210;ARGS:from,\
ctl:ruleRemoveTargetById=942430;ARGS:from,\
ctl:ruleRemoveTargetById=942440;ARGS:from"
#
# [ DAV ]
#
# Nextcloud uses DAV methods with index.php and remote.php to do many things
# The default ones in ModSecurity are: GET HEAD POST OPTIONS
#
# Looking through the code, and via testing, I found these:
#
# File manager: PUT DELETE MOVE PROPFIND PROPPATCH
# Calendars: REPORT
# Others in the code or js files: PATCH MKCOL MOVE TRACE
# Others that I added just in case, and they seem related:
# CHECKOUT COPY LOCK MERGE MKACTIVITY UNLOCK.
SecRule REQUEST_FILENAME "@rx /(?:remote|index|public)\.php/" \
"id:9508130,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
setvar:'tx.allowed_methods=%{tx.allowed_methods} PUT PATCH CHECKOUT COPY DELETE LOCK MERGE MKACTIVITY MKCOL MOVE PROPFIND PROPPATCH SEARCH UNLOCK REPORT TRACE jsonp'"
# Allow CalDav/CarDav clients to scan for CalDav CarDav path
SecRule REQUEST_FILENAME "@streq /" \
"id:9508131,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=921110;REQUEST_BODY,\
setvar:'tx.allowed_methods=%{tx.allowed_methods} PROPFIND'"
#
# [ Preview and Thumbnails ]
#
# Preview
SecRule REQUEST_FILENAME "@contains /index.php/core/preview.png" \
"id:9508150,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=932150;ARGS:file"
# Filepreview for trashbin
SecRule REQUEST_FILENAME "@contains /index.php/apps/files_trashbin/ajax/preview.php" \
"id:9508155,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=932150;ARGS:file,\
ctl:ruleRemoveTargetById=942190;ARGS:file"
#
# [ Ownnote ]
#
SecRule REQUEST_FILENAME "@contains /index.php/apps/ownnote/" \
"id:9508300,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveById=941150"
#
# [ Text Editor ]
#
# This file can save anything, and it's name could be lots of things.
SecRule REQUEST_FILENAME "@contains /index.php/apps/files_texteditor/" \
"id:9508310,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=920370-920390;ARGS:filecontents,\
ctl:ruleRemoveTargetById=920370-920390;ARGS_COMBINED_SIZE,\
ctl:ruleRemoveTargetById=921110-921160;ARGS:filecontents,\
ctl:ruleRemoveTargetById=932150;ARGS:filename,\
ctl:ruleRemoveTargetByTag=OWASP_CRS;ARGS:filecontents"
# Keeping track of client session within a text editor
# Nextcloud 28 and newer will include the document ID in the Request URI after session
# Matches:
# /apps/text/session/sync
# /apps/text/session/close
# /apps/text/session/push
# /apps/text/public/session/sync
# /apps/text/public/session/close
# /apps/text/public/session/push
# /apps/text/attachments
SecRule REQUEST_FILENAME "@rx /apps/text/(?:public/)?(?:session/(?:[0-9]+/)?(?:sync|close|push|save)|attachments)$" \
"id:9508311,\
phase:2,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
chain"
SecRule ARGS:sessionToken|ARGS:json.sessionToken "@rx (?i)^[a-z0-9+/]+$" \
"t:none,\
ctl:ruleRemoveTargetById=920273;ARGS:sessionToken,\
ctl:ruleRemoveTargetById=932236;ARGS:sessionToken,\
ctl:ruleRemoveTargetById=942390;ARGS:sessionToken,\
ctl:ruleRemoveTargetById=942432;ARGS:sessionToken,\
ctl:ruleRemoveTargetById=942450;ARGS:sessionToken,\
ctl:ruleRemoveTargetById=920273;ARGS:json.sessionToken,\
ctl:ruleRemoveTargetById=932236;ARGS:json.sessionToken,\
ctl:ruleRemoveTargetById=942390;ARGS:json.sessionToken,\
ctl:ruleRemoveTargetById=942432;ARGS:json.sessionToken,\
ctl:ruleRemoveTargetById=942450;ARGS:json.sessionToken,\
ctl:ruleRemoveTargetById=920273;REQUEST_BODY"
# Syncing client side document state
# Nextcloud 28 and newer will include the document ID in the Request URI after session
SecRule REQUEST_FILENAME "@rx /apps/text/(?:public/)?session/(?:[0-9]+/)?(?:sync|close|push|save)$" \
"id:9508312,\
phase:1,\
pass,\
t:none,\
nolog,\
ver:'nextcloud-rule-exclusions-plugin/1.2.0',\
ctl:ruleRemoveTargetById=920273;ARGS:documentState,\
ctl:ruleRemoveTargetById=932236;ARGS:documentState,\
ctl:ruleRemoveTargetById=932250;ARGS:documentState,\
ctl:ruleRemoveTargetById=941100;ARGS:documentState,\
ctl:ruleRemoveTargetById=942210;ARGS:documentState,\
ctl:ruleRemoveTargetById=942390;ARGS:documentState,\
ctl:ruleRemoveTargetById=942432;ARGS:documentState,\
ctl:ruleRemoveTargetById=942450;ARGS:documentState,\
ctl:ruleRemoveTargetById=920273;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=932236;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=932250;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=941100;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=942210;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=942390;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=942432;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=942450;ARGS:json.documentState,\
ctl:ruleRemoveTargetById=920273;REQUEST_BODY"
# Guest Token
# This value is null for non public shares, so only remove the target for public ones
# Nextcloud 28 and newer will include the document ID in the Request URI after session