CVE-2021-25987: Hexo Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-q54r-r9pr-w7qv
CVSS 4.6
CWE-79
Published
Advisory Summary

CVE-2021-25987 is a MODERATE (CVSS 4.6) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Hexo libraries in the npm ecosystem. The issue involves hexo vulnerable to xss. Remediation is available by upgrading affected packages to version 6.0.0.

CVE-2021-25987 at a Glance

CVE Identifier CVE-2021-25987
GHSA Identifier GHSA-q54r-r9pr-w7qv
Severity MODERATE
CVSS v3.1 Base Score 4.6
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Hexo
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.6

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

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

How to Fix CVE-2021-25987

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

hexo fixed: 6.0.0
npm install hexo@6.0.0
Verify Direct and Transitive Dependencies

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

npm ls hexo

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-25987, inspect your project dependencies using npm:

npm ls hexo

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

Note: The npm ls hexo command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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 Hexo, 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

Hexo versions 0.0.1 to 5.4.0 are vulnerable against stored XSS. The post “body” and “tags” don’t sanitize malicious javascript during web page generation. Local unprivileged attacker can inject arbitrary code.

CVE-2021-25987 Affected Hexo Versions

1 component(s)
Fixed Versions:
6.0.0
Product / Package Ecosystem Affected Versions Fixed Version
hexo
npm
≥ 0.0.1
< 6.0.0
6.0.0

References

Frequently Asked Questions

What is CVE-2021-25987?
CVE-2021-25987 is a security vulnerability in Hexo involving Hexo Vulnerable to XSS under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Hexo versions are affected?
Affected versions include releases prior to 6.0.0 across affected packages: hexo.
What version fixes CVE-2021-25987?
Upgrading to 6.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is hexo affected?
Yes, hexo is affected in releases prior to 6.0.0. Upgrade your dependency to 6.0.0 or later.
What is the CVSS score of CVE-2021-25987?
CVE-2021-25987 has a CVSS v3.1 base score of 4.6 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2021-25987?
CVE-2021-25987 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 npm dependencies for CVE-2021-25987?
Run the dependency tree command: 'npm ls hexo'. 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-q54r-r9pr-w7qv",
  "modified" : "2023-09-13T19:55:33Z",
  "published" : "2021-12-01T18:27:44Z",
  "aliases" : [ "CVE-2021-25987" ],
  "summary" : "Hexo Vulnerable to XSS",
  "details" : "Hexo versions 0.0.1 to 5.4.0 are vulnerable against stored XSS. The post “body” and “tags” don’t sanitize malicious javascript during web page generation. Local unprivileged attacker can inject arbitrary code.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "hexo"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.0.1"
      }, {
        "fixed" : "6.0.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.4.0"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-25987"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hexojs/hexo/issues/4838"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hexojs/hexo/pull/4750"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hexojs/hexo/commit/5170df2d3fa9c69e855c4b7c2b084ebfd92d5200"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hexojs/hexo"
  }, {
    "type" : "WEB",
    "url" : "https://www.whitesourcesoftware.com/vulnerability-database/CVE-2021-25987"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-01T16:15:32Z",
    "nvd_published_at" : "2021-11-30T14:15:00Z"
  }
}