File permissions are the first line of defense on a WordPress server; they decide which user accounts can read, modify, or execute each file. Getting the numbers right stops a compromised script from overwriting core files and keeps sensitive configuration out of public view.
What are WordPress file permissions and how do they work?
Permissions are expressed as a three-digit octal code. Each digit represents a set of rights for a specific class of users:
- Owner - the user that created the file (usually the account that runs PHP).
- Group - users that share a Unix group with the owner.
- Others - everyone else on the system.
The digit is the sum of read (4), write (2) and execute (1). For example, 644 means:
- Owner: read + write = 6
- Group: read = 4
- Others: read = 4
When a directory has the execute bit set, users can enter the folder; without it they can see the listing but not traverse it. This simple model lets you lock down files while still allowing WordPress to serve pages and write where it legitimately needs to.
Which permission values are considered safe for a typical WordPress installation?
The community-tested baseline is:
- Directories:
755- owner can read/write/execute, group and others can read and enter. - Files:
644- owner can read/write, everyone else can only read. - wp-config.php:
640or600- the file contains database credentials, so it should be readable only by the owner (and optionally the group).
These values work on most shared-hosting setups where the web server runs under the same user that owns the files. If your server uses a different user for PHP, you may need to adjust the group permissions accordingly, but never go above the numbers listed above.
How does a concrete permission mistake lead to a compromise?
Imagine a site where the wp-content/uploads folder is set to 777, and the server also runs PHP files placed there. Any process on the server can now write into that folder, including another compromised site on the same shared server, and an attacker who drops a PHP shell there can run it by requesting its address. The shell can then edit index.php or even wp-config.php, replacing them with malicious code that runs on every request. The damage spreads quickly because the attacker now controls files that were previously protected by stricter permissions.
Step-by-step: How to check and fix WordPress file permissions
- Connect to the server - use SSH, a control-panel file manager, or an FTP/SFTP client.
- Navigate to the WordPress root - this is the folder containing
wp-config.php. - List current permissions - in a shell run
find . -type d -exec stat -c "%a %n" {} \;for directories andfind . -type f -exec stat -c "%a %n" {} \;for files. In a GUI client the permissions column shows the same numbers. - Set directory permissions - run
find . -type d -exec chmod 755 {} \;. - Set file permissions - run
find . -type f -exec chmod 644 {} \;. - Lock down wp-config.php - run
chmod 640 wp-config.php(orchmod 600 wp-config.phpif the web server does not need group access). - Verify the uploads folder - ensure it is
755and that PHP files in it can't run. On Apache, a.htaccessfile in the uploads folder with a<FilesMatch "\.php$">block containingRequire all denieddoes this; on Nginx, add a location rule that denies.phpunder uploads. - Re-run a scanner - after fixing permissions, run a security scanner and work through the WordPress security checklist to confirm no other issues remain.
Common mistakes people make when adjusting permissions
- Using 777 to “fix” upload errors. The real problem is usually a missing group write bit; change the directory to
775and add the web-server user to the group instead of opening it to everyone. - Leaving wp-config.php world-readable. This exposes database usernames, passwords and salts, which is a classic case of information disclosure.
- Setting files to 600 or 660 indiscriminately. If a file needs to be served by the web server (e.g., theme CSS or JavaScript), making it unreadable to “others” will cause 403 errors and break the site.
- Forgetting the execute bit on directories. A directory set to
744looks safe but prevents the web server from traversing it, resulting in missing images or broken admin pages.
Limitations of permission hardening
Changing permissions cannot protect you from vulnerabilities that allow arbitrary code execution with the same user privileges as the web server. If an attacker gains a PHP sandbox that runs under the same UID, they can still modify files that the owner is allowed to write. Permission changes also do not stop attacks that exploit insecure plugins, theme code, or poorly filtered user input. In short, permissions are a strong containment layer, not a complete shield.
How to integrate permission checks into a regular maintenance routine
- Re-check permissions after every update, migration or restore, when they most often change. Run the
findlisting commands above and fix only what has drifted, rather than resetting everything on a schedule. - Include permission verification in your deployment script: after copying new theme or plugin files, automatically set them to
644/755. - Monitor file changes with a file-integrity tool that alerts you when a core file’s permissions deviate from the baseline.
- Document any custom permission needs (e.g., a plugin that writes to a specific folder) so future admins know why a folder might be
775instead of755.
How Silent Threads helps
Silent Threads' Attack Surface scanner flags wp-config.php and .htaccess when the web server can write to them, and offers a one-click fix that makes them read-only, where your host allows it. Other permissions still need your host's file manager or SFTP.
The short version
- Directories =
755; files =644. wp-config.php=640or600.- Never use
777- it gives anyone on the server write access. - Check permissions with
findcommands or a file manager, then fix withchmod. - Keep an eye on the uploads folder and disable PHP execution there.
- Permissions limit damage but do not replace secure code and regular updates.




