Skip to content
SQL injection Write-up Intermediate

SQLI with load file and into outfile

An email parameter in an affiliate registration form was vulnerable to SQL injection, allowing the attacker to read server files and write a new file to the /tmp directory.

NoGe Follow

Published on medium.com

Bounty$750 View original

{{media:0}}

NoGe, on medium.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 application built SQL queries by concatenating user input directly, without parameterised queries or input validation.

Impact

The attacker could read arbitrary files from the server and write new files to the filesystem, which could lead to further compromise.

What the attacker needed

Ability to register as an affiliate; access to the affiliate form endpoint

How it was found

  1. Register as an affiliate on the website.
  2. Capture the POST request to the affiliate form endpoint and send it to a repeater tool.
  3. Inject a UNION SELECT query into the email parameter to retrieve the database version, user, and name.
  4. Replace the query with a load_file call to read /etc/passwd.
  5. Use an INTO OUTFILE query to write a file to /tmp.
  6. Use load_file again to confirm the file was created.

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.

SQL injection is when user input is inserted into a database query without proper handling, letting an attacker change the query's meaning. Here, the email field let the attacker run extra database commands to read files from the server and create a new file.

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 NoGe

View all

1 more disclosed report, 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.