# CVE-2020-1947: Deserialization of Untrusted Data in Apache ShardingSphere

> Attackers can achieve remote code execution by sending malicious YAML inputs to the ShardingSphere web console due to unsafe SnakeYAML deserialization.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 11 Mar 2020
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-v54f-xcmp-43cr

## What is CVE-2020-1947?

CVE-2020-1947 is a critical unsafe deserialization vulnerability in Apache ShardingSphere(incubator), published on 11 Mar 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

In Apache ShardingSphere(incubator) 4.0.0-RC3 and 4.0.0, the ShardingSphere's web console uses the SnakeYAML library for parsing YAML inputs to load datasource configuration. SnakeYAML allows to unmarshal data to a Java type By using the YAML tag. Unmarshalling untrusted data can lead to security flaws of RCE.

Weakness: CWE-502 (Deserialization of Untrusted Data)

## Which versions are affected by CVE-2020-1947?

2 open source packages ship an affected version, including org.apache.shardingsphere:shardingsphere. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.apache.shardingsphere:shardingsphere` | Maven | From 4.0.0-RC3 | 4.0.1 |
| `org.apache.shardingsphere:shardingsphere` | Maven | From 4.0.0-RC3 | 4.0.1 |

Products: Apache Shardingsphere.

## How do I fix CVE-2020-1947?

Upgrade org.apache.shardingsphere:shardingsphere to 4.0.1 or later.

## Is CVE-2020-1947 being exploited?

There is no known exploitation of CVE-2020-1947 in the wild and no public exploit code.

Public exploit code:

- Apache ShardingSphere UI YAML解析远程代码执行漏洞 (github_poc): https://github.com/jas502n/CVE-2020-1947
- CVE-2020-1947 Python POC (github_poc): https://github.com/wsfengfan/CVE-2020-1947
- https://github.com/shadowsock5/ShardingSphere_CVE-2020-1947 (github_poc): https://github.com/shadowsock5/ShardingSphere_CVE-2020-1947
- https://github.com/StarkChristmas/CVE-2020-1947 (github_poc): https://github.com/StarkChristmas/CVE-2020-1947

## Other vulnerabilities in Apache ShardingSphere(incubator)

- [CVE-2022-45347](https://insights.sbomify.com/CVE-2022-45347/): Apache ShardingSphere-Proxy: MySQL authentication bypass (critical 9.8)
- [CVE-2023-28754](https://insights.sbomify.com/CVE-2023-28754/): ShardingSphere-Agent: Deserialization vulnerability in ShardingSphere Agent (high 8.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-1947 and fix it if it is affected.

What it is: CVE-2020-1947 is a critical unsafe deserialization vulnerability in Apache ShardingSphere(incubator), published on 11 Mar 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2020-1947 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.apache.shardingsphere:shardingsphere (Maven): affected from 4.0.0-RC3; fixed in 4.0.1
- org.apache.shardingsphere:shardingsphere (Maven): affected from 4.0.0-RC3; fixed in 4.0.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2020-1947/ (Markdown: https://insights.sbomify.com/CVE-2020-1947/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2020-1947
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2020-1947
- OSV: https://osv.dev/vulnerability/CVE-2020-1947

---
From sbomify Insights: https://insights.sbomify.com/CVE-2020-1947/
Summaries are generated and may contain mistakes; the official description above is the record.
