(Authenticated) Remote Code Execution Possible in Web Interface 5.5
The web interface's domain and client validation uses a regular expression with an unescaped period, allowing an attacker to inject shell metacharacters. When the configuration file is later sourced by the gravity script, the injected commands execute, enabling code execution, file overwrite, and directory listing.
github.com
Published on github.com
PromoFaux published GHSA-5cm9-6p3m-v259 Aug 4, 2021
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 regular expression used to validate domain and client names does not escape a period, so any character can match it, allowing shell metacharacters to pass validation and be written into a file that is later sourced.
Impact
An authenticated attacker could execute commands, list directories, overwrite sensitive files including PHP files and root's bashrc, and potentially shut down the machine; the text notes a more Linux-savvy attacker might achieve full command execution.
What the attacker needed
Authenticated admin access to the web interface
How it was found
- Log in to the Pi-hole admin interface to obtain a session cookie and CSRF token.
- Submit a settings form with a domain or client value containing a shell metacharacter and a command.
- The injected string is written into the setupVars.conf file.
- Visit the gravity endpoint and trigger an update to source the file and execute the command.
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 interface checks that a domain or client name looks valid, but its check is too loose and lets special characters through. Those characters end up in a configuration file that is later run as a shell script, so an attacker can sneak in extra commands. This requires being logged in as an administrator.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.