# CVE-2021-41088: Remote code execution via the web UI backend of Elvish

> Attackers can execute arbitrary code on a user's machine if they visit a malicious site while the Elvish web UI backend is running.

- **Severity:** High 8.0 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 23 Sep 2021
- **Updated:** 4 Aug 2024
- **Also known as:** DEBIAN-CVE-2021-41088, GHSA-fpv6-f8jw-rc3r, GO-2022-0937, UBUNTU-CVE-2021-41088

## What is CVE-2021-41088?

CVE-2021-41088 is a high-severity code injection vulnerability in elves elvish, published on 23 Sep 2021. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Elvish is a programming language and interactive shell, combined into one package. In versions prior to 0.14.0 Elvish's web UI backend (started by `elvish -web`) hosts an endpoint that allows executing the code sent from the web UI. The backend does not check the origin of requests correctly. As a result, if the user has the web UI backend open and visits a compromised or malicious website, the website can send arbitrary code to the endpoint in localhost. All Elvish releases from 0.14.0 onward no longer include the the web UI, although it is still possible for the user to build a version from source that includes the web UI. The issue can be patched for previous versions by removing the web UI (found in web, pkg/web or pkg/prog/web, depending on the exact version).

Weakness: CWE-346 (Origin Validation Error), CWE-668 (Exposure of Resource to Wrong Sphere)

## Which versions are affected by CVE-2021-41088?

3 open source packages ship an affected version, including github.com/elves/elvish. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/elves/elvish` | Go | All versions | 0.14.0 |
| `github.com/elves/elvish` | Go | All versions | 0.14.0 |
| `github.com/elves/elvish` | Go | All versions | 0.14.0 |

Products: Elv Elvish.

## How do I fix CVE-2021-41088?

Upgrade github.com/elves/elvish to 0.14.0 or later.

## Is CVE-2021-41088 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-41088 and fix it if it is affected.

What it is: CVE-2021-41088 is a high-severity code injection vulnerability in elves elvish, published on 23 Sep 2021. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-41088 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/elves/elvish (Go): affected all versions; fixed in 0.14.0
- github.com/elves/elvish (Go): affected all versions; fixed in 0.14.0
- github.com/elves/elvish (Go): affected all versions; fixed in 0.14.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-2021-41088/ (Markdown: https://insights.sbomify.com/CVE-2021-41088/index.md)
```

## Sources

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

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