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
- Kernel level: ensure
/etc/sysctl.conf(or/etc/sysctl.d/) has:fs.protected_symlinks = 1fs.protected_hardlinks = 1fs.protected_regular = 2fs.protected_fifos = 2Apply withsysctl -p.
- Apache level — replace
FollowSymLinkswithSymLinksIfOwnerMatch: in WHM > Apache Configuration > Global Configuration and in the include for each vhost, the defaultOptions +FollowSymLinksbecomesOptions +SymLinksIfOwnerMatch. This is the supported cPanel path. - 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.
- CloudLinux CageFS: CageFS sidesteps this entirely — symlinks across accounts are not visible because each account has a separate namespace.
- Verify with an attack test (lab only): from account A,
ln -s /home/B/public_html/wp-config.php ./test.txt, thencurl http://accountA-site.com/test.txt. Should return 403 or 404, not the contents of B’s config file. .htaccessdoes not save you: a customer’s.htaccesscan re-enableOptions FollowSymLinksunless you forbid override. UseAllowOverrideListto restrict which options are allowed.- Quarterly audit: a global grep for
FollowSymLinksshould return zero customer-configurable files allowing it.
Stack Harbor enforces symlink-race protection on every managed multi-tenant cPanel host under cPanel/WHM management.