Skip to main content
Menu
Advisories

Unauthenticated Arbitrary Class Loading via SQL Server socketFactoryClass

GHSA-26FQ-M9W8-PXQ2Published Updated GitHub

Description

Impact

Summary

DataEase Community Edition v3.0.0 contains an unauthenticated arbitrary class loading vulnerability in the datasource connection validation interface (POST /de2api/datasource/validate). The endpoint lacks authorization checks (@DePermit), allowing unauthenticated network attackers to invoke it directly. When configuring a Microsoft SQL Server datasource (type=sqlServer), the application fails to validate the socketFactoryClass JDBC connection parameter across both hostName (via extraParams) and raw jdbcUrl configurations. The underlying Microsoft SQL Server JDBC driver (mssql-jdbc) passes this parameter directly to Class.forName(), followed by an instantiation attempt if the class implements javax.net.SocketFactory. This enables unauthenticated attackers to force the server's JVM to load arbitrary classes present on the classpath. Note that this issue is an unauthenticated class loading and instantiation primitive rather than Remote Code Execution (RCE), as no executable SocketFactory gadgets are known on the default classpath.

Affected Code

The vulnerability stems from missing authentication on the validation API combined with missing connection parameter filtering in the SQL Server provider:

1. Missing Authentication Check In io.dataease.api.ds.DatasourceApi.java, the POST /datasource/validate endpoint is not annotated with @DePermit, whereas other endpoints (such as GET /validate/{id}) enforce permissions. In standalone Community Edition deployments (listening on DE_PORT=8100 without reverse-proxy authorization filtering), the validation endpoint can be invoked without providing any authentication token. The validation action only tests connectivity and does not persist the datasource to the database.

2. Incomplete JDBC URL Security Filtering In io.dataease.datasource.type.Sqlserver.java, the getJdbc() method handles connection strings through two code paths, neither of which blocks socketFactoryClass:

  • Raw JDBC URL Path (urlType=jdbcUrl): The code checks only for the jdbc:sqlserver prefix and returns the user-supplied URL directly without passing it through JdbcUrlSecurityPolicy.validate().
  • Hostname Path (urlType=hostName + extraParams): User-supplied extraParams are appended directly to the URL (jdbc:sqlserver://...;EXTRA_PARAMS). While JdbcUrlSecurityPolicy.validate() is invoked, the SQL Server-specific dangerous fragments list (TYPE_DANGEROUS_FRAGMENTS["sqlserver"]) was empty, and the COMMON_DANGEROUS_FRAGMENTS list filters only MySQL-related parameters (e.g., autoDeserialize, queryInterceptors) and protocols (jndi:, ldap:), omitting socketFactoryClass.

3. Driver-Level Class Loading Sink The Microsoft SQL Server JDBC driver (mssql-jdbc) parses connection properties and evaluates socketFactoryClass. Upon receiving this parameter, the driver invokes Class.forName(socketFactoryClass) within the application's classloader context. If the class is found and implements javax.net.SocketFactory, the driver attempts instantiation using the default constructor (or a single String constructor if socketFactoryConstructorArg is provided).

Technical Analysis

Root Cause: The application enforces parameter blacklists for other drivers (such as PostgreSQL's socketFactory or generic autoDeserialize), but left SQL Server parameter filtering empty while leaving the validation API unauthenticated.

Comparative Analysis:

  • PostgreSQL socketFactory → Rejected by JdbcUrlSecurityPolicy with Illegal parameter: socketFactory.
  • SQL Server autoDeserialize → Rejected by JdbcUrlSecurityPolicy with Illegal parameter: autoDeserialize.
  • SQL Server socketFactoryClass → Passes validation without restriction, reaching the driver's Class.forName sink.

Exploitation Scope & Clarification:

  • This issue allows unauthenticated arbitrary class loading and attempted instantiation.
  • Because no known javax.net.SocketFactory implementations on the default classpath provide an arbitrary command execution gadget, this vulnerability does not provide direct Remote Code Execution.
  • The POST /de2api/datasource/validate endpoint performs an in-memory connection test and does not save the datasource record in persistent storage.

Vulnerability Reproduction / POC

Prerequisites:

  • Target: DataEase Community Edition v3.0.0 (e.g. official image dataease:v3.0.0, commit a339f1e003f21029d5c37f2c491c8b11c7a72abc)
  • Network access to port 8100
  • No authentication credentials required

Steps:

  1. Verify Unauthenticated Context: Sending a request without authentication tokens to GET /de2api/user/ipInfo returns 400 with message eq(null) is not allowed, verifying the absence of a user session:

<img width="1684" height="392" alt="Unauthenticated verification via ipInfo" src="raw.githubusercontent.com/tzlaosiji/abc/main/images/dataease-sqlserver-socketfactory/01-not-login-ipinfo.png" />

  1. Verify Existing Blacklist Controls: Attempting to pass MySQL autoDeserialize or PostgreSQL socketFactory confirms active filtering for those components:

<img width="1832" height="696" alt="SQL Server autoDeserialize blocked" src="raw.githubusercontent.com/tzlaosiji/abc/main/images/dataease-sqlserver-socketfactory/02-sqlserver-block-autodeserialize.png" />

<img width="1794" height="685" alt="PostgreSQL socketFactory blocked" src="raw.githubusercontent.com/tzlaosiji/abc/main/images/dataease-sqlserver-socketfactory/03-pgsql-block-socketfactory.png" />

  1. Trigger Arbitrary Class.forName: Submit an unauthenticated request to POST /de2api/datasource/validate with type=sqlServer and a non-existent class name in socketFactoryClass:

```http POST /de2api/datasource/validate HTTP/1.1 Host: target:8100 Content-Type: application/json

{ "id": null, "name": "test_sqlserver", "type": "sqlServer", "configuration": "eyJkYXRhQmFzZSI6InRlc3QiLCJleHRyYVBhcmFtcyI6InNvY2tldEZhY3RvcnlDbGFzcz1pby5kYXRhZWFzZS5wb2MuTm90RXhpc3RTb2NrZXRGYWN0b3J5OyIsImhvc3QiOiIxMjcuMC4wLjEiLCJwYXNzd29yZCI6InBhc3MiLCJwb3J0IjoxNDMzLCJ1cmxUeXBlIjoiaG9zdE5hbWUiLCJ1c2VybmFtZSI6InNhIn0=" } `` *Decoded configuration payload:* `json { "host": "127.0.0.1", "port": 1433, "dataBase": "test", "username": "sa", "password": "pass", "urlType": "hostName", "extraParams": "socketFactoryClass=io.dataease.poc.NotExistSocketFactory;" } ``

The server returns ClassNotFoundException: io.dataease.poc.NotExistSocketFactory, confirming that Class.forName was invoked:

<img width="1831" height="716" alt="SQL Server socketFactoryClass triggers ClassNotFoundException" src="raw.githubusercontent.com/tzlaosiji/abc/main/images/dataease-sqlserver-socketfactory/04-sqlserver-socketfactory-classforname.png" />

  1. Verify Raw JDBC URL Bypass: The raw JDBC URL short path (urlType=jdbcUrl) similarly reaches Class.forName:

<img width="1824" height="728" alt="Raw jdbcUrl short path triggers ClassNotFoundException" src="raw.githubusercontent.com/tzlaosiji/abc/main/images/dataease-sqlserver-socketfactory/05-jdbc-short-route.png" />

  1. Verify Class Resolution and Subclass Check: Supplying an existing classpath class such as java.lang.String (socketFactoryClass=java.lang.String;) results in: `` Class java.lang.String must be assignable to javax.net.SocketFactory ` This confirms that Class.forName successfully located and loaded the class before failing the SocketFactory` type assertion:

<img width="1825" height="715" alt="java.lang.String succeeds forName and fails SocketFactory assignment" src="raw.githubusercontent.com/tzlaosiji/abc/main/images/dataease-sqlserver-socketfactory/06-string-class-assignable-check.png" />

Impact

Unauthenticated network attackers can:

  • Force the application JVM to execute Class.forName for arbitrary class names.
  • Trigger static initializers of existing classes on the classpath.
  • Probe the classpath for the existence or absence of specific classes via differential error messages.
  • Attempt object instantiation if a targeted class implements javax.net.SocketFactory.

Affected versions

  • Affected versions <= v3.0.0 (specifically confirmed on release tag v3.0.0, commit a339f1e003f21029d5c37f2c491c8b11c7a72abc)

Patches

The vulnerability has been addressed in commit b26005c50 and will be included in v3.1.0.

References

If you have any questions or comments about this advisory:

Affected versions

References

GitHub · dataease/dataease