Utilizing Log Poisoning: Elevating from LFI to RCE
The web application had a local file inclusion (LFI) vulnerability in a page parameter, and an admin page allowed reading Nginx access logs. By injecting PHP code into the User-Agent header, the attacker could execute arbitrary commands on the server.
Log Poisoning is a technique used in cybersecurity to exploit vulnerabilities within web applications, particularly in the context of escalating privileges from Local File Inclusion (LFI) to Remote Code Execution (RCE). By manipulating log files, attackers can inject malicious code or commands, enabling them to gain…
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 passed user-supplied input directly to a file inclusion function without proper validation, and the admin log viewer allowed reading arbitrary log files, enabling log poisoning.
Impact
An attacker could execute arbitrary commands on the server, leading to full remote code execution.
What the attacker needed
Access to the web application; knowledge of the log file path; ability to send custom HTTP headers
How it was found
- Identify the page parameter and test for local file inclusion.
- Use PHP filter wrappers to read the source code of index.php.
- Discover an admin page and a log parameter that is also vulnerable to LFI.
- Access the Nginx access log through the log parameter.
- Inject PHP system code into the User-Agent header and send a request.
- Remove the User-Agent header, add a cmd parameter, and execute commands on the server.
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.
Local file inclusion lets an attacker make a web page show files from the server that it should not. Here, the attacker also found a way to write PHP code into a log file that the server records for every visit. When the page later reads that log file, the PHP code runs, 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.