Shared-hosting attacks
TL;DR: Co-tenant on same vhost / app pool / DB instance pivots into target’s session, files, or DB. Multi-tenant SaaS variant.
What it is
Shared-hosting environments — classic cPanel boxes, Plesk, IIS shared application pools, single-database multi-tenant SaaS — squeeze many tenants onto one OS, one web server, one database. Isolation depends on file permissions, virtual-host routing, and per-tenant DB users. Any gap in those boundaries gives one tenant access to others.
Preconditions / where it applies
- One web server instance hosting multiple customer sites (Apache mod_php, IIS w3wp shared pool, nginx + php-fpm pool shared)
- World-readable home directories, weak
open_basedir, no chroot/jail - Shared DB instance where tenant credentials are not least-privileged
- Multi-tenant SaaS keying rows by
tenant_idenforced only in application code
Technique
- Buy a cheap account on the same host as the target — same
/etc/passwdUID space, often same web user (www-data,apache). - File-system pivot —
/home/target/public_html/wp-config.phpreadable if perms slack; harvest DB creds, secret keys.1 2
ls -la /home/*/public_html/ 2>/dev/null find / -name 'wp-config.php' -readable 2>/dev/null
- PHP
open_basedirbypass — symlink,glob://,/proc/self/root/, FFI; classic cPanel symlink race exploited for years. - Apache
Symlink Race— replace a file with a symlink betweenstat()andopen()to read victim’s files aswww-data. - Session file theft — default PHP sessions in
/tmpworld-readable; grab cookies, hijack admin sessions. - Cross-vhost via
Host:— requestHost: victim.tldagainst your own vhost’s IP; if app reads files byHost, you may serve their content with your code injection. - DB pivot — same MySQL/Postgres instance; if the tenant user has
FILEor unintended cross-db SELECT, dump other tenants.information_schema.tablesis the recon target. - Multi-tenant SaaS row leak — IDOR/idor on
tenant_id, or SQL injection that drops the implicitWHERE tenant_id = Xfilter, or report endpoint with hand-picked SQL. - Shared cache — Redis/Memcached used across tenants without key prefixes; read/write neighbour keys; poison sessions (cache-poisoning).
- Shared queue / pub-sub — events leak across tenants via wildcard subscriptions.
Detection and defence
- Per-tenant OS user + chroot/container; do not share
www-data. - Apache
SymLinksIfOwnerMatch, mod_ruid2/mpm-itk for per-vhost UID; nginx + per-tenant php-fpm pool withuser=andchroot=. - DB: one role per tenant, schema isolation, row-level security (Postgres
RLS). - SaaS: enforce
tenant_idfilter in a single ORM layer, not per-query; add CI tests for cross-tenant access. - Cache/queue: namespaced keys (
tenant:{id}:…), per-tenant ACLs. - Audit
/tmp,/var/www,/home/*permissions; harden umask to 027. - Related: idor, broken-access-control, information-disclosure, cache-poisoning.
References
- Cloudlinux — CageFS — shared-hosting isolation
- HackTricks — escape jails — chroot/jail breakouts
- Postgres — Row Security Policies — per-tenant DB isolation