Jumping from SQL injection to RCE
A SQL injection allowed the attacker to write files to the server, and the attacker used it to drop a small PHP backdoor into the web root. By calling that file with a command parameter, arbitrary commands could then be run on the server.
In this case we are going to take advantage of a sql injection error to be able to “jump” to other vulnerabilities.
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 SQL injection combined with a database account that had file write privileges, letting the attacker write a PHP script into a web-accessible directory.
Impact
An attacker could run arbitrary commands on the server, leading to full compromise of the host.
What the attacker needed
SQL injection exists; Database user can write files; Known web-accessible path
How it was found
- Find the SQL injection and read the server path from the error screen.
- Use the injection to write a PHP file into a web-accessible path.
- Access the written file in the browser.
- Pass a command through the parameter used in the injected script to run it.
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.
A SQL injection is when user input is placed into a database query without proper handling, so an attacker can change the query. Here the database user could also write files to disk, so the attacker saved a small PHP script that runs whatever command is passed to it. Visiting that script then lets the attacker run commands on the server, which is remote code execution.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.