Default Dashboard - Can't Configure Text Block

Default Dashboard - Can't Configure Text Block

by Jeff Lewis -
Number of replies: 8

403 Forbidden error received when "Configuring a (new text block) Block" after adding Text to the Block.  This is within a brand new Clean Install of Moodle 4.04 with personalized settings that worked in 3.11 and only One Course imported with No User info for testing purposes.

After pasting already html formatted text that I wished to move from Site Home "Summary of Site" into the Text Block added to the Main Dashboard area, I did notice the Content area showed the error at the bottom: "you must supply a value here", despite the text having been entered.  This error does NOT appear when text is typed or copied into the content area without using the html formatting option.  Either way, however, resulted in a 403 Forbidden error occurs.

I then tested configuring a Text Block within the Block Drawer.  This time, I simply pasted the moved text into the content area without using the html formatting option.  It Saved successfully!!!  However, I still needed the html formatting I had used previously for "Summary of Site", so I tried to paste it again from within the Editor's html formatting option.  Again, I received the 403 Forbidden error, and now the error occurs however the text is entered into the Content area of the Text Block.

Further testing resulted in "you must supply a value here" when entering brand new text through the html editing option.  When the html editor is closed, "you must supply a value here" still remains.  However, when additional text is added to the existing text entered using the html editor, the error goes away, but a 403 Forbidden error still results when trying to save the now accepted text.

This seems related to my "Can't update questions" issue.  Are both these issues Editor related, based on the above?  I'm using the default Editor.  Why would it accept the edit once, when entered directly into the Content area, then forever rejected after using the html editor to paste already formatted text that has worked successfully elsewhere?

Thanks


Average of ratings: -
In reply to Jeff Lewis

Re: Default Dashboard - Can't Configure Text Block

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Unexpected 403 Forbiddens can be caused by a web application firewall (WAF) in front of the web server. The WAF can block the request so it doesn't get through to Moodle.

Typically I just turn the WAF off. A better approach would be to configure the WAF so these requests aren't blocked.

If you're not sure whether you have a WAF please tell us more about how your Moodle site is hosted, specifically if it's on a local server, if it's a server hosted by a third party (e.g. a VPS), or if it's on a shared managed hosting service.

In reply to Leon Stringer

Re: Default Dashboard - Can't Configure Text Block

by Jeff Lewis -
Hi Leon, thank you so much for your reply!! Unfortunately, I don't believe it's a WAF issue, because I've been designing this course for over a year in Moodle 3.10 and 3.11 without issue on the same third party VPS. The problem only started with the upgrade to 4.04.

That being said, if what you suggest will fix it without creating a security risk, happy to try it. I have root access to WHM and cPanel, if that helps you to easily tell me where to make the change.

Thanks again!!! This 403 Forbidden thing has been hell!!!
In reply to Jeff Lewis

Re: Default Dashboard - Can't Configure Text Block

by Shivanesh Lal -
Picture of Plugin developers
Hi Jeff,

403 error seems a permission issue, can you run check if SElinux is running?
SElinux command to check -> getenforce
if the response is "enforcing" try setting it to permissive and see if the issue is resolved
command to set SElinux to permissive setenforce 0



Thanks
Shiv
In reply to Shivanesh Lal

Re: Default Dashboard - Can't Configure Text Block

by Jeff Lewis -
Hi Shiv,

Thanks for the input. My attempt to access the Command Line was refused, so I'm having my VPS Host look into it.

Inspired by Leon, I tried turning off Apache ModSecurity by disabling "Apache_userdir Tweak" through cPanel (if that was the correct way to test it), but it didn't help.

I also tested a temporary deletion of the .htaccess file in public_html (in case it was corrupted), as suggested by my Host's Help pages, but this didn't make a difference either.

Even if your fix ultimately or another Mod_security fix works, wouldn't this still be a Moodle bug, since I never had any issues until upgrading to Moodle 4.04?

Thanks again,
Jeff
In reply to Jeff Lewis

Re: Default Dashboard - Can't Configure Text Block

by Shivanesh Lal -
Picture of Plugin developers
Hi Jeff,

from my Moodle experience it does not look like a moodle bug coz moodle bugs usually returns php error, and 403 is a server error when the permissions are not set properly. if you get into root ssh via whm to vps check the apache logs under /var/logs/ should be able to nail down the issue.
In reply to Jeff Lewis

Re: Default Dashboard - Can't Configure Text Block

by Ken Task -
Picture of Particularly helpful Moodlers

Me thinks there is more than meets the eye! .... Here's why ...

Mod_Security rules can be updated automatically and usually are.

If one changes what loads into apache, that requires restart of apache service.
Can your account do that?

Do you have access to: /var/log/httpd/ and the modsec_audit.log files at that location?

I have mod_security running but in the listen mode - not enforcing.

In mod_security.conf

    SecRuleEngine DetectionOnly

That means it logs and actually shows what would have been blocked, the referrer, and the rule that was tripped.   What I have seen is 'false positives' ... example ...

referer indicated it was a authenticated user in a moodle who had access rights/permissions to edit something and action was denied due a tripping of a rule - falsely.

Has a set of rules files and data files for those rules in:
/etc/httpd/modsecurity.d/activated_rules/

modsecurity_35_bad_robots.data
modsecurity_35_scanners.data
modsecurity_40_generic_attacks.data
modsecurity_50_outbound.data
modsecurity_50_outbound_malware.data
modsecurity_crs_20_protocol_violations.conf
modsecurity_crs_21_protocol_anomalies.conf
modsecurity_crs_23_request_limits.conf
modsecurity_crs_30_http_policy.conf
modsecurity_crs_35_bad_robots.conf
modsecurity_crs_40_generic_attacks.conf
modsecurity_crs_41_sql_injection_attacks.conf
modsecurity_crs_41_xss_attacks.conf
modsecurity_crs_42_tight_security.conf
modsecurity_crs_45_trojans.conf
modsecurity_crs_47_common_exceptions.conf
modsecurity_crs_48_local_exceptions.conf.example
modsecurity_crs_49_inbound_blocking.conf
modsecurity_crs_50_outbound.conf
modsecurity_crs_59_outbound_blocking.conf
modsecurity_crs_60_correlation.conf

Example of a false positive:
[Tue Oct 04 23:35:24.170672 2022] [:error] [pid 5556] [client x.x.x.x:58422] [client x.x.x.x]
ModSecurity: Warning. Operator GE matched 5 at TX:inbound_anomaly_score.
[file "/etc/httpd/modsecurity.d/activated_rules/modsecurity_crs_60_correlation.conf"] [line "37"] [id "981204"] [msg "Inbound Anomaly Score Exceeded (Total Inbound Score: 16, SQLi
=3, XSS=0): 981243-Detects classic SQL injection probings 2/2"] [hostname "mymoodleservfqdn"] [uri "/moodle40/course/modedit.php"] [unique_id "Yz0JjOYz60rGL2PutnJudQAAAAE"], ref
erer: https://myserverfqdn/moodle40/course/modedit.php?update=145&return=0&sr=0

That's me (my x.x.x.x ip) logged onto a 4.0.4+ as an admin level and editing a resource.
the rule: 981204 so would need to investigate that rule to see what tweaks could be done with it.   Because I have mod_security loading but not enforcing ... just listening I can edit.

My 2 cents,

'SoS', Ken



Average of ratings: Useful (1)
In reply to Ken Task

Re: Default Dashboard - Can't Configure Text Block

by Jeff Lewis -
SOLUTION:

First, in the spirit of helping future users, since this applies to ALL 403 Forbidden errors in general, and not just this particular instance: it would be great if this solution could be posted somewhere as such, so someone else knows to seek help from their Website Provider instead of Moodle for, at least, an immediate workaround.  As a newbie, it never occurred to me to look or think outside the Moodle box to solve a problem that was occurring within Moodle, especially since our Moodle was working perfectly for over a year using 3.10 and then 3.11 and only became unworkable with our upgrade to 4.04.  Since I tried to post a more directly targeted error report regarding a LearnR Theme so it wouldn't get lost/buried, and my attempt was shut down as a "duplicate post", I assume a Moodle Moderator would need to do this.

For example, this solution also seems to have resolved our own multitude of instances with "I can't update questions", which I spent an entire week trying to resolve, as reported through my many troubleshooting updates posted here:

https://moodle.org/mod/forum/discuss.php?d=438024

No one replied there with any Web Application suggestions, as finally happened here.  If it was a more widespread 403 Forbidden issue, it might have garnered more attention, but it wasn't and didn't, which makes it that much more important for anyone else dealing with a 403 Forbidden error to easily find a straightforward solution through a simple search in MoodleDocs.  As of now, if it wasn't for Leon and then Shiv suggesting here that the issue might be resolved through the Web Server, which led me to searching for and finding the first post about Forbidden errors (listed below), which then sent me to the 2nd post listed below about Mod_Security (which is quite old), my entire week of hell would only be stretching into two. 

https://moodle.org/mod/forum/discuss.php?d=95086

Thus, it would be great if a specific post was provided that addresses 403 Forbidden errors and their solution to help others moving forward, which I assume a Moodle Moderator must do.

As for the solution itself: A workaround was indeed implemented through our Web Application's Mod_Security, though the error must still be rooted in Moodle 4, since it wasn't present in Moodle 3.10 or 3.11 (no?).  When I told my VPS Provider that I was experiencing 403 Forbidden errors, he immediately suspected it was a Mod_Security issue and asked for a direct link to our Moodle website, including step-by-step instructions on how to recreate the error on his end.  Luckily, the "Text Block" error occurred on a separately staged Clean install of Moodle 4.04, so there were no security, privacy, or IP related risks preventing me from giving him System Administrator access to this dev Website for him to recreate the error, which I could not have provided for our Main website.

In case we need to troubleshoot it moving forward, I learned that he used our Web Server's WHM/cPanel plugin within WHM called:

"ConfigServer ModSecurity Control"

...to check the apache logs and work on the website to 'force' the error, so he could see the actual ID that was triggering the mod_security. After that, he could whitelist the rule per domain/subdomain name.

In this case, the Rule ID turned out to be "341256", in case this applies to others.  This one rule exception also seems to have resolved our many instances of  "I can't update questions".

While I still don't know exactly how to "whitelist the rule", which can be done using this plugin as well, I do know that the Apache log:

"/etc/apache2/logs/modsec_audit.log"

...can be checked with the above plugin, which lists the ID needed for the whitelist as well as more information on the errors, such as the example copied below.  This way, we will at least be able recreate the issue ourselves and locate the ID required for whitelisting from the logs, then give the ID to our Host provider to Whitelist the ID for us (unless someone else can post how to do that here), without having to give them Teacher access to a Course, or System Administrator access to our Moodle.

Here are two Apache Error Log examples, in case they help with further troubleshooting of the 403 Forbidden within Moodle itself:

"detected XSS using libinjection. [file "/etc/apache2/conf.d/modsec/modsec_rules/12_asl_adv_xss_rules.conf"] [line "37"] [id "341256"] [rev "3"] [msg "Atomicorp.com WAF Rules: Possible Cross Site Scripting attack (detectXSS)"] [data "<p dir=\x22ltr\x22 style=\x22text-align: left;\x22>my title2 here</p>,ARGS:config_text[text]"] [severity "CRITICAL"]"

detected XSS using libinjection. [file "/etc/apache2/conf.d/modsec/modsec_rules/12_asl_adv_xss_rules.conf"] [line "37"] [id "341256"] [rev "3"] [msg "Atomicorp.com WAF Rules: Possible Cross Site Scripting attack (detectXSS)"] [data "<p style=\x22font-size:20px; color: rgb(0,75,200)\x22>welcome\x0a</p>\x0a<p style=\x22font-size:14px; color: rgb(0,75,200)\x22>we're currently using moodle, the wonderful open source learning management system, to manage our volunteer training for  \x22 course\x22, \x22activity\x22 , and \x22quiz\x22 , elsewhere.  still, volunteers like yourself..."] [severity "CRITICAL"]


Again, thanks to Leon and Shiv for sending me in the right direction as well as to those from the earlier posts; sincerely appreciated!!!  And of course, much gratitude to all those that make Moodle possible, including everyone contributing to the forums; Moodle 4 looks great and we look forward to deploying it.

Jeff

As Ken puts it "In the Spirit of Sharing" smile

Average of ratings: Useful (1)
In reply to Jeff Lewis

Re: Default Dashboard - Can't Configure Text Block

by Jeff Lewis -
How to Whitelist a Rule using the ConfigServer ModSecurity Control plugin in WHM (the cPanel Website Host Manager app):

My VPS Host provided the following instructions, which turned out to be quite easy if you have access to the above plugin...

"Once you got the Rule ID (based on the apache error log or modsecurity log), you can go ahead and whitelist it as follows:

1) Find the account/domain for which you are facing the block
2) Mark it (by clicking on it), and click Modify user whitelists
3) Then in the ModSecurity rule ID list you can whitelist it for the whole account
4) If you want to specify the domain, mark the domain at the box below and click Modify Domain whitelists
5) Add the rule ID and click Save.

This will whitelist the Rule for the whole user or account depending on the option that you have used.

If you want to whitelist it globally (for example you are seeing that the Rule ID is the same for multiple accounts), you can Global whitelist it directly on the initial page (ModSecurity rule ID list)."