How Hackers Hack Into Websites On Shared Hosts - Part 1
A shared hosting server allows an attacker who compromises one site to use a symlink bypass to read configuration files of other sites on the same server. The attacker can then use the extracted database credentials to access and modify other sites' databases.
Published on rafaybaloch.com
The original lives on rafaybaloch.com
We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the shared hosting environment does not properly isolate websites, allowing a compromised site to use symlinks to access files outside its own directory.
Impact
An attacker who compromises one site on a shared server could read other sites' configuration files and use the credentials to access and modify their databases.
What the attacker needed
Shared hosting server; at least one vulnerable site on the server; ability to upload a PHP shell
The fix
The text suggests renaming configuration files and moving them to a safer location, but a proper fix would be to isolate websites on the shared server so symlinks cannot escape their directories.
How it was found
- Find a list of domains on the shared server using a reverse IP lookup.
- Hack into any vulnerable website on that server and upload a PHP shell.
- Upload a script (and possibly a .htaccess file) and make it publicly accessible with 0755 permissions.
- Connect to the script and run commands to create a directory, navigate into it, create a symlink to the root, and list the aliases file for the target site to extract its username.
- Navigate to the created directory to find the target website's configuration file, download it, and use the credentials to access the database.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Shared hosting means many websites live on one computer. If one website is hacked, the attacker can sometimes use a trick called a symlink (like a shortcut) to peek at files belonging to other websites on the same computer. This lets them steal database passwords and take over those other sites.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.