# CVE-2020-26297: XSS in mdBook's search page


- **Severity:** High 8.2 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 4 Jan 2021
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-gx5w-rrhp-f436, RUSTSEC-2021-0001

## What is CVE-2020-26297?

CVE-2020-26297 is a high-severity vulnerability in rust-lang mdBook, published on 4 Jan 2021. 

### Official description

mdBook is a utility to create modern online books from Markdown files and is written in Rust. In mdBook before version 0.4.5, there is a vulnerability affecting the search feature of mdBook, which could allow an attacker to execute arbitrary JavaScript code on the page. The search feature of mdBook (introduced in version 0.1.4) was affected by a cross site scripting vulnerability that allowed an attacker to execute arbitrary JavaScript code on an user's browser by tricking the user into typing a malicious search query, or tricking the user into clicking a link to the search page with the malicious search query prefilled. mdBook 0.4.5 fixes the vulnerability by properly escaping the search query. Owners of websites built with mdBook have to upgrade to mdBook 0.4.5 or greater and rebuild their website contents with it.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

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

3 open source packages ship an affected version, including mdBook and mdbook. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `mdBook` | crates.io | From 0.1.4 | 0.4.5 |
| `mdBook` | crates.io | From 0.1.4 | 0.4.5 |
| `mdbook` | crates.io | From 0.1.4-0 | 0.4.5 |

Products: Rust-Lang Mdbook.

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

Upgrade mdBook to 0.4.5 or later.

## Is CVE-2020-26297 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2020-26297 is a high-severity vulnerability in rust-lang mdBook, published on 4 Jan 2021. 
Exploitation: There is no known exploitation of CVE-2020-26297 in the wild and no public exploit code.

Affected packages and fixed versions:
- mdBook (crates.io): affected from 0.1.4; fixed in 0.4.5
- mdBook (crates.io): affected from 0.1.4; fixed in 0.4.5
- mdbook (crates.io): affected from 0.1.4-0; fixed in 0.4.5

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

## Sources

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

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