Cve 2021 28379 Abusing File Uploads To Get An Ssh Backdoor
The VestaCP file upload feature allowed authenticated users to control the upload directory and create arbitrary directories, and the file copy script only permitted writing to /tmp or /home/admin. An attacker could upload an SSH authorized_keys file to /home/admin/.ssh, gaining SSH access as the admin user.
Published on infosecwriteups.com
Free Link
The full write-up lives on its author's site
It belongs to its author, 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
The upload handler allowed the client to set the destination directory via a GET parameter and created missing directories, while the copy script only restricted writes to /tmp or /home/admin, enabling placement of an SSH authorized_keys file.
Impact
An authenticated attacker could gain SSH access as the admin user, and combined with CSRF this could lead to remote code execution.
What the attacker needed
Authenticated user account; ability to send crafted requests (CSRF for unauthenticated)
How it was found
- Authenticate to VestaCP and access the file upload endpoint.
- Set the 'dir' GET parameter to /home/admin/.ssh to target the SSH directory.
- Upload a file named authorized_keys containing the attacker's public SSH key.
- Connect to the server via SSH using the corresponding private key as the admin user.
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.
VestaCP is a web hosting control panel. Its file upload feature let a logged-in user choose where files were saved, and it would create missing folders. The attacker saved a special file that tells the server's SSH service to trust their own key, then logged in as the admin user over SSH.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.