GHSA-Q4QQ-JHJV-7RH2
Vulnerability from github – Published: 2022-10-18 18:05 – Updated: 2022-10-25 20:31Impact
In Dataease, the Mysql data source in the data source function can customize the JDBC connection parameters and the Mysql server target to be connected.

In backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java, MysqlConfiguration class don't filter any parameters, directly concat user input.
@Getter
@Setter
public class MysqlConfiguration extends JdbcConfiguration {
private String driver = "com.mysql.jdbc.Driver";
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
public String getJdbc() {
if(StringUtils.isEmpty(extraParams.trim())){
return "jdbc:mysql://HOSTNAME:PORT/DATABASE"
.replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim());
}else {
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim())
.replace("EXTRA_PARAMS", getExtraParams().trim());
}
}
}
So, if the attack add some parameters in JDBC url, and connect to evil mysql server, he can trigger the mysql jdbc deserialization vulnerability, and eventually the attacker can execute through the deserialization vulnerability system commands and obtain server privileges.
Affected versions: < 1.15.2
Patches
The vulnerability has been fixed in v1.15.2.
https://github.com/dataease/dataease/blob/6c3a011955c5c753ffd616d030bea5db4793c51c/backend/src/main/java/io/dataease/dto/datasource/MysqlConfiguration.java#L19
the MysqlConfiguration class use illegalParameters filter illegal parameters to fix this vulnerability.
@Getter
@Setter
public class MysqlConfiguration extends JdbcConfiguration {
private String driver = "com.mysql.jdbc.Driver";
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
private List<String> illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations");
public String getJdbc() {
if (StringUtils.isEmpty(extraParams.trim())) {
return "jdbc:mysql://HOSTNAME:PORT/DATABASE"
.replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim());
} else {
for (String illegalParameter : illegalParameters) {
if (getExtraParams().contains(illegalParameter)) {
throw new RuntimeException("Illegal parameter: " + illegalParameter);
}
}
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim())
.replace("EXTRA_PARAMS", getExtraParams().trim());
}
}
}
Workarounds
It is recommended to upgrade the version to v1.15.2.
For more information
If you have any questions or comments about this advisory: * Open an issue in https://github.com/dataease/dataease * Email us at wei@fit2cloud.com
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "io.dataease:dataease-plugin-common"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.15.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-39312"
],
"database_specific": {
"cwe_ids": [
"CWE-20",
"CWE-502"
],
"github_reviewed": true,
"github_reviewed_at": "2022-10-18T18:05:36Z",
"nvd_published_at": "2022-10-25T17:15:00Z",
"severity": "CRITICAL"
},
"details": "### Impact\n\nIn Dataease, the Mysql data source in the data source function can customize the JDBC connection parameters and the Mysql server target to be connected.\n\n\nIn `backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java`, MysqlConfiguration class don\u0027t filter any parameters, directly concat user input.\n```java\n@Getter\n@Setter\npublic class MysqlConfiguration extends JdbcConfiguration {\n\n private String driver = \"com.mysql.jdbc.Driver\";\n private String extraParams = \"characterEncoding=UTF-8\u0026connectTimeout=5000\u0026useSSL=false\u0026allowPublicKeyRetrieval=true\u0026zeroDateTimeBehavior=convertToNull\";\n\n public String getJdbc() {\n if(StringUtils.isEmpty(extraParams.trim())){\n return \"jdbc:mysql://HOSTNAME:PORT/DATABASE\"\n .replace(\"HOSTNAME\", getHost().trim())\n .replace(\"PORT\", getPort().toString().trim())\n .replace(\"DATABASE\", getDataBase().trim());\n }else {\n return \"jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS\"\n .replace(\"HOSTNAME\", getHost().trim())\n .replace(\"PORT\", getPort().toString().trim())\n .replace(\"DATABASE\", getDataBase().trim())\n .replace(\"EXTRA_PARAMS\", getExtraParams().trim());\n }\n }\n}\n```\nSo, if the attack add some parameters in JDBC url, and connect to evil mysql server, he can trigger the mysql jdbc deserialization vulnerability, and eventually the attacker can execute through the deserialization vulnerability system commands and obtain server privileges.\n\nAffected versions: \u003c 1.15.2\n\n### Patches\n\nThe vulnerability has been fixed in v1.15.2.\nhttps://github.com/dataease/dataease/blob/6c3a011955c5c753ffd616d030bea5db4793c51c/backend/src/main/java/io/dataease/dto/datasource/MysqlConfiguration.java#L19\nthe MysqlConfiguration class use `illegalParameters` filter illegal parameters to fix this vulnerability.\n```\n@Getter\n@Setter\npublic class MysqlConfiguration extends JdbcConfiguration {\n\n private String driver = \"com.mysql.jdbc.Driver\";\n private String extraParams = \"characterEncoding=UTF-8\u0026connectTimeout=5000\u0026useSSL=false\u0026allowPublicKeyRetrieval=true\u0026zeroDateTimeBehavior=convertToNull\";\n private List\u003cString\u003e illegalParameters = Arrays.asList(\"autoDeserialize\", \"queryInterceptors\", \"statementInterceptors\", \"detectCustomCollations\");\n\n public String getJdbc() {\n if (StringUtils.isEmpty(extraParams.trim())) {\n return \"jdbc:mysql://HOSTNAME:PORT/DATABASE\"\n .replace(\"HOSTNAME\", getHost().trim())\n .replace(\"PORT\", getPort().toString().trim())\n .replace(\"DATABASE\", getDataBase().trim());\n } else {\n for (String illegalParameter : illegalParameters) {\n if (getExtraParams().contains(illegalParameter)) {\n throw new RuntimeException(\"Illegal parameter: \" + illegalParameter);\n }\n }\n\n return \"jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS\"\n .replace(\"HOSTNAME\", getHost().trim())\n .replace(\"PORT\", getPort().toString().trim())\n .replace(\"DATABASE\", getDataBase().trim())\n .replace(\"EXTRA_PARAMS\", getExtraParams().trim());\n }\n }\n}\n```\n\n### Workarounds\n\nIt is recommended to upgrade the version to v1.15.2.\n\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [https://github.com/dataease/dataease](https://github.com/dataease/dataease)\n* Email us at [wei@fit2cloud.com](mailto:wei@fit2cloud.com)\n",
"id": "GHSA-q4qq-jhjv-7rh2",
"modified": "2022-10-25T20:31:45Z",
"published": "2022-10-18T18:05:36Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/dataease/dataease/security/advisories/GHSA-q4qq-jhjv-7rh2"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-39312"
},
{
"type": "WEB",
"url": "https://github.com/dataease/dataease/pull/3328"
},
{
"type": "WEB",
"url": "https://github.com/dataease/dataease/commit/956ee2d6c9e81349a60aef435efc046888e10a6d"
},
{
"type": "PACKAGE",
"url": "https://github.com/dataease/dataease"
},
{
"type": "WEB",
"url": "https://github.com/dataease/dataease/releases/tag/v1.15.2"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "MySQL JDBC deserialization vulnerability"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.