Skip to content
SQL injection Write-up Advanced

Exploiting Hibernate Injection in "Order by" Clause (Oracle database)

The web application passed user-supplied data as a column name in an 'Order by' clause, leading to Hibernate Query Language (HQL) injection. An attacker could use boolean-based blind injection with error-generating inline queries to extract information from the Oracle database.

Mannu Linux Follow

Published on mannulinux.org

In this case, the web application was passing user-supplied data as column name to "Order by" clause.

Mannu Linux (@IndiShell1046), on mannulinux.org

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, user input was concatenated directly into an HQL 'order by' clause without proper validation or parameterisation, allowing injection.

Impact

An attacker could extract arbitrary data from the Oracle database through boolean-based blind injection, potentially leading to full database compromise.

What the attacker needed

User input passed to order by clause; Oracle database backend

How it was found

  1. Identify that user input is passed to the 'order by' clause and causes a Hibernate error.
  2. Craft an inline query that raises an exception when a condition is true, using division by zero or an invalid date format.
  3. Inject the inline query into the order by clause to create a boolean-based blind injection payload.
  4. Observe different HTTP responses for true and false conditions to extract data.

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.

The application let users choose how to sort a list, but it inserted their choice directly into a database query without checking it. This allowed an attacker to sneak in extra database commands. By causing the database to throw an error only when a secret condition was true, the attacker could slowly extract data one bit at a time.

What is SQL injection?

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

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.