coreruleset: Wordpress REST API Response: (403) Forbidden , rule exclusion help for this

Description

I am running a live site. https://danran.rocks On my wordpress site health status page, I am getting a performance error/notification:

The REST API encountered an unexpected result
Performance
The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.

When testing the REST API, an unexpected result was returned:

REST API Endpoint: https://danran.rocks/wp-json/wp/v2/types/post?context=edit
REST API Response: (403) Forbidden

I believe this needs a rule exclusion, but I really don’t know where to start. In the logs it seems like it is a cookie problem but I have no idea how to exclude specific cookies.

Do you think you could help me create a rule exclusion to work so that I don’t get curl errors in my wordpress installation?

Any help is much appreciated!

How to reproduce the misbehavior (-> curl call)

I don’t know how to do a curl call, but my logs are below:

Logs

---Corg2X8X---A--
[26/Jul/2024:02:47:44 -0500] 172198006423.863660 127.0.0.1 43446 127.0.0.1 443
---Corg2X8X---B--
GET /wp-json/wp/v2/types/post?context=edit HTTP/1.1
Host: danran.rocks
User-Agent: WordPress/6.5.5; https://danran.rocks
Cookie: wordpress_sec_740531fd29902d777d631092ad187b89=Danran|1722147706|LnH6dW4hgShd0jHqKlwrAbQpP1ZQJq1cnXAER5mI7Xg|01ea01b1bf4d1fe3d703f90fd1a2f03e8d2a47de86db5fcff877273addf24204; _pk_id_2_cfa4=8e2a3c22448c0e61.1720003885.; _ga=GA1.1.482340392.1720003885; wp-settings-1=libraryContent=browse&editor=tinymce&advImgDetails=show&hidetb=1; wp-settings-time-1=1720004036; wordpress_test_cookie=WP Cookie check; wp_lang=en_US; _ga_XKRRP1GEPK=GS1.1.1720040865.3.1.1720040867.0.0.0; wordpress_logged_in_740531fd29902d777d631092ad187b89=Danran|1722147706|LnH6dW4hgShd0jHqKlwrAbQpP1ZQJq1cnXAER5mI7Xg|97abb5c7529b09fa8622a51a5401fda7db2a4d11ee1b2b6d8e8715d4f336d7fa; PHPSESSID=9c25dlip4m92cpjpvnje4v1a04; _pk_ref_2_cfa4=["","",1721977075,"https://gravatar.com/"]; _pk_ses_2_cfa4=1; redux_current_tab=20; redux_current_tab_get=20; redux_current_tab_epcl_theme=21
Accept: */*
Accept-Encoding: deflate, gzip, br, zstd
Cache-Control: no-cache
Connection: close
X-WP-Nonce: e01ef67abe

---Corg2X8X---E--
\xa1\x88\x04\x00 :\xb7\xceF\xe8\x84\x06\x0c\xf2\xa3)X\xc4\x82\x1bI=Y\xc8\x99]2\x92L\x0a\x0aZ\xa37|\xdc\xbe5I\xe4bPIXo\xd5\x05mi!\xeb\xcdn\xd3!\x14&\xcb$\x98d!\xd8Q\x19\xc5\x95\xca\xc5\xaar\x8c\x1bY\xd6\x80\xf0\xfa\xdc\xfe\xb8kD\xd3l\x00

---Corg2X8X---F--
HTTP/1.1 403
Server: nginx
Date: Fri, 26 Jul 2024 07:47:44 GMT
Content-Type: text/html
X-Content-Type-Options: nosniff
Connection: close
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Content-Encoding: br
Content-Security-Policy: default-src * data: 'unsafe-eval' 'unsafe-inline' blob:
Referrer-Policy: no-referrer-when-downgrade
x-frame-options: SAMEORIGIN

---Corg2X8X---H--
ModSecurity: Warning. Matched "Operator `Rx' with parameter `(?i).\|(?:[\s\v]*|b[\"'\)\[-\x5c]*(?:(?:(?:\|\||&&)[\s\v]*)?\$[!#\(\*\-0-9\?-@_a-\{]*)?\x5c?u[\"'\)\[-\x5c]*(?:(?:(?:\|\||&&)[\s\v]*)?\$[!#\(\*\-0-9\?-@_a-\{]*)?\x5c?s[\"'\)\[-\x5c]*(?:(?:(?:\|\||&&)[ (9637 characters omitted)' against variable `REQUEST_COOKIES:wordpress_sec_740531fd29902d777d631092ad187b89' (Value: `Danran|1722147706|LnH6dW4hgShd0jHqKlwrAbQpP1ZQJq1cnXAER5mI7Xg|01ea01b1bf4d1fe3d703f90fd1a2f03e8d2a47 (26 characters omitted)' ) [file "/etc/nginx/modsec/crs4.0/rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf"] [line "1074"] [id "932220"] [rev ""] [msg "Remote Command Execution: Unix Command Injection with pipe"] [data "Matched Data: 6|Ln found within REQUEST_COOKIES:wordpress_sec_740531fd29902d777d631092ad187b89: Danran|1722147706|LnH6dW4hgShd0jHqKlwrAbQpP1ZQJq1cnXAER5mI7Xg|01ea01b1bf4d1fe3d703f90fd1a2f03e8d2a47de86 (22 characters omitted)"] [severity "2"] [ver "OWASP_CRS/4.0.0"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-shell"] [tag "platform-unix"] [tag "attack-rce"] [tag "paranoia-level/2"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/88"] [tag "PCI/6.5.2"] [hostname "127.0.0.1"] [uri "/wp-json/wp/v2/types/post"] [unique_id "172198006423.863660"] [ref "o16,4v752,126o16,4v276,126"]
ModSecurity: Access denied with code 403 (phase 2). Matched "Operator `Ge' with parameter `5' against variable `TX:BLOCKING_INBOUND_ANOMALY_SCORE' (Value: `10' ) [file "/etc/nginx/modsec/crs4.0/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "176"] [id "949110"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Score: 10)"] [data ""] [severity "0"] [ver "OWASP_CRS/4.0.0"] [maturity "0"] [accuracy "0"] [tag "anomaly-evaluation"] [hostname "127.0.0.1"] [uri "/wp-json/wp/v2/types/post"] [unique_id "172198006423.863660"] [ref ""]

Your Environment

  • CRS version (e.g., v3.3.4): CRS 4.0
  • Paranoia level setting (e.g. PL1) : PL2
  • ModSecurity version (e.g., 2.9.6): I’m not sure how to find the version
  • Web Server and version or cloud provider / CDN (e.g., Apache httpd 2.4.54): Nginx 1.27.0 Mainline
  • Operating System and version: Ubuntu Server 22.04 for Raspberry Pi (aarch64)

Confirmation

[x] I have removed any personal data (email addresses, IP addresses, passwords, domain names) from any logs posted.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

@Danrancan You don’t have to wait to encounter the false positive every time you want to test a new rule exclusion, you can use curl to send the offending payload again. Just run the curl command I gave you earlier again and see if you get blocked, feel free to tweak some settings if you need to and then run the curl command again.

Since your false positive is with a session cookie, this will be annoying to fix since they tend to change without using something like curl to test.