# CVE-2022-31011: TiDB authentication bypass vulnerability

> Attackers can bypass authentication in TiDB to gain unauthorized access or escalate privileges, requiring specific configuration conditions.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 31 May 2022
- **Updated:** 23 Apr 2025
- **Also known as:** GHSA-4whx-7p29-mq22

## What is CVE-2022-31011?

CVE-2022-31011 is a high-severity authentication bypass vulnerability in pingcap tidb, published on 31 May 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

TiDB is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads. Under certain conditions, an attacker can construct malicious authentication requests to bypass the authentication process, resulting in privilege escalation or unauthorized access. Only users using TiDB 5.3.0 are affected by this vulnerability. TiDB version 5.3.1 contains a patch for this issue. Other mitigation strategies include turning off Security Enhanced Mode (SEM), disabling local login for non-root accounts, and ensuring that the same IP cannot be logged in as root and normal user at the same time.

Weakness: CWE-287 (Improper Authentication)

## Which versions are affected by CVE-2022-31011?

6 open source packages ship an affected version, including github.com/pingcap/tidb. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/pingcap/tidb` | Go | From 0.0.0-20210808221113-a7fdc2a05663 | 0.0.0-20220221072141-27ffd1126da1 |
| `github.com/pingcap/tidb` | Go | From 0.0.0-20210808221113-a7fdc2a05663 | 0.0.0-20220221072141-27ffd1126da1 |
| `github.com/pingcap/tidb` | Go | From 1.1.0-beta.0.20210808221113-a7fdc2a05663 | 1.1.0-beta.0.20220221072141-27ffd1126da1 |
| `github.com/pingcap/tidb` | Go | From 1.1.0-beta.0.20210808221113-a7fdc2a05663 | 1.1.0-beta.0.20220221072141-27ffd1126da1 |
| `github.com/pingcap/tidb` | Go | From 5.3.0 | 5.3.1 |
| `github.com/pingcap/tidb` | Go | From 5.3.0 | 5.3.1 |

Products: Pingcap Tidb.

## How do I fix CVE-2022-31011?

Upgrade github.com/pingcap/tidb to a fixed version for your release line: 0.0.0-20220221072141-27ffd1126da1, 1.1.0-beta.0.20220221072141-27ffd1126da1 or 5.3.1.

## Is CVE-2022-31011 being exploited?

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

## Other vulnerabilities in pingcap tidb

- [CVE-2024-41433](https://insights.sbomify.com/CVE-2024-41433/): Memory corruption in n/a (critical 9.8)
- [CVE-2024-35618](https://insights.sbomify.com/CVE-2024-35618/): Null dereference in n/a (high 7.5)
- [CVE-2022-34969](https://insights.sbomify.com/CVE-2022-34969/): Null dereference in n/a (high 7.5)
- [CVE-2024-33809](https://insights.sbomify.com/CVE-2024-33809/): Memory corruption in n/a (medium 6.5)
- [CVE-2024-41434](https://insights.sbomify.com/CVE-2024-41434/): Denial of service in n/a (medium 4.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-31011 and fix it if it is affected.

What it is: CVE-2022-31011 is a high-severity authentication bypass vulnerability in pingcap tidb, published on 31 May 2022. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-31011 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/pingcap/tidb (Go): affected from 0.0.0-20210808221113-a7fdc2a05663; fixed in 0.0.0-20220221072141-27ffd1126da1
- github.com/pingcap/tidb (Go): affected from 0.0.0-20210808221113-a7fdc2a05663; fixed in 0.0.0-20220221072141-27ffd1126da1
- github.com/pingcap/tidb (Go): affected from 1.1.0-beta.0.20210808221113-a7fdc2a05663; fixed in 1.1.0-beta.0.20220221072141-27ffd1126da1
- github.com/pingcap/tidb (Go): affected from 1.1.0-beta.0.20210808221113-a7fdc2a05663; fixed in 1.1.0-beta.0.20220221072141-27ffd1126da1
- github.com/pingcap/tidb (Go): affected from 5.3.0; fixed in 5.3.1
- github.com/pingcap/tidb (Go): affected from 5.3.0; fixed in 5.3.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-2022-31011/ (Markdown: https://insights.sbomify.com/CVE-2022-31011/index.md)
```

## Sources

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

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