# CVE-2022-31022: Missing Role Based Access Control for the REST handlers in bleve/http package

> Attackers can create or delete arbitrary directories on the server if the bleve/http package is used without additional access controls.

- **Severity:** Medium 6.2 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 1 Jun 2022
- **Updated:** 8 May 2025
- **Also known as:** DEBIAN-CVE-2022-31022, GHSA-9w9f-6mg8-jp7w, GO-2022-0470, MINI-fg56-938j-xcpr, MINI-q4h9-chqh-5m28, MINI-w57p-f8jx-g5qq, UBUNTU-CVE-2022-31022

## What is CVE-2022-31022?

CVE-2022-31022 is a medium-severity missing authorization vulnerability in blevesearch bleve, published on 1 Jun 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

Bleve is a text indexing library for go. Bleve includes HTTP utilities under bleve/http package, that are used by its sample application. These HTTP methods pave way for exploitation of a node’s filesystem where the bleve index resides, if the user has used bleve’s own HTTP (bleve/http) handlers for exposing the access to the indexes. For instance, the CreateIndexHandler (`http/index_create.go`) and DeleteIndexHandler (`http/index_delete.go`) enable an attacker to create a bleve index (directory structure) anywhere where the user running the server has the write permissions and to delete recursively any directory owned by the same user account. Users who have used the bleve/http package for exposing access to bleve index without the explicit 
handling for the Role Based Access Controls(RBAC) of the index assets would be impacted by this issue. Version 2.5.0 relocated the `http/` dir used _only_ by bleve-explorer to `blevesearch/bleve-explorer`, thereby addressing the issue. However, the http package is purely intended to be used for demonstration purposes. Bleve was never designed handle the RBACs, nor it was ever advertised to be used in that way. The collaborators of this project have decided to stay away from adding any authentication or authorization to bleve project at the moment. The bleve/http package is mainly for demonstration purposes and it lacks exhaustive validation of the user inputs as well as any authentication and authorization measures. It is recommended to not use bleve/http in production use cases.

Weakness: CWE-306 (Missing Authentication for Critical Functionality), CWE-288 (Authentication Bypass Using an Alternate Path or Channel)

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

6 open source packages ship an affected version, including github.com/blevesearch/bleve and github.com/blevesearch/bleve/v2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/blevesearch/bleve` | Go | All versions | None |
| `github.com/blevesearch/bleve` | Go | All versions to 1.10.14 | None |
| `github.com/blevesearch/bleve` | Go | All versions to 1.10.14 | None |
| `github.com/blevesearch/bleve/v2` | Go | All versions | 2.5.0 |
| `github.com/blevesearch/bleve/v2` | Go | All versions | 2.5.0 |
| `github.com/blevesearch/bleve/v2` | Go | All versions | 2.5.0 |

Products: Couchbase Bleve.

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

Upgrade to a fixed version.

## Is CVE-2022-31022 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2022-31022 is a medium-severity missing authorization vulnerability in blevesearch bleve, published on 1 Jun 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-31022 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/blevesearch/bleve (Go): affected all versions; no fix listed
- github.com/blevesearch/bleve (Go): affected all versions up to 1.10.14; no fix listed
- github.com/blevesearch/bleve (Go): affected all versions up to 1.10.14; no fix listed
- github.com/blevesearch/bleve/v2 (Go): affected all versions; fixed in 2.5.0
- github.com/blevesearch/bleve/v2 (Go): affected all versions; fixed in 2.5.0
- github.com/blevesearch/bleve/v2 (Go): affected all versions; fixed in 2.5.0

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-31022/ (Markdown: https://insights.sbomify.com/CVE-2022-31022/index.md)
```

## Sources

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

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