Sar Cve 2019 12454 In sar2html And A Writable Cron Script That Got Me Root Offsec Pg
The sar2html web application passes the 'plot' parameter directly into a shell command without sanitisation, allowing unauthenticated remote code execution as the web server user. A root-owned cron job runs a script located in a web-writable directory, so an attacker can overwrite that script to gain root privileges.
Published on infosecwriteups.com
SAR is an easy-rated Linux machine on OffSec Proving Grounds Play. Two services are exposed: SSH on 22 and Apache on 80.
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
Likely the application fails to sanitise user input before passing it to a shell, and a privileged cron job executes a script from a directory writable by the web server user.
What the attacker needed
Network access to the web server; no authentication required
The fix
The report recommends upgrading or removing sar2html, moving the cron script outside the web root with strict permissions, removing phpinfo.php, applying system updates, and adding egress filtering; it does not state that these were applied.
How it was found
- Scan the target and find SSH on port 22 and Apache on port 80.
- Brute-force web directories and discover /sar2HTML/ and robots.txt.
- Inspect the sar2html page source to identify version 3.2.1 and the plot parameter.
- Confirm command execution by injecting a simple command through the plot parameter.
- Start a listener and send a reverse shell payload through the plot parameter to get a shell as www-data.
- Read /etc/crontab, find a root cron job running finally.sh from /var/www/html/, overwrite that script with a reverse shell, and wait for the job to fire.
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.
The web app takes a value from the URL and runs it as part of a system command, so an attacker can add extra commands that the server executes. Separately, a scheduled task runs a script as the all-powerful root user, but the script sits in a folder the web server can write to, so the attacker replaces it with their own code. Together these give full control of the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.