HQL Injection on Web Application Running Oracle Database
The application was vulnerable to HQL injection through the id parameter, allowing an attacker to execute arbitrary HQL queries. The attacker could dump the Hibernate version and potentially query the database using Oracle-specific functions.
The original lives on blog.yappare.com
We do not hold its text, 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 concatenated user input directly into an HQL query without using parameterised queries or proper validation.
What the attacker needed
None
The fix
The application should use parameterised queries or named parameters in HQL to prevent injection.
How it was found
- Send a single quote in the id parameter and observe an error.
- Send two single quotes and observe no error, indicating SQL injection.
- Use blind HQL injection techniques to extract the Hibernate version.
- Use DBMS_XMLGEN.getxml to execute a standard SQL injection via HQL.
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.
HQL is a query language similar to SQL but used by Hibernate, a tool that maps Java objects to database tables. The application inserted user input directly into an HQL query, so an attacker could change the query's logic. This let the attacker read information from the database, such as the Hibernate version.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.