Skip to content
hostcomplex

File Permissions Security

Maarten Soetens 2 min read

How File Permissions Control Access on a Server

File permissions security is the set of rules that decides which users and programs may read, change or run each file on a server. Every file and folder has an owner, a group and settings for three actions: read, write and execute.

A web server runs as a specific system user. Website scripts inherit that user's rights. If a file is writable by that user, or by everyone, then a compromised script can rewrite it. This is why a small mistake in a permission setting can turn a minor bug into a full takeover. On shared servers, the same risk is limited by account isolation.

Why Overly Open Permissions Are Dangerous

The most common mistake is making a file or folder writable by everyone. A permission value such as 777 allows any account on the server to change the item. On a shared server, that includes accounts belonging to other customers.

Wrong ownership causes similar problems. If a website's files belong to a different account than the one serving the site, the wrong party may be able to edit them, or the site may need permissions that are too loose to work at all. Administrators sometimes loosen permissions to fix an error quickly. The quick fix then stays in place and becomes the weakness.

Upload folders deserve special attention. An upload folder that is writable by the web server and also runs scripts is a common route for attackers, who upload a script and then call it from the browser.

Which Files Are Most Sensitive

Not every file carries the same risk. The following items deserve the strictest settings:

  • Configuration files that contain database passwords or API secrets.
  • Script files that the server executes, because changing them changes what the site does.
  • Upload and cache folders, which must accept new files but should not run them.
  • SSH keys and authorized key lists, which control who can log in to the server.

Files that visitors never need to modify should generally be readable by the web server but not writable by it. Keeping access this narrow follows the idea behind least privilege.

Frequently asked questions

Is 777 permission always a security problem?

On a website, almost always. The value 777 lets every user on the system read, write and execute the item. A web file or folder rarely needs that level of access, and narrower settings for the owner and the web server user are usually enough.

Should the web server be able to write to website files?

Only where the application truly needs to write, such as an upload or cache folder. Most code files should be readable but not writable by the web server. That way, a compromised application cannot easily rewrite its own scripts or plant new ones.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.