Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 37 ยท Development and Security

Security Hardening and Updates

Harden a Joomla site: update strategy, backups you can restore, file permissions, HTTPS and security headers, admin protection, logging and an audit checklist.

Every public website is scanned by automated tools within hours of going online. Those tools do not care how small or unimportant your site is; they look for known holes in old versions of popular software. Joomla is secure when it is maintained, and vulnerable when it is not. Security is mostly routine: update quickly, keep tested backups, give out the minimum rights, and remove what you do not use.

Joomla cannot run on this site, so this lesson is a precise checklist with menu paths and commands. Two JavaScript stand-ins check a configuration and file permissions the way an audit would. They teach the rules; they do not scan a real site.

1. Updates

Most successful attacks use a vulnerability that already has a fix.

  • Joomla core: when System > Update > Joomla shows a new release, plan to install it promptly, especially if it is labeled a security release. Read the release notes for your major version.
  • Extensions and templates: check System > Update > Extensions regularly. An outdated extension is the most common way in.
  • PHP and the database: use a PHP version that still receives security support, and ask your host if you are unsure. Joomla's release notes name the minimum and supported versions.
  • Remove what you do not use. A disabled but installed extension can still be exploitable if its files are reachable. Uninstall it.
  • Subscribe to the Joomla Security Centre announcements (and the vendors' of your extensions) so you hear about problems early.

A safe update routine:

flowchart LR
    A["Back up files and database"] --> B["Update a staging copy"]
    B --> C["Test key pages and forms"]
    C --> D["Update production"]
    D --> E["Check the error log and Update screen"]

Back up, stage, test, deploy, check.

Recent Joomla 5 releases add a more secure update mechanism (based on The Update Framework) and, in newer versions, an optional automated updates feature for core. Check System > Update > Joomla > Options in your version, decide consciously whether you want automatic updates, and keep notifications and backups either way.

2. Backups you can restore

A backup that has never been restored is a hope, not a backup.

  • Back up both: all files (including configuration.php, images, extensions) and the database.
  • Follow the 3-2-1 idea: three copies, on two kinds of storage, one off the server. A copy only on the same server disappears with the server.
  • Use a trusted tool (the free Akeeba Backup extension is widely used) or your host's snapshots, and schedule it, for instance daily with a retention of a few weeks.
  • Test a restore on another host or locally at least a couple of times a year. Time how long it takes.
  • Do before every update as an extra copy.

3. Accounts and the administrator

  • Use a unique, long password per person and a password manager; enable multi-factor authentication for all staff (see Registration, Login and Privacy).
  • Do not use admin as a username; give each person their own login, never share one.
  • Keep Super User accounts to a minimum, and review the user list for forgotten accounts.
  • Review System > User Actions Log from time to time; it shows who changed what and when.
  • Optionally restrict /administrator by IP address at the web server, or put it behind a second layer. This is an extra, not a replacement for the rest.

4. Transport and headers

  • Serve everything over HTTPS, then enable Force HTTPS in Global Configuration.
  • Enable the System - HTTP Headers plugin and review its options. It can send headers such as Strict-Transport-Security (HSTS), X-Content-Type-Options: nosniff, Referrer-Policy, X-Frame-Options and a Content Security Policy. Add them gradually: a strict CSP can block your own inline scripts, so test.
  • Make sure cookies are Secure and HttpOnly (Joomla sets sensible defaults on HTTPS).

5. Files and configuration

  • File permissions: directories 755, files 644, and configuration.php as strict as the host allows (444 or 640). Never 777. The files should be owned by the user running the site, not by the web server user where possible.
  • Delete installation/ if it is still there (modern releases remove it during setup), and delete backup archives, phpinfo.php files, .sql dumps and test scripts from the web root. Visitors can download anything stored there.
  • In System > Global Configuration: set Error Reporting to None or Default and keep Debug System Off on production; error messages leak paths.
  • Use a database user with only the rights Joomla needs for its own database, never the root account.
  • Keep the log and tmp paths outside the web root if your host allows it.
  • Block execution in upload folders (images, media) with a server rule, so an uploaded script cannot run. Restrict allowed upload types in Media options and keep the list short.

6. Everyday habits for developers

The code lessons (Component Structure and MVC, The Database API and Input Filtering) apply here: filter input, bind parameters, escape output, check tokens and permissions. Add:

  • Never print stack traces to visitors; log them.
  • Avoid storing secrets in Git; put them outside the repository.
  • Treat any extension you install as code that runs with full access, and vet it (see Choosing and Vetting Extensions).
  • Keep development, staging and production separate, with different passwords.

7. Detecting and recovering

  • Watch your error log, web server log and the User Actions Log. Sudden new admin users, new PHP files in images, or changed index.php files are warning signs.
  • Use a monitoring service for uptime and for changes in your files if available.
  • If you suspect a hack: take the site offline, preserve a copy for analysis, restore from a clean backup and then update everything, change all passwords (Joomla users, database, FTP/SSH, hosting panel) and find out how the attacker entered; otherwise they return.

A configuration audit

JS Audit a Joomla configuration

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The version numbers are made up for the demo. In real life read them from your Update screen.

A file-permission check

JS Check file modes

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Modes are written in octal. The demo flags world-writable files (the last digit includes the write bit), and backup archives left in the web root.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which is the most common way a Joomla site gets hacked?

    Outdated, vulnerable extensions are the usual entry point.
  2. 2. What makes a backup trustworthy?

    Complete, off-site and tested backups are the ones that save you.
  3. 3. Which file permission is risky for a PHP file?

    777 lets anyone on the server write the file.
  4. 4. Why set Debug System to Off in production?

    Debug output reveals paths, queries and versions to attackers and adds overhead.
  5. 5. After a hack and restore, what else must you do?

    Without fixing the cause and credentials the attacker simply returns.

Summary

  • Update Joomla, extensions, PHP and the database promptly; remove unused code.
  • Keep complete, off-site, restore-tested backups, and take one before every update.
  • Use unique passwords and MFA, minimal Super Users and the action log.
  • Force HTTPS, enable security headers, set sane file permissions and clean the web root.
  • Know how to detect a compromise and recover properly.

Next: Project: A Small Business Website