Skip to content

Symlink race protection on cPanel Apache — why it matters

The Apache symlink race vulnerability that affects multi-tenant cPanel hosts, and the SymlinksIfOwnerMatch and CloudLinux protections that close it.

The Apache symlink race is the classic shared-hosting attack. Account A creates a symlink from their public_html to account B’s wp-config.php, Apache follows the link as Apache’s UID (which can read every account’s files), and account A’s webshell reads account B’s database credentials. cPanel ships protections, but they must be enabled and verified.

What’s happening

By default, Apache’s Options FollowSymLinks lets any symlink be followed during request handling. On a multi-tenant host, that means any account can symlink-read into any other account if Apache runs as a shared UID. The two relevant Apache directives are Options SymLinksIfOwnerMatch (only follow symlinks where the target’s UID matches the link’s UID) and the cPanel-specific symlink race protection patch.

How to verify

grep -r "FollowSymLinks\|SymLinksIfOwnerMatch" /etc/apache2/conf.d/ /etc/apache2/conf/
grep -E "symlink" /var/cpanel/conf/apache/local
ls -la /etc/apache2/conf.d/symlink_protection.conf 2>/dev/null
sysctl fs.protected_symlinks
sysctl fs.protected_hardlinks

fs.protected_symlinks=1 is the kernel-level protection (Linux 3.6+). The Apache directive is a layer above. Both should be enabled.

The fix

  1. Kernel level: ensure /etc/sysctl.conf (or /etc/sysctl.d/) has:
    • fs.protected_symlinks = 1
    • fs.protected_hardlinks = 1
    • fs.protected_regular = 2
    • fs.protected_fifos = 2 Apply with sysctl -p.
  2. Apache level — replace FollowSymLinks with SymLinksIfOwnerMatch: in WHM > Apache Configuration > Global Configuration and in the include for each vhost, the default Options +FollowSymLinks becomes Options +SymLinksIfOwnerMatch. This is the supported cPanel path.
  3. cPanel symlink race patch: WHM > Tweak Settings > Security > Use jailshell by default for new accounts is related but not the same. The actual patch is WHM > Security Center > Symlink Race Condition Protection if it appears in your cPanel version. Older cPanel installs may rely on the kernel sysctls only.
  4. CloudLinux CageFS: CageFS sidesteps this entirely — symlinks across accounts are not visible because each account has a separate namespace.
  5. Verify with an attack test (lab only): from account A, ln -s /home/B/public_html/wp-config.php ./test.txt, then curl http://accountA-site.com/test.txt. Should return 403 or 404, not the contents of B’s config file.
  6. .htaccess does not save you: a customer’s .htaccess can re-enable Options FollowSymLinks unless you forbid override. Use AllowOverrideList to restrict which options are allowed.
  7. Quarterly audit: a global grep for FollowSymLinks should return zero customer-configurable files allowing it.

Stack Harbor enforces symlink-race protection on every managed multi-tenant cPanel host under cPanel/WHM management.