Skip to content
RCE Write-up Intermediate

Authenticated RCE in PhpMyAdmin via SQL File Write and Shell Uplo

An authenticated user with FILE privileges could use SELECT ... INTO OUTFILE to write a PHP uploader to the web root, then upload and trigger a reverse shell. This led to remote code execution on the server.

CyberQuestor Follow

Published on osintteam.blog

Misconfigurations in widely used tools like PhpMyAdmin can lead to critical vulnerabilities when overlooked. In this post, I demonstrate how authenticated access combined with improper privilege management can allow an attacker to write and execute a malicious PHP file through a SQL query which ultimately leading to…

CyberQuestor, on osintteam.blog

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 database user was granted FILE privileges and the web root was writable by MySQL, allowing SQL queries to write executable files.

Impact

An authenticated attacker could execute arbitrary code on the server, leading to full compromise.

What the attacker needed

Valid login credentials; database user with FILE privileges; web root writable by MySQL; PhpMyAdmin exposed with write access

The fix

The FILE privilege should be disabled for database users, web root permissions should be restricted, and PhpMyAdmin should not be exposed to the internet.

How it was found

  1. Log in to PhpMyAdmin with valid credentials.
  2. Use SELECT ... INTO OUTFILE to write a PHP uploader to the web root.
  3. Visit the uploader in the browser.
  4. Generate a reverse shell payload with msfvenom.
  5. Upload the reverse shell using the uploader.
  6. Trigger the reverse shell by visiting it, and catch the connection with netcat.

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.

PhpMyAdmin is a web tool for managing databases. If a database user has a special permission called FILE, they can write files to the server's disk using a SQL command. If the web server's folder is writable, an attacker who can log in can place a malicious PHP script there and run it, taking over 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.

More by CyberQuestor

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.