13th June 2026

Increase the security of a CMS using the filesystem immutability attribute

Protecting critical CMS files with the immutability attribute reduces the attack surface and limits unauthorized changes to the web filesystem.

Chattr-CMS-security

When discussing CMS security, the focus is almost always on updates, vulnerable plugins, passwords, application firewalls, and backups. These are fundamental aspects, but there's a lower, often overlooked level that can significantly contribute to mitigating attacks: the filesystem.

The discussion is generic and can be applied, with the necessary differences, to dynamic CMS such as Magento, PrestaShop, Drupal, Joomla and naturally WordpressIn this article, we'll focus on WordPress because of its widespread use and because, precisely because of this, it's one of the most frequent targets of automated exploits, bots, and massive compromise campaigns.

The starting point is simple: a dynamic site must be able to read many files, write to some, and traverse directories to function properly. But this doesn't mean the entire installation must always be modifiable. Not all files need to be writable, not all paths need to allow the same level of operation, and not all directories need to allow changes outside of maintenance periods.

When an exploit writes into WordPress

Many WordPress attacks don't just temporarily exploit a vulnerability. They often attempt to achieve persistence: they write new files, modify existing files, inject code into a theme, alter a plugin, or place a web shell in a web-accessible directory.

This happens because many installations are left, for convenience, in a too permissive state. WordPress needs to be able to update plugins and themes, upload images, generate cache, and sometimes modify files such as .htaccessFrom this legitimate need, however, a dangerous habit arises: treating the entire installation as if it were always writable.

If an exploit can execute code in the context of the website user or web process, it will try to exploit this very possibility.If it finds modifiable directories and overwritable files, it can install backdoors or alter legitimate components. However, if certain critical areas are protected and unmodifiable during normal operation, a significant part of the attack is made more difficult.

Not everything has to be writable

A clear example is the plugin directory. A WordPress site doesn't need that. wp-content/plugins be writable at all times. This must be the case when installing, updating, or removing a plugin. But between updates, especially on a professionally managed production site, those files can remain static.

The same reasoning can be applied to many core files, parts of the active theme, configuration files, and components that shouldn't change outside of scheduled maintenance. Conversely, directories like wp-content/uploads They have different needs: they must allow media to be loaded, but precisely because they are writable they should be treated with care and not become a convenient place to execute malicious code.

Security, therefore, should not be seen only as a distinction between “allowed” and “forbidden”, but as a more precise separation between what must be read, what must be written and what must remain intact.

This separation also concerns the concept of execution. On Linux, the execute bit on directories is also used to traverse them, so it shouldn't be interpreted superficially. However, from an application perspective, not every path containing files uploaded or generated by the CMS should be eligible for code execution. An upload area, for example, should be designed to store content, not to host PHP scripts ready to be called by the browser.

What does chattr +i do?

On Linux, in addition to the classic permissions managed with chmod e chown, there are filesystem attributes that can be managed via chattrAmong these, the most interesting attribute from a hardening perspective is +i, that is, the attribute of immutability.

When a file is marked as immutable, it cannot be modified, deleted, renamed, or opened for writing until the attribute is removed by an authorized party. This is therefore not equivalent to simply removing write permission with chmod: is a stronger constraint, applied at the filesystem level.

In essential form, the commands are these:

chattr +i file-o-directory
chattr -i file-o-directory
lsattr file-o-directory

chattr +i apply immutability, chattr -i removes it, while lsattr It allows you to check the existing attributes. Of course, these commands shouldn't be applied indiscriminately across the entire installation. A CMS must continue to write where it needs to: cache, upload, logs, and other dynamic paths can't be blocked without careful evaluation.

Why is it used so little?

Although it is a powerful tool, chattr +i It's rarely used in traditional web hosting (let's just say never), so do a few Google searches to see that we're the only ones talking about it. The first reason is cultural: many CMS security guides limit themselves to standard permissions, security plugins, or web server rules. Filesystem immutability is a topic closer to Linux system architecture than to standard WordPress management.

file-attributes

The second reason is operational. If you make a file that needs updating immutable, the update will fail. If you lock the wrong directory, the CMS may no longer be able to generate cache, upload files, or complete maintenance. This technique therefore requires a method, documentation, and clear procedures.

The third reason concerns control panels. Plesk, cPanel, and DirectAdmin simplify the management of domains, files, databases, mail, and certificates, but they haven't made filesystem immutability a standard application hardening model for CMSs. Some document the immutable attribute or explain how to remove it when it causes problems, but they don't typically offer it as a standard workflow for surgically securing a WordPress installation.

The reason is understandable: a generic control panel must work in a wide range of scenarios, often with non-systems users. Automating immutability without knowing the site could lead to disruptions. This is precisely where professionally managed hosting can offer added value.

The correct approach: surgical, not indiscriminate

Immutability shouldn't be used as a lock that can be applied everywhere. The site shouldn't be completely frozen. Instead, paths should be distinguished based on their function.

Critical configuration files may require additional protection. Core files can be treated as static between updates. Plugins can be made unmodifiable until the next maintenance. Upload directories should remain writable, but should not allow code execution. Cache directories should be regenerable, but without granting excessive freedom to sensitive areas.

A purely conceptual example, not a universal procedure, might be:

# Protezione di un percorso critico fuori manutenzione
chattr +i percorso/critico

# Sblocco controllato prima di un aggiornamento
chattr -i percorso/critico

# Verifica dello stato degli attributi
lsattr percorso/critico

The important part is not the single command, but the process: analyzing the site's behavior, identifying what needs to change, and protecting what shouldn't be changed during normal operation.

An extra layer of security for managed hosting

In standard hosting, the provider offers web space, a database, a control panel, and generic tools. The user installs the CMS, updates plugins, and manages the site. In this model, it's difficult to apply truly targeted hardening because the provider doesn't necessarily know the specific behavior of the project.

Hosting managed by professional system administrators, however, can take a different approach. After initial tuning, it's possible to identify which paths should be writable, which should be readable only, and which can be protected with more restrictive attributes. This reduces the attack surface and makes it more difficult for malware to modify critical components.

The value is not just in performing chattr +i, but in knowing where to apply it, when to remove it, and how to reintegrate it into update processes. Immutability must coexist with maintenance: first unlock, then update, verify the site, and finally restore protection.

Limits not to be ignored

The immutable attribute isn't a silver bullet. It doesn't replace updates, backups, user isolation, malware scanning, monitoring, WAFs, or good access policies. Furthermore, if an attacker gains elevated privileges on the server, they may be able to remove the attribute, depending on the context and available capabilities.

However, it remains a very interesting measure against a common category of attacks: those that, after exploiting a vulnerability in the CMS or a plugin, attempt to write or modify files within the web installation. In these cases, reducing the writable nature of critical paths can make a tangible difference.

Conclusion

Increasing the security of a CMS also means stopping thinking of the filesystem as a single container. Each file and directory has a different function. Some paths should be dynamic, others should remain stable, and still others should only be modifiable during controlled maintenance.

In the case of WordPress, but also Magento, PrestaShop, Drupal, and Joomla, the filesystem immutability attribute can represent an additional layer of defense. It doesn't eliminate the need to update, monitor, and secure the application, but it does reduce the wiggle room for many attacks that aim to write backdoors or alter existing files.

chattr +i It's rarely used because it requires system expertise and because general-purpose control panels don't typically integrate it as an application security model. Precisely for this reason, it can become a distinctive feature in professionally managed hosting: initial tuning, path mapping, and a precise separation between reading, writing, and execution can transform a standard CMS installation into a more robust, more controlled environment that's less vulnerable to automated attacks.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.

0256569681

Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

DISCLAIMER, Legal Notes and Copyright. RedHat, Inc. holds the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of the AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. holds the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds holds the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt; Oracle Corporation holds the rights to Oracle®, MySQL®, MyRocks®, VirtualBox®, and ZFS®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; PostgreSQL® is a registered trademark of PostgreSQL Global Development Group; SQLite® is a registered trademark of Hipp, Wyrick & Company, Inc.; KeyDB® is a registered trademark of EQ Alpha Technology Ltd.; Typesense® is a registered trademark of Typesense Inc.; REDIS® is a registered trademark of Redis Labs Ltd; F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB; HAProxy® is a registered trademark of HAProxy Technologies LLC; Traefik® is a registered trademark of Traefik Labs; Envoy® is a registered trademark of CNCF; Adobe Inc. owns the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited; Automattic Inc. holds the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert owns the rights to Drupal®; Shopify® is a registered trademark of Shopify Inc.; BigCommerce® is a registered trademark of BigCommerce Pty. Ltd.; TYPO3® is a registered trademark of the TYPO3 Association; Ghost® is a registered trademark of the Ghost Foundation; Amazon Web Services, Inc. owns the rights to AWS® and Amazon SES®; Google LLC owns the rights to Google Cloud™, Chrome™, and Google Kubernetes Engine™; Alibaba Cloud® is a registered trademark of Alibaba Group Holding Limited; DigitalOcean® is a registered trademark of DigitalOcean, LLC; Linode® is a registered trademark of Linode, LLC; Vultr® is a registered trademark of The Constant Company, LLC; Akamai® is a registered trademark of Akamai Technologies, Inc.; Fastly® is a registered trademark of Fastly, Inc.; Let's Encrypt® is a registered trademark of the Internet Security Research Group; Microsoft Corporation owns the rights to Microsoft®, Azure®, Windows®, Office®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®; Apache® is a registered trademark of The Apache Software Foundation; Apache Tomcat® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group; Docker® is a registered trademark of Docker, Inc.; Kubernetes® is a registered trademark of The Linux Foundation; OpenShift® is a registered trademark of Red Hat, Inc.; Podman® is a registered trademark of Red Hat, Inc.; Proxmox® is a registered trademark of Proxmox Server Solutions GmbH; VMware® is a registered trademark of Broadcom Inc.; CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV; Grafana® is a registered trademark of Grafana Labs; Prometheus® is a registered trademark of The Linux Foundation; Zabbix® is a registered trademark of Zabbix LLC; Datadog® is a registered trademark of Datadog, Inc.; Ceph® is a registered trademark of Red Hat, Inc.; MinIO® is a registered trademark of MinIO, Inc.; Mailgun® is a registered trademark of Mailgun Technologies, Inc.; SendGrid® is a registered trademark of Twilio Inc.; Postmark® is a registered trademark of ActiveCampaign, LLC; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Hetzner® is a registered trademark of Hetzner Online GmbH; OVHcloud® is a registered trademark of OVH Groupe SAS; Terraform® is a registered trademark of HashiCorp, Inc.; Ansible® is a registered trademark of Red Hat, Inc.; cURL® is a registered trademark of Daniel Stenberg; Facebook®, Inc. owns the rights to Facebook®, Messenger® and Instagram®. This site is not affiliated with, sponsored by, or otherwise associated with any of the above-mentioned entities and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. All other trademarks mentioned are the property of their respective registrants. MANAGED SERVER® is a European registered trademark of MANAGED SERVER SRL, with registered office in Via Flavio Gioia, 6, 62012 Civitanova Marche (MC), Italy and operational headquarters in Via Enzo Ferrari, 9, 62012 Civitanova Marche (MC), Italy.

JUST A MOMENT !

Have you ever wondered if your hosting sucks?

Find out now if your hosting provider is hurting you with a slow website worthy of 1990! Instant results.

Close the CTA
Back to top