CVE-2020-11108: How I Stumbled into a Pi-hole RCE+LPE
An authenticated user of the Pi-hole web interface could inject extra curl flags through the blocklist URL field, causing the server to write a PHP file into the web directory and achieve remote code execution. The same flaw could overwrite a PHP script that is later run as root via sudo, leading to privilege escalation.
frichetten.com
Published on frichetten.com
The following is a technical writeup for CVE-2020-11108, a vulnerability that allows an authenticated user of the Pi-hole web application to gain remote code execution and escalate privileges to root. This vulnerability affects Pi-hole v4.4 and below.
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 blocklist URL and derived variables were passed unquoted into a curl command, allowing shell metacharacters and extra curl flags to be injected.
Impact
An authenticated user could execute arbitrary code as the web server user and then escalate to root, but only if they can reach the web interface and, for one variant, if BLOCKINGMODE is set to NXDOMAIN.
What the attacker needed
Authenticated web interface access; attacker-controlled server on port 80; BLOCKINGMODE=NXDOMAIN for one variant
How it was found
- Log in to the Pi-hole web interface and go to Settings > Blocklists.
- Disable existing blocklists and add a new blocklist URL containing injected curl flags.
- Start a netcat listener on port 80 to serve the malicious content.
- Click 'Save and Update' and respond with a 200 OK to the incoming request.
- Update Gravity a second time and serve the PHP payload when the request includes '.domains'.
- Request the written PHP file under /admin/scripts/pi-hole/php/ to trigger the payload.
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.
Pi-hole is a tool that blocks ads for your whole network. Its web interface lets you add blocklists by URL, and the server uses a command-line tool called curl to download them. The bug is that the URL was passed to curl without proper quoting, so an attacker could sneak in extra curl options that made the server save a malicious file. That file could then be run as a web page, giving the attacker control of the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.