Join our Newsletter — 33% off our NHI Course
Home› Guides› Moodle Security Hardening Guide: Site Admin, Plugins, Files…
Guide Application Security

Moodle Security Hardening Guide: Site Admin, Plugins, Files and Server Settings

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 19 November 2026 14 min read
On this page

Hardening a self hosted Moodle site comes down to four things: keeping the code current, locking down administrator and privileged accounts, controlling plugins, and getting file permissions and server settings right. Moodle is an open source learning management system that many organisations run on their own servers. A self hosted site puts the operator in charge of the whole stack: the web server, PHP, the database, the Moodle code, the data directory and every installed plugin. This guide covers platform security for that stack, drawing on the settings and checks named in Moodle's administrator documentation.

The audience is system administrators, platform teams and security reviewers responsible for Moodle servers. It focuses on the platform, not on teaching practice or course design. For the wider sector picture, see the Cybersecurity for Higher Education Guide.

This is an independent guide from NHI Mgmt Group, based on Moodle's public documentation as of November 2026. It is not sponsored or reviewed by Moodle. Product features change, so confirm settings against Moodle's current documentation for your version.

Key takeaways

  • Apply each Moodle release promptly and keep the operating system, PHP, web server and database patched. Moodle's documentation notes that older versions tend to have more known vulnerabilities.
  • Run the built in security checks report (Site administration > Reports > Security checks) on a schedule and act on every warning.
  • Serve every page over HTTPS, not only the login page, and enable secure cookies.
  • Keep the Moodle code directory read only to the web server and keep config.php unwritable; the data directory should not be reachable from the web.
  • Consider setting $CFG->disableupdateautodeploy = true; so plugins cannot be installed or updated through the web interface, and manage plugins through a reviewed deployment process.
  • Keep administrator accounts few, review them regularly, and limit who can back up user data.
  • Treat database credentials, the password salt and integration tokens in config.php as secrets.

The Moodle attack surface

A Moodle site is a PHP web application with a large number of features and an extension model that lets administrators add activity modules, blocks, themes and authentication plugins. From a security point of view that creates several exposure points:

  • The public web application: login pages, profile pages and any content open to the web. Exploiting a public facing application is a well documented initial access route, catalogued as MITRE ATT&CK T1190.
  • Privileged web accounts: site administrators can change configuration, install plugins (unless disabled) and reach sensitive reports. A stolen admin session or password is a full compromise of the application.
  • Plugins: third party code running with the same privileges as Moodle itself.
  • The server and its secrets: config.php holds database credentials, the data directory holds uploaded files and sessions, and the database holds everything else.
  • Integrations: web service tokens, LTI connections and single sign on links that let other systems act on the site. These are non-human identities and need owners and rotation like any other.

The sections below take each surface in turn.

Patching and staying informed

Moodle's security recommendations put updates first. The documentation advises applying each Moodle release, keeping PHP, the web server and Moodle current, and turning on automatic update mechanisms for the operating system. It also recommends registering the site with Moodle.org to receive security alerts, which are published at moodle.org/security, and subscribing to PHP and database announcement lists and to CISA cybersecurity advisories.

NHI Mgmt Group recommends turning that into a written process:

  • Name an owner for Moodle security announcements and a deputy.
  • Set a target time to apply security releases after they are announced, and track it.
  • Keep a staging copy of the site where upgrades and plugin updates are tested before production.
  • Record the Moodle version, PHP version and every plugin version so you can tell quickly whether an announcement applies.

Check that your Moodle branch is still receiving security fixes. Running an unsupported branch means new vulnerabilities will not be fixed at all.

The security checks report

Moodle includes a report that reviews common security settings. In the 4.5 documentation it is found at Site administration > Reports > Security checks. The documentation describes checks including the following:

CheckWhat to aim for
Insecure datarootThe data directory is not reachable from the web
Displaying of PHP errorsPHP errors are not shown to visitors
Vendor directoryNot present on public sites
No authenticationThe "No authentication" plugin is not in use
Allow EMBED and OBJECTNot allowed for ordinary users
Executable paths$CFG->preventexecpath = true in config.php so executable paths cannot be set from the admin interface
Open user profilesProfiles not open to the web without login
Open to GoogleOff unless the site is meant to be public
Password policyEnabled
Password saltSet
Email change confirmationRequired
Secure cookiesEnabled when the site uses HTTPS
Writable config.phpconfig.php not writable by the web server
XSS trusted usersOnly trusted users hold this permission
AdministratorsOnly the admin accounts that are needed
Backup of user dataLimited to trusted roles
Default role, guest role and frontpage roleReasonable permissions only

The aims in the right hand column summarise the check descriptions; confirm the exact wording for your version, as check names can change between releases. Run the report after every upgrade and plugin change, and treat a new warning as a change that needs an explanation.

HTTPS, sessions and login settings

The documentation recommends serving every page over HTTPS, not just the login page, and notes that free certificates are available from Let's Encrypt. Once the whole site is on HTTPS, enable secure cookies so session cookies are not sent over plain HTTP; the security checks report flags this.

Password policy

Moodle's password policy is configured under Site administration > Security > Site policies. The documentation lists options for enforcing complexity, minimum length and minimum counts of digits, lower case, upper case and non alphanumeric characters. It recommends strong passwords for administrator and teacher accounts and requiring users to change their initial password, and it warns that overly strict rules lead people to write passwords down. Keep rules realistic and favour length.

Stronger authentication for administrators

A password alone is weak protection for an administrator account. NHI Mgmt Group recommends putting administrator logins behind multi-factor authentication, either through your identity provider via single sign on or through the multi-factor options available in your Moodle version. Confirm in your version's documentation which options exist and how they apply to the administrator role. See the Education Identity Security Guide for identity patterns across education platforms.

Site exposure settings

The documentation recommends disabling guest access and keeping the opentowebcrawlers setting disabled under Site policies unless the site is meant to be public. The security checks report also flags open user profiles. Every page that does not require login is attack surface, so keep public content to what is intended.

Administrator accounts and role permissions

Privilege in Moodle is set through roles and capabilities. The security checks report points to several of the most sensitive: administrators, XSS trusted users, backup of user data, and the default, guest and frontpage roles. A practical review covers:

  • Site administrators: keep the list short, use named personal accounts rather than a shared "admin" login, and remove access when people change role.
  • XSS trusted users: users holding this permission can add content that is not cleaned for scripts. Limit it to people who genuinely need it.
  • Backup of user data: backups that include user data are a copy of personal data that can leave the site. Limit the capability to trusted roles.
  • Default, guest and frontpage roles: these apply broadly, so a permission added here reaches every user or every visitor.
  • Teacher accounts: the documentation advises giving these only to trusted people and not offering free teacher accounts in public sandboxes on production servers.

The documentation also advises keeping the enrolment key hint disabled under Site administration > Plugins > Enrolment > Self enrolment, where it is disabled by default, and using enrolment keys on self enrolment courses or making courses not enrollable.

Review administrator and high privilege roles at least quarterly, and log who approved each grant. Valid accounts used by an attacker are hard to tell apart from normal use, which is why the review matters (MITRE ATT&CK T1078).

Plugin governance

Plugins are the main way to extend Moodle and a common source of risk, because each one is code running inside the application. Moodle's documentation describes three ways to install a plugin: from the Moodle plugins directory through Site administration > Plugins > Install plugins, by uploading a ZIP on the same page, or by copying files to the right folder on the server and then visiting Site administration > Notifications.

Disable web based installs

Adding $CFG->disableupdateautodeploy = true; to config.php blocks new installs, updates and missing dependency fixes made through the web interface. Installs through the directory or by ZIP upload need the web server to have write access to the plugin type folders, which conflicts with keeping the code read only. With web installs disabled, plugins arrive through your own deployment process, where they can be reviewed and tested first. This also means a stolen administrator session cannot be used to upload code.

Choose and maintain plugins carefully

The documentation advises testing plugins on a non production server first, considering whether a plugin is really needed (since extra features add maintenance and upgrade risk), checking whether it is supported, maintained and likely to work with future Moodle versions, and being cautious with patches that modify core files. After installing, check the plugin validation report.

NHI Mgmt Group adds:

  • Keep a plugin register with owner, purpose, version, source and the date it was last reviewed.
  • Use the "Check for available updates" button on Site administration > Plugins > Plugins overview, and include plugin updates in the patch process.
  • Remove plugins that are no longer used. The documentation explains that uninstalling takes two steps: click Uninstall in Plugins overview, then delete the plugin directory, otherwise Moodle will reinstall it.
  • Treat abandoned plugins as a risk to plan around, not a reason to skip upgrades.

File permissions, the data directory and config.php

Moodle separates its code directory from its data directory (moodledata). The documentation gives permission guidance for Linux and Unix servers.

Dedicated servers

  • moodledata and its contents, including sessions: owned by the web server user and group, with mode 700 for directories and 600 for files.
  • The Moodle code directory, including config.php: owned by root, with mode 755 for directories and 644 for files. If local user logins are allowed on the server, the documentation suggests the web server group with 750 and 640.

Shared hosting

The documentation explains that the dedicated settings may lock out the web server on shared hosting and lists fallbacks for moodledata, ending with 777 and 666 as the least secure option. The web server needs read access to code files and read and execute access to code directories, but not write access. With read only code, config.php must be created manually during installation. If your hosting only works with world writable permissions, that is a signal to move to a different hosting arrangement.

Keep the data directory off the web

The security checks report includes an "Insecure dataroot" check, which flags a data directory that can be reached from the web. Place moodledata outside the web server's document root so uploaded files and session data cannot be requested directly.

Protect config.php

config.php holds the database connection details and other site secrets, and the report flags it if it is writable. Keep it readable only by the accounts that need it, keep it out of version control in plain text, and rotate the database password if the file is ever exposed. Set $CFG->preventexecpath = true so executable paths cannot be changed from the admin interface. Credentials sitting in configuration files are a classic target (MITRE ATT&CK T1552).

Server, database and network hardening

The documentation's server advice includes setting a password for the database root user, turning off database network access where the database runs on the same host, disabling unused services, separating services onto different machines and using different passwords across systems so one compromise does not spread. It suggests reviewing open ports and restricting remote administration to SSH or RDP.

NHI Mgmt Group recommends a few additions for a modern deployment:

  • Give Moodle its own database account with rights only on the Moodle database, not a root or administrative account.
  • Restrict SSH to named administrators using keys, from management networks only.
  • Keep PHP error display off in production, which the security checks report also tests.
  • Remove development artefacts such as the vendor directory from public sites, as the report recommends.
  • Send web server, PHP and Moodle logs to central logging and alert on administrator logins, role changes and plugin changes.
  • Watch for unexpected PHP files in web accessible directories. See How to Hunt for Web Shells on IIS, Apache and Nginx.

Backups, recovery and integration secrets

The documentation advises keeping backups, testing restores, practising recovery procedures in advance and running a rootkit detector regularly. Backups contain the database and moodledata, so they hold everything an attacker would want. Encrypt them, store at least one copy separately from the server, and restrict who can retrieve them.

Integrations deserve the same care. Web service tokens, LTI shared secrets and single sign on configuration let other systems act on the Moodle site without a person logging in. NHI Mgmt Group recommends keeping an inventory of each integration with its owner, the account or role it uses, and when its secret was last rotated, and removing tokens for integrations that are no longer in use.

Common failure patterns

  • Delayed upgrades: sites left on old releases or unsupported branches because upgrades are seen as risky.
  • Web writable code: code directories left writable so that web based plugin installs work, which also lets an attacker with admin access drop code.
  • Data directory under the web root: moodledata reachable over HTTP, flagged by the Insecure dataroot check.
  • Shared admin login: one "admin" account used by several people, with no way to tell who did what.
  • Plugin sprawl: plugins installed for a one off need and never removed or updated.
  • HTTPS on login only: mixed HTTP and HTTPS, with secure cookies off.
  • Ignored security report: warnings accepted as normal instead of being fixed or documented.
  • Untracked integration tokens: web service tokens with no owner, left active after the connected system is retired.

Practitioner checklist

  • Register the site for Moodle security alerts and assign an owner for announcements.
  • Apply Moodle security releases within a set target time, after testing on staging.
  • Run Site administration > Reports > Security checks after every change and clear or document every warning.
  • Serve the whole site over HTTPS and enable secure cookies.
  • Set a realistic password policy and put administrator logins behind multi-factor authentication.
  • Keep the administrator list short, named and reviewed quarterly; limit XSS trusted users and user data backups.
  • Set $CFG->disableupdateautodeploy = true; and deploy plugins through a reviewed process.
  • Keep a plugin register and remove unused plugins fully.
  • Apply the documented file permissions, keep moodledata outside the document root and config.php unwritable.
  • Set $CFG->preventexecpath = true.
  • Use a dedicated least privilege database account and close database network access where possible.
  • Encrypt and test backups, and inventory every integration token and secret.

Standards and references

Related NHI Mgmt Group resources: Cybersecurity for Higher Education Guide · Education Identity Security Guide · How to Hunt for Web Shells on IIS, Apache and Nginx

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.