☰
WEB SECURITY / PRACTICE

WordPress Site Isolation on Shared Hosting: Practical Protection Against Compromise

WordPress Site Isolation on Shared Hosting: Practical Protection Against Compromise

When several WordPress sites are hosted on the same server, a compromise of one site should not automatically give an attacker access to the files, configuration or databases of the others. This is why isolation matters: each site should run in its own restricted environment, and neighboring projects should not be accessible for reading or writing.

On shared hosting, some settings are controlled by the provider, but site owners can still check the account structure, file permissions, database access, FTP users and backup behavior. Below is a practical checklist to help identify dangerous shared resources and formulate a precise request to the hosting provider.

What Site Isolation Provides

A typical attack scenario looks like this: an attacker finds a vulnerable plugin or theme on one WordPress site, uploads a malicious PHP file and attempts to read nearby configuration files. If all sites belong to the same system user or are stored in a shared directory with excessive permissions, compromising one project can lead to the compromise of all of them.

Isolation does not make a site invulnerable. It reduces the blast radius: an attacker gains access only to the environment in which the compromised site runs. This simplifies incident containment, reduces the number of damaged files and helps prevent configuration leaks from neighboring projects.

  • A separate system user, container or PHP-FPM pool for each site;
  • No access for one site to another site's directories and files;
  • A separate database or database user with minimum required privileges;
  • Different FTP or SFTP accounts without shared passwords;
  • Server-level restrictions on PHP access to other directories.

A Separate System User or PHP-FPM Pool

The most reliable basic setup is to run each site under a separate system user. In this arrangement, the PHP process for one project should not be able to read or modify another project's files. On servers using PHP-FPM, a separate pool with its own user and group can provide a similar boundary.

On a full VPS, an administrator can create the user, assign file ownership and configure a separate pool. On shared hosting, these actions are often unavailable: the provider may already use CageFS or another isolation mechanism, or all sites under one account may run in a shared environment.

Do not assume that a separate domain is sufficient protection. Two domains may have different URLs while remaining accessible to the same system user. Check the hosting control panel to see whether you can create a separate hosting account, user or SFTP account tied to a specific directory.

  • Ask support which system user runs the PHP processes for each site.
  • Clarify whether separate hosting accounts are isolated from one another, rather than only separate by domain.
  • For a VPS, verify that each PHP-FPM pool has its own user and group and does not use one shared user for all sites.
  • Never run PHP or the web server as root.

File and Directory Permissions

Filesystem permissions should allow the web server to perform necessary operations without making all files accessible to every user. Directories with 777 permissions are especially dangerous: any process or user that gains access to the server can modify their contents.

Safe values depend on the ownership and group model used by the particular host. As a guideline, permissions of 750 for directories and 640 for files are often used, but they must not be applied mechanically to every object. If PHP runs under a different user or group, permissions that are too restrictive may break updates, media uploads or caching.

The key requirement is that files belong to the correct user, while neighboring users have no read or write access. Also check configuration files, backups, logs and temporary archives, which often contain passwords and keys.

  • Do not use 777 for the site root, wp-content or uploads.
  • Do not store backups in an open web directory if they can be accessed by URL.
  • Check that .zip archives, copies of wp-config.php or old .sql dumps are not left nearby.
  • Site directories should be separated rather than placed inside one shared directory with broad permissions.
  • After changing permissions, test WordPress updates, media uploads and the operation of required plugins.
Приклад орієнтовних прав для окремого сайту на VPS:

find /var/www/site -type d -exec chmod 750 {} \\;
find /var/www/site -type f -exec chmod 640 {} \\;

Це лише приклад. Перед виконанням визначте правильного власника, групу та користувача PHP-FPM. На shared hosting такі команди можуть бути недоступними або недоречними.

Separate WordPress Databases and Access Credentials

File isolation does not protect data if all sites use one database with one administrator account. Ideally, create a separate database and database user for each WordPress site. That user should receive only the privileges required by that particular site.

A separate table prefix is an additional measure, but it is not a substitute for isolation. A unique prefix makes mass attacks against tables more difficult and helps distinguish sites in a shared database, but a user with full access to that database can still read every table. A shared database with different prefixes is therefore weaker than separate databases and users.

Database connection details are stored in wp-config.php. This file must not be accessible through a browser, and its copies should not be left in archives, public backup directories or version-control systems.

  • Create a separate database and account for each site.
  • Use different long passwords for databases and never reuse them between projects.
  • Verify that each WordPress configuration points to the correct database.
  • Use a unique table prefix during installation or migration.
  • Restrict external database access if remote connections are not required for the site.

Restricting PHP Access to Other Directories

Even separate users are not always sufficient if the server configuration allows PHP to bypass directory boundaries. Ask the hosting provider to check open_basedir, CageFS, containerization or another mechanism that restricts the site's process to its own filesystem space.

open_basedir can prevent PHP from accessing directories outside an allowed list, but it is not a complete replacement for proper Unix permissions, separate users and containers. Its configuration can sometimes conflict with libraries, caches or system directories, so changes should be tested on a copy or during a controlled maintenance window.

Containerization and hosting-account isolation generally create a stronger boundary than simply separating folders. However, no technology eliminates the risks posed by vulnerable core software, plugins, themes or stolen credentials.

  • Ask the provider in writing whether PHP for one site can see the directories of other sites.
  • Clarify whether processes, temporary directories, cron jobs and logs are isolated.
  • Do not rely only on hiding the directory path or using a nonstandard folder name.
  • Check isolation again after a site migration, plan change or account consolidation.

FTP, SFTP, Backups and Common Mistakes

A shared FTP account with access to all sites undermines much of the isolation. If its password is stolen, an attacker can modify every accessible directory. Create a separate SFTP or FTP account for each project, restrict it to the site's root directory and remove unused accounts.

Backups must also be separated. If all archives are stored in one accessible directory, a compromise of one site may expose the configurations and databases of all the others. Store backups outside the web root and, where possible, on separate storage with restricted access.

The most common mistakes are using one user for multiple sites, 777 permissions, one database account with excessive privileges, reused passwords, old test copies and access to the hosting panel through unsecured FTP.

  • Use SFTP instead of standard FTP if the provider supports it.
  • Restrict each file-transfer account to a specific site.
  • Enable two-factor authentication for the hosting panel and administrator email.
  • Keep at least one backup separately from the server.
  • Regularly verify that the site can be restored from a backup.

Shared Hosting Isolation Verification Checklist

If you do not have root access, do not try to change server parameters blindly. Gather the facts and send the hosting provider a specific list of questions. A reliable provider should explain exactly how sites are separated and what boundaries apply to PHP and the filesystem.

After the review, record the results for each domain: directory, system user, PHP mode, database, file-transfer accounts and backup location. This will make audits easier after a migration or configuration change.

  • Does each site run under a separate system user or PHP-FPM pool?
  • Can PHP for one site read or write to another site's directory?
  • Does each WordPress site have a separate database and database user?
  • Are 777 permissions and shared FTP accounts with access to all sites absent?
  • Is PHP restricted by open_basedir, CageFS, a container or another mechanism?
  • Are backups stored outside public directories?
  • After the audit, have updates, login logs, active users and unknown PHP files been checked?

Frequently asked questions

Is creating a separate folder for each site enough?

No. Separate folders without different system users, correct permissions and PHP restrictions do not guarantee isolation. The important point is that one site's process must not be able to read or modify another site's files.

Can one database be used for several WordPress sites?

Technically, yes, if the sites use different table prefixes, but this is a weaker arrangement. It is better to create a separate database and database user for each project so that compromising one set of credentials does not expose all data.

Does open_basedir protect against all attacks between sites?

No. It is an additional PHP access restriction, not a complete replacement for system permissions, separate users or containerization. It should be combined with updates, least-privilege access and access control.

What should I do if shared hosting does not support isolation?

Ask about separate hosting accounts, CageFS, containerization or another plan with stronger separation. If the sites are critical, consider placing them on different accounts, servers or a properly configured VPS.

Does isolation replace updates and backups?

No. It only reduces the potential scale of an incident. WordPress, plugins, themes and server software must be updated, while backups should be created regularly and restoration should be tested.

Conclusion

A secure setup for several sites on one server starts with separating their environments: a separate user or PHP-FPM pool, restricted filesystem permissions, an individual database and separate file-transfer accounts. Shared directories with 777 permissions, universal FTP passwords and one database for all projects create unnecessary risk.

Check these settings yourself or ask the hosting provider for technical confirmation of the isolation measures. Add regular updates, monitoring and working backups so that a compromise of one WordPress site does not become a problem for the entire server.

← All web security materials