Web Shell
A web shell is a malicious script that an attacker plants on a web server, so they can run commands on the server by sending it HTTP requests.
The classic route in is a file upload vulnerability. An attacker uploads a
file named, say, avatar.php, containing a one-line PHP script that runs whatever command it finds
in a URL parameter. If the server stores uploads in a public directory and executes .php files
there, the attacker can now visit /uploads/avatar.php?cmd=whoami and read the output in their
browser. Web shells are also a favorite way to keep access after exploiting some other
vulnerability, since they survive reboots and look like any other file on disk.
In March 2021, attackers exploited four vulnerabilities in Microsoft Exchange Server (known collectively as ProxyLogon) and planted web shells on tens of thousands of servers around the world. A month later, the FBI got a court order to remove web shells from hundreds of computers in the United States whose owners had not cleaned them up.
To prevent web shells, store uploaded files outside the web root (or in separate cloud storage), rename them on upload, make sure the server never executes them, and patch your servers promptly.