HyperSQL Flaw Let Attackers Run Arbitrary Code
TL;DR: A critical vulnerability in the popular HyperSQL Java database allowed SQL queries to execute arbitrary code. By default, any Java class on the classpath was callable, creating a major remote code execution risk for many applications.
Key facts
- Category
- Cybersecurity
- Impact
- Critical
- Published
- Source
- Ubuntu Security Notices
Full summary
A critical flaw in the HyperSQL Java database allowed attackers to execute arbitrary code by default, creating a significant security risk.
A critical security flaw has been discovered in HyperSQL Database (HSQLDB), a widely used database engine written in Java. According to a security notice from Ubuntu, the database software had a default configuration that could allow an attacker to execute arbitrary code on the server. This type of issue, known as a remote code execution (RCE) vulnerability, is considered one of the most severe categories of security flaws. The vulnerability stems from a feature that allowed SQL statements to directly call static methods from any Java class available in the application's classpath. For any application that incorporates untrusted user input into its SQL queries, this flaw effectively creates a backdoor for attackers to take control of the system.
The mechanism behind this HyperSQL vulnerability is a classic case of an overly permissive default setting. HyperSQL was designed with the powerful capability to extend SQL's functionality by calling out to Java code. However, it did not restrict which Java classes or methods could be invoked. An attacker could craft a malicious input that, when embedded in an SQL query by the application, would instruct the database to execute a dangerous command. For example, a query could be made to call `java.lang.Runtime.getRuntime().exec("...")`, allowing the attacker to run any command the application's user has permission to execute. The security update addresses this by changing the default behavior. After the patch, only methods from the safe `java.lang.Math` class can be called. To enable any other classes, administrators must now explicitly list them in a new configuration property, `hsqldb.method_clas`, forcing a secure-by-default posture.
This incident fits into a broader pattern of vulnerabilities caused by features that blur the lines between data and executable code. It echoes the principles behind other major security events, such as the Log4Shell vulnerability in the Log4j library, where a logging function could be tricked into executing code. In both cases, a seemingly innocuous input from a user could trigger powerful, unintended actions deep within the application stack. These vulnerabilities highlight a persistent challenge in software development: powerful, flexible features often come with hidden security risks, especially when their default configurations prioritize convenience over security. Developers using a library may not be aware of all its capabilities, and an insecure default means they are unknowingly exposed to risk simply by including the dependency in their project.
For engineering and security teams, the immediate takeaway is the urgent need to patch. Any system using HyperSQL, particularly in environments where it processes external input, should be considered at high risk. The long-term lesson is a crucial reminder to practice defense-in-depth and adhere to the principle of least privilege. Database engines should not, by default, have the ability to execute arbitrary system commands. This event underscores the importance of thoroughly vetting third-party dependencies and their configurations, rather than assuming they are secure out of the box. Teams should conduct code reviews to identify any instances where user input is concatenated into SQL queries and prioritize using parameterized queries or prepared statements, which can mitigate this entire class of injection attacks.
Why it matters
This HyperSQL vulnerability represents a severe security risk for any application that passes untrusted user input into SQL statements. It allows for remote code execution (RCE), giving attackers a potential backdoor to take full control of the underlying server, steal data, or disrupt services.
Business impact
Companies using HyperSQL in their applications face an urgent threat of system compromise and data breaches. Failing to patch this vulnerability could lead to significant financial loss, reputational damage, and regulatory penalties. Security and engineering teams must prioritize this update to mitigate immediate risk.
⚡ Action needed
A patch is available and should be applied immediately. Systems using HyperSQL with untrusted inputs are at high risk of remote code execution.
Action checklist
- 1Identify all applications using the HyperSQL (HSQLDB) library.
- 2Check if your application passes untrusted or user-supplied data into SQL statements.
- 3Update to the patched version of HyperSQL provided by your package manager or vendor.
- 4Review code to ensure no untrusted input reaches SQL queries.
- 5If updating is not possible, configure the `hsqldb.method_clas` property to whitelist only necessary classes.
Tags
Related on Notifire
Related stories
Primary source: Ubuntu Security Notices
