CVE-2020-26297: MdBook Cross-Site Scripting Vulnerability

HIGH
Advisory Identifier: GHSA-gx5w-rrhp-f436
CVSS 8.2
CWE-79
Published
Advisory Summary

CVE-2020-26297 is a HIGH (CVSS 8.2) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting MdBook libraries in the crates.io ecosystem. The issue involves xss in mdbook. Remediation is available by upgrading affected packages to version 0.4.5.

CVE-2020-26297 at a Glance

CVE Identifier CVE-2020-26297
GHSA Identifier GHSA-gx5w-rrhp-f436
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product MdBook
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 8.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2020-26297

To remediate this vulnerability, upgrade all affected MdBook dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mdBook fixed: 0.4.5
Upgrade mdBook to 0.4.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for mdBook

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-26297, inspect your project dependencies for MdBook:

inspect dependencies for mdBook

Analyze the terminal output to locate any version of MdBook in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In MdBook, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

> This is a cross-post of [the official security advisory][ml]. The official post contains a signed version with our PGP key, as well. [ml]: https://groups.google.com/g/rustlang-security-announcements/c/3-sO6of29O0 The Rust Security Response Working Group was recently notified of a security issue affecting the search feature of mdBook, which could allow an attacker to execute arbitrary JavaScript code on the page. The CVE for this vulnerability is [CVE-2020-26297](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-26297). ## Overview 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. ## Mitigations Owners of websites built with mdBook have to upgrade to mdBook 0.4.5 or greater and rebuild their website contents with it. It's possible to install mdBook 0.4.5 on the local system with: ``` cargo install mdbook --version 0.4.5 --force ``` ## Acknowledgements Thanks to Kamil Vavra for responsibly disclosing the vulnerability to us according to [our security policy](https://www.rust-lang.org/policies/security). ## Timeline of events All times are listed in UTC. - 2020-12-30 20:14 - The issue is reported to the Rust Security Response WG - 2020-12-30 20:32 - The issue is acknowledged and the investigation began - 2020-12-30 21:21 - Found the cause of the vulnerability and prepared the patch - 2021-01-04 15:00 - Patched version released and vulnerability disclosed

CVE-2020-26297 Affected MdBook Versions

1 component(s)
Fixed Versions:
0.4.5
Product / Package Ecosystem Affected Versions Fixed Version
mdBook
crates.io
≥ 0.1.4
< 0.4.5
0.4.5

References

Frequently Asked Questions

What is CVE-2020-26297?
CVE-2020-26297 is a security vulnerability in MdBook involving XSS in mdBook under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which MdBook versions are affected?
Affected versions include releases prior to 0.4.5 across affected packages: mdBook.
What version fixes CVE-2020-26297?
Upgrading to 0.4.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mdBook affected?
Yes, mdBook is affected in releases prior to 0.4.5. Upgrade your dependency to 0.4.5 or later.
What is the CVSS score of CVE-2020-26297?
CVE-2020-26297 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N.
What CWE is associated with CVE-2020-26297?
CVE-2020-26297 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check crates.io dependencies for CVE-2020-26297?
Run the dependency tree command: 'inspect dependencies for mdBook'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gx5w-rrhp-f436",
  "modified" : "2021-08-18T21:06:53Z",
  "published" : "2021-08-25T20:56:20Z",
  "aliases" : [ "CVE-2020-26297" ],
  "summary" : "XSS in mdBook",
  "details" : "> This is a cross-post of [the official security advisory][ml]. The official post contains a signed version with our PGP key, as well.\n\n[ml]: https://groups.google.com/g/rustlang-security-announcements/c/3-sO6of29O0\n\nThe Rust Security Response Working Group was recently notified of a security issue affecting the search feature of mdBook, which could allow an attacker to execute arbitrary JavaScript code on the page.\n\nThe CVE for this vulnerability is [CVE-2020-26297](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-26297).\n\n## Overview\n\nThe 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.\n\nmdBook 0.4.5 fixes the vulnerability by properly escaping the search query.\n\n## Mitigations\n\nOwners of websites built with mdBook have to upgrade to mdBook 0.4.5 or greater and rebuild their website contents with it. It's possible to install mdBook 0.4.5 on the local system with:\n\n```\ncargo install mdbook --version 0.4.5 --force\n```\n\n## Acknowledgements\n\nThanks to Kamil Vavra for responsibly disclosing the vulnerability to us according to [our security policy](https://www.rust-lang.org/policies/security).\n\n## Timeline of events\n\nAll times are listed in UTC.\n\n- 2020-12-30 20:14 - The issue is reported to the Rust Security Response WG\n- 2020-12-30 20:32 - The issue is acknowledged and the investigation began\n- 2020-12-30 21:21 - Found the cause of the vulnerability and prepared the patch\n- 2021-01-04 15:00 - Patched version released and vulnerability disclosed",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "mdBook"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.4"
      }, {
        "fixed" : "0.4.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/mdBook/security/advisories/GHSA-gx5w-rrhp-f436"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-26297"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/mdBook/commit/32abeef088e98327ca0dfccdad92e84afa9d2e9b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-lang/mdBook"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-045"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/rustlang-security-announcements/c/3-sO6of29O0"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2021-0001.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-18T21:06:53Z",
    "nvd_published_at" : "2021-01-04T19:15:00Z"
  }
}