Skip to content
SQL injection Write-up Intermediate

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.

_Y000_ Follow

Published on infosecwriteups.com

In this case we are going to take advantage of a sql injection error to be able to “jump” to other vulnerabilities.

_Y000_, on infosecwriteups.com

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

  1. Find the SQL injection and read the server path from the error screen.
  2. Use the injection to write a PHP file into a web-accessible path.
  3. Access the written file in the browser.
  4. 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.

More by _Y000_

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.